diff --git a/.gitignore b/.gitignore index de6cdcf..e3fa080 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ out/ classes/ +.factorypath # Quilt Loom remappedSrc/ diff --git a/src/main/java/pm/c7/scout/Scout.java b/src/main/java/pm/c7/scout/Scout.java index 550485f..00e4e52 100644 --- a/src/main/java/pm/c7/scout/Scout.java +++ b/src/main/java/pm/c7/scout/Scout.java @@ -1,22 +1,39 @@ package pm.c7.scout; import com.unascribed.lib39.core.api.AutoRegistry; + +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; + import org.quiltmc.loader.api.ModContainer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; -import org.quiltmc.qsl.item.group.api.QuiltItemGroup; import pm.c7.scout.config.ScoutConfigHandler; import pm.c7.scout.registry.ScoutItems; public class Scout implements ModInitializer { public static final AutoRegistry AUTOREGISTRY = AutoRegistry.of(ScoutUtil.MOD_ID); - public static final ItemGroup ITEM_GROUP = QuiltItemGroup.createWithIcon(new Identifier("scout", "itemgroup"), () -> new ItemStack(ScoutItems.SATCHEL)); + public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() + .icon(() -> new ItemStack(ScoutItems.SATCHEL)) + .name(Text.translatable("itemGroup.scout.itemgroup")) + .entries((context, entries) -> { + entries.addItem(ScoutItems.TANNED_LEATHER); + entries.addItem(ScoutItems.SATCHEL_STRAP); + entries.addItem(ScoutItems.SATCHEL); + entries.addItem(ScoutItems.UPGRADED_SATCHEL); + entries.addItem(ScoutItems.POUCH); + entries.addItem(ScoutItems.UPGRADED_POUCH); + }) + .build(); @Override - public void onInitialize(ModContainer mod) { + public void onInitialize(ModContainer mod) { new ScoutConfigHandler(); - ScoutItems.init(); - } + ScoutItems.init(); + Registry.register(Registries.ITEM_GROUP, new Identifier(ScoutUtil.MOD_ID, "itemgroup"), ITEM_GROUP); + } } diff --git a/src/main/java/pm/c7/scout/client/ScoutClient.java b/src/main/java/pm/c7/scout/client/ScoutClient.java index dc95f8f..17ab0ee 100644 --- a/src/main/java/pm/c7/scout/client/ScoutClient.java +++ b/src/main/java/pm/c7/scout/client/ScoutClient.java @@ -108,7 +108,7 @@ public class ScoutClient implements ClientModInitializer { } }); - ScreenEvents.AFTER_INIT.register((screen, client, scaledWidth, scaledHeight) -> { + ScreenEvents.AFTER_INIT.register((screen, client, firstInit) -> { if (screen instanceof HandledScreen handledScreen && client.player != null) { if (ScoutUtil.isScreenBlacklisted(screen)) { // realistically no one is going to have a screen bigger than 2147483647 pixels diff --git a/src/main/java/pm/c7/scout/client/gui/BagTooltipComponent.java b/src/main/java/pm/c7/scout/client/gui/BagTooltipComponent.java index 838b8b9..b876eda 100644 --- a/src/main/java/pm/c7/scout/client/gui/BagTooltipComponent.java +++ b/src/main/java/pm/c7/scout/client/gui/BagTooltipComponent.java @@ -1,12 +1,9 @@ package pm.c7.scout.client.gui; import com.google.common.math.IntMath; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.tooltip.TooltipComponent; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.util.collection.DefaultedList; import pm.c7.scout.ScoutUtil; @@ -15,46 +12,43 @@ import pm.c7.scout.item.BagTooltipData; import java.math.RoundingMode; public class BagTooltipComponent implements TooltipComponent { - private final DefaultedList inventory; - private final int slotCount; + private final DefaultedList inventory; + private final int slotCount; - public BagTooltipComponent(BagTooltipData data) { - this.inventory = data.getInventory(); - this.slotCount = data.getSlotCount(); - } + public BagTooltipComponent(BagTooltipData data) { + this.inventory = data.getInventory(); + this.slotCount = data.getSlotCount(); + } - @Override - public int getHeight() { - return (18 * IntMath.divide(slotCount, 6, RoundingMode.UP)) + 2; - } + @Override + public int getHeight() { + return (18 * IntMath.divide(slotCount, 6, RoundingMode.UP)) + 2; + } - @Override - public int getWidth(TextRenderer textRenderer) { - return 18 * (Math.min(slotCount, 6)); - } + @Override + public int getWidth(TextRenderer textRenderer) { + return 18 * (Math.min(slotCount, 6)); + } - @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { - int originalX = x; + @Override + public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graphics) { + int originalX = x; - for (int i = 0; i < slotCount; i++) { - ItemStack itemStack = this.inventory.get(i); - this.drawSlot(matrices, x, y, z); - itemRenderer.renderInGuiWithOverrides(itemStack, x + 1, y + 1, i); - itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, x + 1, y + 1); + for (int i = 0; i < slotCount; i++) { + this.drawSlot(x, y, i, graphics, textRenderer); - x += 18; - if ((i + 1) % 6 == 0) { - y += 18; - x = originalX; - } - } - } - - private void drawSlot(MatrixStack matrices, int x, int y, int z) { - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); - DrawableHelper.drawTexture(matrices, x, y, z, 46, 7, 18, 18, 256, 256); - } + x += 18; + if ((i + 1) % 6 == 0) { + y += 18; + x = originalX; + } + } + } + private void drawSlot(int x, int y, int index, GuiGraphics graphics, TextRenderer textRenderer) { + ItemStack itemStack = this.inventory.get(index); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 46, 7, 18, 18, 256, 256); + graphics.drawItem(itemStack, x + 1, y + 1, index); + graphics.drawItemInSlot(textRenderer, itemStack, x + 1, y + 1); + } } diff --git a/src/main/java/pm/c7/scout/client/render/PouchFeatureRenderer.java b/src/main/java/pm/c7/scout/client/render/PouchFeatureRenderer.java index 5f82cc6..93fa887 100644 --- a/src/main/java/pm/c7/scout/client/render/PouchFeatureRenderer.java +++ b/src/main/java/pm/c7/scout/client/render/PouchFeatureRenderer.java @@ -6,11 +6,11 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.render.item.HeldItemRenderer; -import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.Axis; import pm.c7.scout.ScoutUtil; import pm.c7.scout.item.BaseBagItem; @@ -29,21 +29,21 @@ public class PouchFeatureRenderer) this.getContextModel()).leftLeg.rotate(matrices); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); + matrices.multiply(Axis.X_POSITIVE.rotationDegrees(180.0F)); + matrices.multiply(Axis.Y_POSITIVE.rotationDegrees(-90.0F)); matrices.scale(0.325F, 0.325F, 0.325F); matrices.translate(0F, -0.325F, -0.475F); - this.heldItemRenderer.renderItem(entity, leftPouch, ModelTransformation.Mode.FIXED, false, matrices, vertexConsumers, light); + this.heldItemRenderer.renderItem(entity, leftPouch, ModelTransformationMode.FIXED, false, matrices, vertexConsumers, light); matrices.pop(); } if (!rightPouch.isEmpty()) { matrices.push(); ((PlayerEntityModel) this.getContextModel()).rightLeg.rotate(matrices); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); + matrices.multiply(Axis.X_POSITIVE.rotationDegrees(180.0F)); + matrices.multiply(Axis.Y_POSITIVE.rotationDegrees(-90.0F)); matrices.scale(0.325F, 0.325F, 0.325F); matrices.translate(0F, -0.325F, 0.475F); - this.heldItemRenderer.renderItem(entity, rightPouch, ModelTransformation.Mode.FIXED, false, matrices, vertexConsumers, light); + this.heldItemRenderer.renderItem(entity, rightPouch, ModelTransformationMode.FIXED, false, matrices, vertexConsumers, light); matrices.pop(); } } diff --git a/src/main/java/pm/c7/scout/mixin/ItemStackMixin.java b/src/main/java/pm/c7/scout/mixin/ItemStackMixin.java index bb533ca..d5ec36c 100644 --- a/src/main/java/pm/c7/scout/mixin/ItemStackMixin.java +++ b/src/main/java/pm/c7/scout/mixin/ItemStackMixin.java @@ -10,10 +10,10 @@ import pm.c7.scout.item.BaseBagItem; @Mixin(ItemStack.class) public class ItemStackMixin { - // Trinkets calls isItemEqual to check whether it should unequip old and equip new (https://github.com/emilyploszaj/trinkets/blob/37ee13d6/src/main/java/dev/emi/trinkets/mixin/LivingEntityMixin.java#L196-L199) - // Excluding ourselves from this check to force unequip/equip when switching bag items fixes a duplication bug (GH-12) + // Trinkets calls areEqual to check whether it should unequip old and equip new (https://github.com/emilyploszaj/trinkets/blob/7cb63ce0/src/main/java/dev/emi/trinkets/mixin/LivingEntityMixin.java#L155-L158) + // Excluding ourselves from this check to force unequip/equip when switching bag items fixes a duplication bug // Gross and hacky but oh well, can't mixin mixins. - @Inject(method = "isItemEqual", at = @At("HEAD"), cancellable = true) + @Inject(method = "areEqual", at = @At("HEAD"), cancellable = true) private void scout$grossTrinketsEquipFix(ItemStack newStack, CallbackInfoReturnable callbackInfo) { ItemStack self = (ItemStack) (Object) this; if (self.getItem() instanceof BaseBagItem && newStack.getItem() instanceof BaseBagItem) { diff --git a/src/main/java/pm/c7/scout/mixin/ServerPlayerEntityMixin.java b/src/main/java/pm/c7/scout/mixin/ServerPlayerEntityMixin.java index eec5513..2ca4095 100644 --- a/src/main/java/pm/c7/scout/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/pm/c7/scout/mixin/ServerPlayerEntityMixin.java @@ -21,74 +21,74 @@ import pm.c7.scout.screen.BagSlot; @Mixin(ServerPlayerEntity.class) public class ServerPlayerEntityMixin { - @Inject(method = "onDeath", at = @At("HEAD")) - private void scout$attemptFixGraveMods(DamageSource source, CallbackInfo callbackInfo) { - ServerPlayerEntity player = (ServerPlayerEntity) (Object) this; - ScoutScreenHandler handler = (ScoutScreenHandler) player.playerScreenHandler; + @Inject(method = "onDeath", at = @At("HEAD")) + private void scout$attemptFixGraveMods(DamageSource source, CallbackInfo callbackInfo) { + ServerPlayerEntity player = (ServerPlayerEntity) (Object) this; + ScoutScreenHandler handler = (ScoutScreenHandler) player.playerScreenHandler; - if (!player.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) { - ItemStack backStack = ScoutUtil.findBagItem(player, BagType.SATCHEL, false); - if (!backStack.isEmpty()) { - BaseBagItem bagItem = (BaseBagItem) backStack.getItem(); - int slots = bagItem.getSlotCount(); + if (!player.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) { + ItemStack backStack = ScoutUtil.findBagItem(player, BagType.SATCHEL, false); + if (!backStack.isEmpty()) { + BaseBagItem bagItem = (BaseBagItem) backStack.getItem(); + int slots = bagItem.getSlotCount(); - DefaultedList bagSlots = handler.scout$getSatchelSlots(); + DefaultedList bagSlots = handler.scout$getSatchelSlots(); - for (int i = 0; i < slots; i++) { - BagSlot slot = bagSlots.get(i); - slot.setInventory(null); - slot.setEnabled(false); - } + for (int i = 0; i < slots; i++) { + BagSlot slot = bagSlots.get(i); + slot.setInventory(null); + slot.setEnabled(false); + } - PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); - packet.writeBoolean(false); - packet.writeInt(0); - packet.writeItemStack(backStack); + PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); + packet.writeBoolean(false); + packet.writeInt(0); + packet.writeItemStack(backStack); - ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); - } + ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); + } - ItemStack leftPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, false); - if (!leftPouchStack.isEmpty()) { - BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem(); - int slots = bagItem.getSlotCount(); + ItemStack leftPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, false); + if (!leftPouchStack.isEmpty()) { + BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem(); + int slots = bagItem.getSlotCount(); - DefaultedList bagSlots = handler.scout$getLeftPouchSlots(); + DefaultedList bagSlots = handler.scout$getLeftPouchSlots(); - for (int i = 0; i < slots; i++) { - BagSlot slot = bagSlots.get(i); - slot.setInventory(null); - slot.setEnabled(false); - } + for (int i = 0; i < slots; i++) { + BagSlot slot = bagSlots.get(i); + slot.setInventory(null); + slot.setEnabled(false); + } - PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); - packet.writeBoolean(false); - packet.writeInt(0); - packet.writeItemStack(leftPouchStack); + PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); + packet.writeBoolean(false); + packet.writeInt(0); + packet.writeItemStack(leftPouchStack); - ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); - } + ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); + } - ItemStack rightPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, true); - if (!rightPouchStack.isEmpty()) { - BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem(); - int slots = bagItem.getSlotCount(); + ItemStack rightPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, true); + if (!rightPouchStack.isEmpty()) { + BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem(); + int slots = bagItem.getSlotCount(); - DefaultedList bagSlots = handler.scout$getRightPouchSlots(); + DefaultedList bagSlots = handler.scout$getRightPouchSlots(); - for (int i = 0; i < slots; i++) { - BagSlot slot = bagSlots.get(i); - slot.setInventory(null); - slot.setEnabled(false); - } + for (int i = 0; i < slots; i++) { + BagSlot slot = bagSlots.get(i); + slot.setInventory(null); + slot.setEnabled(false); + } - PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); - packet.writeBoolean(false); - packet.writeInt(1); - packet.writeItemStack(rightPouchStack); + PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); + packet.writeBoolean(false); + packet.writeInt(1); + packet.writeItemStack(rightPouchStack); - ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); - } - } - } + ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); + } + } + } } diff --git a/src/main/java/pm/c7/scout/mixin/client/AbstractFurnaceScreenMixin.java b/src/main/java/pm/c7/scout/mixin/client/AbstractFurnaceScreenMixin.java index b44b278..dd830b4 100644 --- a/src/main/java/pm/c7/scout/mixin/client/AbstractFurnaceScreenMixin.java +++ b/src/main/java/pm/c7/scout/mixin/client/AbstractFurnaceScreenMixin.java @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.ingame.AbstractFurnaceScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; +import net.minecraft.client.gui.screen.recipe.book.RecipeBookProvider; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.screen.AbstractFurnaceScreenHandler; diff --git a/src/main/java/pm/c7/scout/mixin/client/CraftingScreenMixin.java b/src/main/java/pm/c7/scout/mixin/client/CraftingScreenMixin.java index cd121a4..af904c8 100644 --- a/src/main/java/pm/c7/scout/mixin/client/CraftingScreenMixin.java +++ b/src/main/java/pm/c7/scout/mixin/client/CraftingScreenMixin.java @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.ingame.CraftingScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; +import net.minecraft.client.gui.screen.recipe.book.RecipeBookProvider; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.screen.CraftingScreenHandler; diff --git a/src/main/java/pm/c7/scout/mixin/client/HandledScreenMixin.java b/src/main/java/pm/c7/scout/mixin/client/HandledScreenMixin.java index 45d9181..b80d97d 100644 --- a/src/main/java/pm/c7/scout/mixin/client/HandledScreenMixin.java +++ b/src/main/java/pm/c7/scout/mixin/client/HandledScreenMixin.java @@ -4,13 +4,13 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.Slot; @@ -47,16 +47,14 @@ public abstract class HandledScreenMixin extends Screen protected int backgroundHeight; @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/util/math/MatrixStack;FII)V")) - private void scout$drawSatchelRow(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + private void scout$drawSatchelRow(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) { ItemStack backStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.SATCHEL, false); if (!backStack.isEmpty()) { BaseBagItem bagItem = (BaseBagItem) backStack.getItem(); int slots = bagItem.getSlotCount(); - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); int x = this.x; int y = this.y + this.backgroundHeight - 3; @@ -65,7 +63,7 @@ public abstract class HandledScreenMixin extends Screen y -= 1; } - this.drawTexture(matrices, x, y, 0, 32, 176, 4); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 32, 176, 4); y += 4; int u = 0; @@ -75,30 +73,32 @@ public abstract class HandledScreenMixin extends Screen if (slot % 9 == 0) { x = this.x; u = 0; - this.drawTexture(matrices, x, y, u, v, 7, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 7, 18); x += 7; u += 7; } - this.drawTexture(matrices, x, y, u, v, 18, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 18, 18); x += 18; u += 18; if ((slot + 1) % 9 == 0) { - this.drawTexture(matrices, x, y, u, v, 7, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 7, 18); y += 18; } } x = this.x; - this.drawTexture(matrices, x, y, 0, 54, 176, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 54, 176, 7); + + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } } } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;disableDepthTest()V")) - private void scout$drawPouchSlots(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;disableDepthTest()V", remap = false)) + private void scout$drawPouchSlots(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) { ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, false); if (!leftPouchStack.isEmpty()) { @@ -113,22 +113,21 @@ public abstract class HandledScreenMixin extends Screen y -= 1; } - RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - this.drawTexture(matrices, x, y, 18, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 18, 25, 7, 7); for (int i = 0; i < columns; i++) { x -= 11; - this.drawTexture(matrices, x, y, 7, 25, 11, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 25, 11, 7); } if (columns > 1) { for (int i = 0; i < columns - 1; i++) { x -= 7; - this.drawTexture(matrices, x, y, 7, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 25, 7, 7); } } x -= 7; - this.drawTexture(matrices, x, y, 0, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 25, 7, 7); x = this.x + 7; y -= 54; @@ -138,33 +137,33 @@ public abstract class HandledScreenMixin extends Screen y += 54; } y -= 18; - this.drawTexture(matrices, x, y, 7, 7, 18, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 7, 18, 18); } x -= 7; y += 54; for (int i = 0; i < 3; i++) { y -= 18; - this.drawTexture(matrices, x, y, 0, 7, 7, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 7, 7, 18); } x = this.x; y -= 7; - this.drawTexture(matrices, x, y, 18, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 18, 0, 7, 7); for (int i = 0; i < columns; i++) { x -= 11; - this.drawTexture(matrices, x, y, 7, 0, 11, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 0, 11, 7); } if (columns > 1) { for (int i = 0; i < columns - 1; i++) { x -= 7; - this.drawTexture(matrices, x, y, 7, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 0, 7, 7); } } x -= 7; - this.drawTexture(matrices, x, y, 0, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 0, 7, 7); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } ItemStack rightPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, true); @@ -180,22 +179,21 @@ public abstract class HandledScreenMixin extends Screen y -= 1; } - RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - this.drawTexture(matrices, x, y, 25, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 25, 25, 7, 7); x += 7; for (int i = 0; i < columns; i++) { - this.drawTexture(matrices, x, y, 7, 25, 11, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 25, 11, 7); x += 11; } if (columns > 1) { for (int i = 0; i < columns - 1; i++) { - this.drawTexture(matrices, x, y, 7, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 25, 7, 7); x += 7; } } - this.drawTexture(matrices, x, y, 32, 25, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 32, 25, 7, 7); x = this.x + this.backgroundWidth - 25; y -= 54; @@ -205,33 +203,33 @@ public abstract class HandledScreenMixin extends Screen y += 54; } y -= 18; - this.drawTexture(matrices, x, y, 7, 7, 18, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 7, 18, 18); } x += 18; y += 54; for (int i = 0; i < 3; i++) { y -= 18; - this.drawTexture(matrices, x, y, 32, 7, 7, 18); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 32, 7, 7, 18); } x = this.x + this.backgroundWidth - 7; y -= 7; - this.drawTexture(matrices, x, y, 25, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 25, 0, 7, 7); x += 7; for (int i = 0; i < columns; i++) { - this.drawTexture(matrices, x, y, 7, 0, 11, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 0, 11, 7); x += 11; } if (columns > 1) { for (int i = 0; i < columns - 1; i++) { - this.drawTexture(matrices, x, y, 7, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 0, 7, 7); x += 7; } } - this.drawTexture(matrices, x, y, 32, 0, 7, 7); + graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 32, 0, 7, 7); - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } } } @@ -275,20 +273,20 @@ public abstract class HandledScreenMixin extends Screen } @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawForeground(Lnet/minecraft/client/util/math/MatrixStack;II)V")) - public void scout$drawOurSlots(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + public void scout$drawOurSlots(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) { for (int i = ScoutUtil.SATCHEL_SLOT_START; i > ScoutUtil.BAG_SLOTS_END; i--) { BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(i, this.client.player.playerScreenHandler); if (slot != null && slot.isEnabled()) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - this.drawSlot(matrices, slot); + this.drawSlot(graphics, slot); } if (this.isPointOverSlot(slot, mouseX, mouseY) && slot != null && slot.isEnabled()) { this.focusedSlot = slot; int slotX = slot.getX(); int slotY = slot.getY(); - drawSlotHighlight(matrices, slotX, slotY, this.getZOffset()); + drawSlotHighlight(graphics, slotX, slotY, 0); } } } @@ -314,9 +312,9 @@ public abstract class HandledScreenMixin extends Screen } @Shadow - private void drawSlot(MatrixStack matrices, Slot slot) {} + private void drawSlot(GuiGraphics graphics, Slot slot) {} @Shadow - public static void drawSlotHighlight(MatrixStack matrices, int x, int y, int z) {} + public static void drawSlotHighlight(GuiGraphics graphics, int x, int y, int z) {} @Shadow private boolean isPointOverSlot(Slot slot, double pointX, double pointY) { return false; diff --git a/src/main/java/pm/c7/scout/mixin/client/InventoryScreenMixin.java b/src/main/java/pm/c7/scout/mixin/client/InventoryScreenMixin.java index 1520905..5a32458 100644 --- a/src/main/java/pm/c7/scout/mixin/client/InventoryScreenMixin.java +++ b/src/main/java/pm/c7/scout/mixin/client/InventoryScreenMixin.java @@ -5,7 +5,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; +import net.minecraft.client.gui.screen.recipe.book.RecipeBookProvider; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; diff --git a/src/main/java/pm/c7/scout/mixin/client/RecipeBookWidgetMixin.java b/src/main/java/pm/c7/scout/mixin/client/RecipeBookWidgetMixin.java index 9e2543b..51b9ec8 100644 --- a/src/main/java/pm/c7/scout/mixin/client/RecipeBookWidgetMixin.java +++ b/src/main/java/pm/c7/scout/mixin/client/RecipeBookWidgetMixin.java @@ -3,7 +3,7 @@ package pm.c7.scout.mixin.client; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; +import net.minecraft.client.gui.screen.recipe.book.RecipeBookWidget; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/pm/c7/scout/registry/ScoutItems.java b/src/main/java/pm/c7/scout/registry/ScoutItems.java index 497b7c0..f0258bb 100644 --- a/src/main/java/pm/c7/scout/registry/ScoutItems.java +++ b/src/main/java/pm/c7/scout/registry/ScoutItems.java @@ -1,22 +1,22 @@ package pm.c7.scout.registry; import net.minecraft.item.Item; +import net.minecraft.registry.Registries; import net.minecraft.util.Rarity; -import net.minecraft.util.registry.Registry; import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; import pm.c7.scout.Scout; import pm.c7.scout.ScoutUtil; import pm.c7.scout.item.BaseBagItem; public class ScoutItems { - public static final Item TANNED_LEATHER = new Item(new QuiltItemSettings().group(Scout.ITEM_GROUP)); - public static final Item SATCHEL_STRAP = new Item(new QuiltItemSettings().group(Scout.ITEM_GROUP)); - public static final BaseBagItem SATCHEL = new BaseBagItem(new QuiltItemSettings().group(Scout.ITEM_GROUP).maxCount(1), ScoutUtil.MAX_SATCHEL_SLOTS / 2, BaseBagItem.BagType.SATCHEL); - public static final BaseBagItem UPGRADED_SATCHEL = new BaseBagItem(new QuiltItemSettings().group(Scout.ITEM_GROUP).maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_SATCHEL_SLOTS, BaseBagItem.BagType.SATCHEL); - public static final BaseBagItem POUCH = new BaseBagItem(new QuiltItemSettings().group(Scout.ITEM_GROUP).maxCount(1), ScoutUtil.MAX_POUCH_SLOTS / 2, BaseBagItem.BagType.POUCH); - public static final BaseBagItem UPGRADED_POUCH = new BaseBagItem(new QuiltItemSettings().group(Scout.ITEM_GROUP).maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_POUCH_SLOTS, BaseBagItem.BagType.POUCH); + public static final Item TANNED_LEATHER = new Item(new QuiltItemSettings()); + public static final Item SATCHEL_STRAP = new Item(new QuiltItemSettings()); + public static final BaseBagItem SATCHEL = new BaseBagItem(new QuiltItemSettings().maxCount(1), ScoutUtil.MAX_SATCHEL_SLOTS / 2, BaseBagItem.BagType.SATCHEL); + public static final BaseBagItem UPGRADED_SATCHEL = new BaseBagItem(new QuiltItemSettings().maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_SATCHEL_SLOTS, BaseBagItem.BagType.SATCHEL); + public static final BaseBagItem POUCH = new BaseBagItem(new QuiltItemSettings().maxCount(1), ScoutUtil.MAX_POUCH_SLOTS / 2, BaseBagItem.BagType.POUCH); + public static final BaseBagItem UPGRADED_POUCH = new BaseBagItem(new QuiltItemSettings().maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_POUCH_SLOTS, BaseBagItem.BagType.POUCH); public static void init() { - Scout.AUTOREGISTRY.autoRegister(Registry.ITEM, ScoutItems.class, Item.class); + Scout.AUTOREGISTRY.autoRegister(Registries.ITEM, ScoutItems.class, Item.class); } } diff --git a/src/main/java/pm/c7/scout/screen/BagSlot.java b/src/main/java/pm/c7/scout/screen/BagSlot.java index 35fbc4f..da1b815 100644 --- a/src/main/java/pm/c7/scout/screen/BagSlot.java +++ b/src/main/java/pm/c7/scout/screen/BagSlot.java @@ -10,87 +10,84 @@ import pm.c7.scout.config.ScoutConfigHandler; import pm.c7.scout.item.BaseBagItem; public class BagSlot extends Slot { - private final int index; - public Inventory inventory; - private boolean enabled = false; + private final int index; + public Inventory inventory; + private boolean enabled = false; private int realX; private int realY; - public BagSlot(int index, int x, int y) { - super(null, index, x, y); - this.index = index; + public BagSlot(int index, int x, int y) { + super(null, index, x, y); + this.index = index; this.realX = x; this.realY = y; - } + } - public void setInventory(Inventory inventory) { - this.inventory = inventory; - } + public void setInventory(Inventory inventory) { + this.inventory = inventory; + } - public void setEnabled(boolean state) { - enabled = state; - } + public void setEnabled(boolean state) { + enabled = state; + } - @Override - public boolean canInsert(ItemStack stack) { - if (stack.getItem() instanceof BaseBagItem) - return false; + @Override + public boolean canInsert(ItemStack stack) { + if (stack.getItem() instanceof BaseBagItem) + return false; if (stack.getItem() instanceof BlockItem blockItem) { if (blockItem.getBlock() instanceof ShulkerBoxBlock) return (boolean) ScoutConfigHandler.getConfigValue("allowShulkers").value(); } - return enabled && inventory != null; - } - - @Override - public boolean canTakeItems(PlayerEntity playerEntity) { - return enabled && inventory != null; - } - - @Override - public boolean isEnabled() { - return enabled && inventory != null; - } - - @Override - public ItemStack getStack() { - return enabled && this.inventory != null ? this.inventory.getStack(this.index) : ItemStack.EMPTY; - } - - @Override - public void setStack(ItemStack stack) { - if (enabled && this.inventory != null) { - this.inventory.setStack(this.index, stack); - this.markDirty(); - } - } + return enabled && inventory != null; + } @Override - public void m_tfmituvd(ItemStack stack) { + public boolean canTakeItems(PlayerEntity playerEntity) { + return enabled && inventory != null; + } + + @Override + public boolean isEnabled() { + return enabled && inventory != null; + } + + @Override + public ItemStack getStack() { + return enabled && this.inventory != null ? this.inventory.getStack(this.index) : ItemStack.EMPTY; + } + + @Override + public void setStack(ItemStack stack) { if (enabled && this.inventory != null) { this.inventory.setStack(this.index, stack); this.markDirty(); } } - @Override - public void markDirty() { - if (enabled && this.inventory != null) { - this.inventory.markDirty(); - } - } + @Override + public void setStackByPlayer(ItemStack stack) { + this.setStack(stack); + } - @Override - public ItemStack takeStack(int amount) { - return enabled && this.inventory != null ? this.inventory.removeStack(this.index, amount) : ItemStack.EMPTY; - } + @Override + public void markDirty() { + if (enabled && this.inventory != null) { + this.inventory.markDirty(); + } + } - @Override - public int getMaxItemCount() { - return enabled && this.inventory != null ? this.inventory.getMaxCountPerStack() : 0; - } + @Override + public ItemStack takeStack(int amount) { + return enabled && this.inventory != null ? this.inventory.removeStack(this.index, amount) : ItemStack.EMPTY; + } + + @Override + public int getMaxItemCount() { + return enabled && this.inventory != null ? this.inventory.getMaxCountPerStack() : 0; + } public int getX() { return this.realX;