feat: remove offhand (#125)

This commit is contained in:
Jacob
2025-08-12 04:58:14 +08:00
committed by GitHub
parent 773a8bec96
commit 3fe5ec7233
3 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package moe.nea.firmament.mixins;
import moe.nea.firmament.features.fixes.Fixes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.PlayerScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerScreenHandler.class)
public class MixinPlayerScreenHandler {
@Unique
private static final int OFF_HAND_SLOT = 40;
@Inject(method = "<init>", at = @At("TAIL"))
private void moveOffHandSlot(PlayerInventory inventory, boolean onServer, PlayerEntity owner, CallbackInfo ci) {
if (Fixes.TConfig.INSTANCE.getHideOffHand()) {
PlayerScreenHandler self = (PlayerScreenHandler) (Object) this;
self.slots.stream()
.filter(slot -> slot.getIndex() == OFF_HAND_SLOT)
.forEach(slot -> {
slot.x = -1000;
slot.y = -1000;
});
}
}
}

View File

@@ -29,6 +29,7 @@ object Fixes : FirmamentFeature {
val noHurtCam by toggle("disable-hurt-cam") { false }
val hideSlotHighlights by toggle("hide-slot-highlights") { false }
val hideRecipeBook by toggle("hide-recipe-book") { false }
val hideOffHand by toggle("hide-off-hand") { false }
}
override val config: ManagedConfig