Everything except transformers fixed for 1.20.1

This commit is contained in:
Cynthia Foxwell 2024-03-14 00:12:23 -06:00
parent 8fcb9f3acc
commit 04b4ddd3d8
14 changed files with 230 additions and 223 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
build/ build/
out/ out/
classes/ classes/
.factorypath
# Quilt Loom # Quilt Loom
remappedSrc/ remappedSrc/

View File

@ -1,22 +1,39 @@
package pm.c7.scout; package pm.c7.scout;
import com.unascribed.lib39.core.api.AutoRegistry; import com.unascribed.lib39.core.api.AutoRegistry;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; 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 net.minecraft.util.Identifier;
import org.quiltmc.loader.api.ModContainer; import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; 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.config.ScoutConfigHandler;
import pm.c7.scout.registry.ScoutItems; import pm.c7.scout.registry.ScoutItems;
public class Scout implements ModInitializer { public class Scout implements ModInitializer {
public static final AutoRegistry AUTOREGISTRY = AutoRegistry.of(ScoutUtil.MOD_ID); 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 @Override
public void onInitialize(ModContainer mod) { public void onInitialize(ModContainer mod) {
new ScoutConfigHandler(); new ScoutConfigHandler();
ScoutItems.init(); ScoutItems.init();
} Registry.register(Registries.ITEM_GROUP, new Identifier(ScoutUtil.MOD_ID, "itemgroup"), ITEM_GROUP);
}
} }

View File

@ -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 (screen instanceof HandledScreen<?> handledScreen && client.player != null) {
if (ScoutUtil.isScreenBlacklisted(screen)) { if (ScoutUtil.isScreenBlacklisted(screen)) {
// realistically no one is going to have a screen bigger than 2147483647 pixels // realistically no one is going to have a screen bigger than 2147483647 pixels

View File

@ -1,12 +1,9 @@
package pm.c7.scout.client.gui; package pm.c7.scout.client.gui;
import com.google.common.math.IntMath; import com.google.common.math.IntMath;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.font.TextRenderer; 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.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.item.ItemStack;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
import pm.c7.scout.ScoutUtil; import pm.c7.scout.ScoutUtil;
@ -15,46 +12,43 @@ import pm.c7.scout.item.BagTooltipData;
import java.math.RoundingMode; import java.math.RoundingMode;
public class BagTooltipComponent implements TooltipComponent { public class BagTooltipComponent implements TooltipComponent {
private final DefaultedList<ItemStack> inventory; private final DefaultedList<ItemStack> inventory;
private final int slotCount; private final int slotCount;
public BagTooltipComponent(BagTooltipData data) { public BagTooltipComponent(BagTooltipData data) {
this.inventory = data.getInventory(); this.inventory = data.getInventory();
this.slotCount = data.getSlotCount(); this.slotCount = data.getSlotCount();
} }
@Override @Override
public int getHeight() { public int getHeight() {
return (18 * IntMath.divide(slotCount, 6, RoundingMode.UP)) + 2; return (18 * IntMath.divide(slotCount, 6, RoundingMode.UP)) + 2;
} }
@Override @Override
public int getWidth(TextRenderer textRenderer) { public int getWidth(TextRenderer textRenderer) {
return 18 * (Math.min(slotCount, 6)); return 18 * (Math.min(slotCount, 6));
} }
@Override @Override
public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) { public void drawItems(TextRenderer textRenderer, int x, int y, GuiGraphics graphics) {
int originalX = x; int originalX = x;
for (int i = 0; i < slotCount; i++) { for (int i = 0; i < slotCount; i++) {
ItemStack itemStack = this.inventory.get(i); this.drawSlot(x, y, i, graphics, textRenderer);
this.drawSlot(matrices, x, y, z);
itemRenderer.renderInGuiWithOverrides(itemStack, x + 1, y + 1, i);
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, x + 1, y + 1);
x += 18; x += 18;
if ((i + 1) % 6 == 0) { if ((i + 1) % 6 == 0) {
y += 18; y += 18;
x = originalX; 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);
}
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);
}
} }

View File

@ -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.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.render.item.HeldItemRenderer; 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.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; 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.ScoutUtil;
import pm.c7.scout.item.BaseBagItem; import pm.c7.scout.item.BaseBagItem;
@ -29,21 +29,21 @@ public class PouchFeatureRenderer<T extends LivingEntity, M extends EntityModel<
if (!leftPouch.isEmpty()) { if (!leftPouch.isEmpty()) {
matrices.push(); matrices.push();
((PlayerEntityModel<?>) this.getContextModel()).leftLeg.rotate(matrices); ((PlayerEntityModel<?>) this.getContextModel()).leftLeg.rotate(matrices);
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); matrices.multiply(Axis.X_POSITIVE.rotationDegrees(180.0F));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); matrices.multiply(Axis.Y_POSITIVE.rotationDegrees(-90.0F));
matrices.scale(0.325F, 0.325F, 0.325F); matrices.scale(0.325F, 0.325F, 0.325F);
matrices.translate(0F, -0.325F, -0.475F); 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(); matrices.pop();
} }
if (!rightPouch.isEmpty()) { if (!rightPouch.isEmpty()) {
matrices.push(); matrices.push();
((PlayerEntityModel<?>) this.getContextModel()).rightLeg.rotate(matrices); ((PlayerEntityModel<?>) this.getContextModel()).rightLeg.rotate(matrices);
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); matrices.multiply(Axis.X_POSITIVE.rotationDegrees(180.0F));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); matrices.multiply(Axis.Y_POSITIVE.rotationDegrees(-90.0F));
matrices.scale(0.325F, 0.325F, 0.325F); matrices.scale(0.325F, 0.325F, 0.325F);
matrices.translate(0F, -0.325F, 0.475F); 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(); matrices.pop();
} }
} }

View File

@ -10,10 +10,10 @@ import pm.c7.scout.item.BaseBagItem;
@Mixin(ItemStack.class) @Mixin(ItemStack.class)
public class ItemStackMixin { 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) // 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 (GH-12) // 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. // 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<Boolean> callbackInfo) { private void scout$grossTrinketsEquipFix(ItemStack newStack, CallbackInfoReturnable<Boolean> callbackInfo) {
ItemStack self = (ItemStack) (Object) this; ItemStack self = (ItemStack) (Object) this;
if (self.getItem() instanceof BaseBagItem && newStack.getItem() instanceof BaseBagItem) { if (self.getItem() instanceof BaseBagItem && newStack.getItem() instanceof BaseBagItem) {

View File

@ -21,74 +21,74 @@ import pm.c7.scout.screen.BagSlot;
@Mixin(ServerPlayerEntity.class) @Mixin(ServerPlayerEntity.class)
public class ServerPlayerEntityMixin { public class ServerPlayerEntityMixin {
@Inject(method = "onDeath", at = @At("HEAD")) @Inject(method = "onDeath", at = @At("HEAD"))
private void scout$attemptFixGraveMods(DamageSource source, CallbackInfo callbackInfo) { private void scout$attemptFixGraveMods(DamageSource source, CallbackInfo callbackInfo) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this; ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
ScoutScreenHandler handler = (ScoutScreenHandler) player.playerScreenHandler; ScoutScreenHandler handler = (ScoutScreenHandler) player.playerScreenHandler;
if (!player.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) { if (!player.getWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
ItemStack backStack = ScoutUtil.findBagItem(player, BagType.SATCHEL, false); ItemStack backStack = ScoutUtil.findBagItem(player, BagType.SATCHEL, false);
if (!backStack.isEmpty()) { if (!backStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) backStack.getItem(); BaseBagItem bagItem = (BaseBagItem) backStack.getItem();
int slots = bagItem.getSlotCount(); int slots = bagItem.getSlotCount();
DefaultedList<BagSlot> bagSlots = handler.scout$getSatchelSlots(); DefaultedList<BagSlot> bagSlots = handler.scout$getSatchelSlots();
for (int i = 0; i < slots; i++) { for (int i = 0; i < slots; i++) {
BagSlot slot = bagSlots.get(i); BagSlot slot = bagSlots.get(i);
slot.setInventory(null); slot.setInventory(null);
slot.setEnabled(false); slot.setEnabled(false);
} }
PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
packet.writeBoolean(false); packet.writeBoolean(false);
packet.writeInt(0); packet.writeInt(0);
packet.writeItemStack(backStack); 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); ItemStack leftPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, false);
if (!leftPouchStack.isEmpty()) { if (!leftPouchStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem(); BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
int slots = bagItem.getSlotCount(); int slots = bagItem.getSlotCount();
DefaultedList<BagSlot> bagSlots = handler.scout$getLeftPouchSlots(); DefaultedList<BagSlot> bagSlots = handler.scout$getLeftPouchSlots();
for (int i = 0; i < slots; i++) { for (int i = 0; i < slots; i++) {
BagSlot slot = bagSlots.get(i); BagSlot slot = bagSlots.get(i);
slot.setInventory(null); slot.setInventory(null);
slot.setEnabled(false); slot.setEnabled(false);
} }
PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
packet.writeBoolean(false); packet.writeBoolean(false);
packet.writeInt(0); packet.writeInt(0);
packet.writeItemStack(leftPouchStack); 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); ItemStack rightPouchStack = ScoutUtil.findBagItem(player, BagType.POUCH, true);
if (!rightPouchStack.isEmpty()) { if (!rightPouchStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem(); BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
int slots = bagItem.getSlotCount(); int slots = bagItem.getSlotCount();
DefaultedList<BagSlot> bagSlots = handler.scout$getRightPouchSlots(); DefaultedList<BagSlot> bagSlots = handler.scout$getRightPouchSlots();
for (int i = 0; i < slots; i++) { for (int i = 0; i < slots; i++) {
BagSlot slot = bagSlots.get(i); BagSlot slot = bagSlots.get(i);
slot.setInventory(null); slot.setInventory(null);
slot.setEnabled(false); slot.setEnabled(false);
} }
PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
packet.writeBoolean(false); packet.writeBoolean(false);
packet.writeInt(1); packet.writeInt(1);
packet.writeItemStack(rightPouchStack); packet.writeItemStack(rightPouchStack);
ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet); ServerPlayNetworking.send(player, ScoutNetworking.ENABLE_SLOTS, packet);
} }
} }
} }
} }

View File

@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.ingame.AbstractFurnaceScreen; import net.minecraft.client.gui.screen.ingame.AbstractFurnaceScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen; 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.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.AbstractFurnaceScreenHandler; import net.minecraft.screen.AbstractFurnaceScreenHandler;

View File

@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.ingame.CraftingScreen; import net.minecraft.client.gui.screen.ingame.CraftingScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen; 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.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.CraftingScreenHandler; import net.minecraft.screen.CraftingScreenHandler;

View File

@ -4,13 +4,13 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen; import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen;
import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
@ -47,16 +47,14 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
protected int backgroundHeight; 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")) @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)) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) {
ItemStack backStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.SATCHEL, false); ItemStack backStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.SATCHEL, false);
if (!backStack.isEmpty()) { if (!backStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) backStack.getItem(); BaseBagItem bagItem = (BaseBagItem) backStack.getItem();
int slots = bagItem.getSlotCount(); int slots = bagItem.getSlotCount();
RenderSystem.setShader(GameRenderer::getPositionTexShader); graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
int x = this.x; int x = this.x;
int y = this.y + this.backgroundHeight - 3; int y = this.y + this.backgroundHeight - 3;
@ -65,7 +63,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
y -= 1; y -= 1;
} }
this.drawTexture(matrices, x, y, 0, 32, 176, 4); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 32, 176, 4);
y += 4; y += 4;
int u = 0; int u = 0;
@ -75,30 +73,32 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
if (slot % 9 == 0) { if (slot % 9 == 0) {
x = this.x; x = this.x;
u = 0; u = 0;
this.drawTexture(matrices, x, y, u, v, 7, 18); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 7, 18);
x += 7; x += 7;
u += 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; x += 18;
u += 18; u += 18;
if ((slot + 1) % 9 == 0) { 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; y += 18;
} }
} }
x = this.x; 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")) @Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;disableDepthTest()V", remap = false))
private void scout$drawPouchSlots(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { 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)) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) {
ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, false); ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, false);
if (!leftPouchStack.isEmpty()) { if (!leftPouchStack.isEmpty()) {
@ -113,22 +113,21 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
y -= 1; y -= 1;
} }
RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.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++) { for (int i = 0; i < columns; i++) {
x -= 11; 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) { if (columns > 1) {
for (int i = 0; i < columns - 1; i++) { for (int i = 0; i < columns - 1; i++) {
x -= 7; x -= 7;
this.drawTexture(matrices, x, y, 7, 25, 7, 7); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 25, 7, 7);
} }
} }
x -= 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; x = this.x + 7;
y -= 54; y -= 54;
@ -138,33 +137,33 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
y += 54; y += 54;
} }
y -= 18; y -= 18;
this.drawTexture(matrices, x, y, 7, 7, 18, 18); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 7, 18, 18);
} }
x -= 7; x -= 7;
y += 54; y += 54;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
y -= 18; 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; x = this.x;
y -= 7; 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++) { for (int i = 0; i < columns; i++) {
x -= 11; 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) { if (columns > 1) {
for (int i = 0; i < columns - 1; i++) { for (int i = 0; i < columns - 1; i++) {
x -= 7; x -= 7;
this.drawTexture(matrices, x, y, 7, 0, 7, 7); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 0, 7, 7);
} }
} }
x -= 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); ItemStack rightPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, true);
@ -180,22 +179,21 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
y -= 1; y -= 1;
} }
RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE); graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.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; x += 7;
for (int i = 0; i < columns; i++) { 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; x += 11;
} }
if (columns > 1) { if (columns > 1) {
for (int i = 0; i < columns - 1; i++) { 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; 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; x = this.x + this.backgroundWidth - 25;
y -= 54; y -= 54;
@ -205,33 +203,33 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
y += 54; y += 54;
} }
y -= 18; y -= 18;
this.drawTexture(matrices, x, y, 7, 7, 18, 18); graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 7, 7, 18, 18);
} }
x += 18; x += 18;
y += 54; y += 54;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
y -= 18; 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; x = this.x + this.backgroundWidth - 7;
y -= 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; x += 7;
for (int i = 0; i < columns; i++) { 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; x += 11;
} }
if (columns > 1) { if (columns > 1) {
for (int i = 0; i < columns - 1; i++) { 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; 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<T extends ScreenHandler> 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")) @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)) { if (this.client != null && this.client.player != null && !ScoutUtil.isScreenBlacklisted(this)) {
for (int i = ScoutUtil.SATCHEL_SLOT_START; i > ScoutUtil.BAG_SLOTS_END; i--) { for (int i = ScoutUtil.SATCHEL_SLOT_START; i > ScoutUtil.BAG_SLOTS_END; i--) {
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(i, this.client.player.playerScreenHandler); BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(i, this.client.player.playerScreenHandler);
if (slot != null && slot.isEnabled()) { if (slot != null && slot.isEnabled()) {
RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShader(GameRenderer::getPositionTexShader);
this.drawSlot(matrices, slot); this.drawSlot(graphics, slot);
} }
if (this.isPointOverSlot(slot, mouseX, mouseY) && slot != null && slot.isEnabled()) { if (this.isPointOverSlot(slot, mouseX, mouseY) && slot != null && slot.isEnabled()) {
this.focusedSlot = slot; this.focusedSlot = slot;
int slotX = slot.getX(); int slotX = slot.getX();
int slotY = slot.getY(); int slotY = slot.getY();
drawSlotHighlight(matrices, slotX, slotY, this.getZOffset()); drawSlotHighlight(graphics, slotX, slotY, 0);
} }
} }
} }
@ -314,9 +312,9 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
} }
@Shadow @Shadow
private void drawSlot(MatrixStack matrices, Slot slot) {} private void drawSlot(GuiGraphics graphics, Slot slot) {}
@Shadow @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 @Shadow
private boolean isPointOverSlot(Slot slot, double pointX, double pointY) { private boolean isPointOverSlot(Slot slot, double pointX, double pointY) {
return false; return false;

View File

@ -5,7 +5,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen; import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen; 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.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View File

@ -3,7 +3,7 @@ package pm.c7.scout.mixin.client;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient; 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 net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;

View File

@ -1,22 +1,22 @@
package pm.c7.scout.registry; package pm.c7.scout.registry;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.util.Rarity; import net.minecraft.util.Rarity;
import net.minecraft.util.registry.Registry;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import pm.c7.scout.Scout; import pm.c7.scout.Scout;
import pm.c7.scout.ScoutUtil; import pm.c7.scout.ScoutUtil;
import pm.c7.scout.item.BaseBagItem; import pm.c7.scout.item.BaseBagItem;
public class ScoutItems { public class ScoutItems {
public static final Item TANNED_LEATHER = new Item(new QuiltItemSettings().group(Scout.ITEM_GROUP)); public static final Item TANNED_LEATHER = new Item(new QuiltItemSettings());
public static final Item SATCHEL_STRAP = new Item(new QuiltItemSettings().group(Scout.ITEM_GROUP)); public static final Item SATCHEL_STRAP = new Item(new QuiltItemSettings());
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 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().group(Scout.ITEM_GROUP).maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_SATCHEL_SLOTS, 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().group(Scout.ITEM_GROUP).maxCount(1), ScoutUtil.MAX_POUCH_SLOTS / 2, BaseBagItem.BagType.POUCH); 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().group(Scout.ITEM_GROUP).maxCount(1).rarity(Rarity.RARE), ScoutUtil.MAX_POUCH_SLOTS, 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() { public static void init() {
Scout.AUTOREGISTRY.autoRegister(Registry.ITEM, ScoutItems.class, Item.class); Scout.AUTOREGISTRY.autoRegister(Registries.ITEM, ScoutItems.class, Item.class);
} }
} }

View File

@ -10,87 +10,84 @@ import pm.c7.scout.config.ScoutConfigHandler;
import pm.c7.scout.item.BaseBagItem; import pm.c7.scout.item.BaseBagItem;
public class BagSlot extends Slot { public class BagSlot extends Slot {
private final int index; private final int index;
public Inventory inventory; public Inventory inventory;
private boolean enabled = false; private boolean enabled = false;
private int realX; private int realX;
private int realY; private int realY;
public BagSlot(int index, int x, int y) { public BagSlot(int index, int x, int y) {
super(null, index, x, y); super(null, index, x, y);
this.index = index; this.index = index;
this.realX = x; this.realX = x;
this.realY = y; this.realY = y;
} }
public void setInventory(Inventory inventory) { public void setInventory(Inventory inventory) {
this.inventory = inventory; this.inventory = inventory;
} }
public void setEnabled(boolean state) { public void setEnabled(boolean state) {
enabled = state; enabled = state;
} }
@Override @Override
public boolean canInsert(ItemStack stack) { public boolean canInsert(ItemStack stack) {
if (stack.getItem() instanceof BaseBagItem) if (stack.getItem() instanceof BaseBagItem)
return false; return false;
if (stack.getItem() instanceof BlockItem blockItem) { if (stack.getItem() instanceof BlockItem blockItem) {
if (blockItem.getBlock() instanceof ShulkerBoxBlock) if (blockItem.getBlock() instanceof ShulkerBoxBlock)
return (boolean) ScoutConfigHandler.getConfigValue("allowShulkers").value(); return (boolean) ScoutConfigHandler.getConfigValue("allowShulkers").value();
} }
return enabled && inventory != null; 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();
}
}
@Override @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) { if (enabled && this.inventory != null) {
this.inventory.setStack(this.index, stack); this.inventory.setStack(this.index, stack);
this.markDirty(); this.markDirty();
} }
} }
@Override @Override
public void markDirty() { public void setStackByPlayer(ItemStack stack) {
if (enabled && this.inventory != null) { this.setStack(stack);
this.inventory.markDirty(); }
}
}
@Override @Override
public ItemStack takeStack(int amount) { public void markDirty() {
return enabled && this.inventory != null ? this.inventory.removeStack(this.index, amount) : ItemStack.EMPTY; if (enabled && this.inventory != null) {
} this.inventory.markDirty();
}
}
@Override @Override
public int getMaxItemCount() { public ItemStack takeStack(int amount) {
return enabled && this.inventory != null ? this.inventory.getMaxCountPerStack() : 0; 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() { public int getX() {
return this.realX; return this.realX;