Slots and drawing now positioned based on inventory slot positions
This commit is contained in:
parent
e622b3d9bb
commit
f2bd540675
6 changed files with 274 additions and 230 deletions
|
@ -5,12 +5,11 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
|
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback;
|
import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback;
|
||||||
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.ShulkerBoxScreen;
|
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
|
||||||
|
@ -120,30 +119,39 @@ public class ScoutClient implements ClientModInitializer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handledScreenAccessor = (HandledScreenAccessor) handledScreen;
|
var handledScreenAccessor = (HandledScreenAccessor<?>) handledScreen;
|
||||||
|
ScreenHandler handler = handledScreenAccessor.getHandler();
|
||||||
|
|
||||||
var sx = handledScreenAccessor.getX();
|
var playerInventory = client.player.getInventory();
|
||||||
var sy = handledScreenAccessor.getY();
|
|
||||||
var sw = handledScreenAccessor.getBackgroundWidth();
|
int x = 0;
|
||||||
var sh = handledScreenAccessor.getBackgroundHeight();
|
int y = 0;
|
||||||
|
|
||||||
// satchel
|
// satchel
|
||||||
int x = sx;
|
var _hotbarSlot1 = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 0).findFirst();
|
||||||
int y = sy + sh + 2;
|
Slot hotbarSlot1 = _hotbarSlot1.isPresent() ? _hotbarSlot1.get() : null;
|
||||||
|
if (hotbarSlot1 != null) {
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
if (!hotbarSlot1.isEnabled()) {
|
||||||
y -= 1;
|
for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
|
||||||
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.SATCHEL_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
|
if (slot != null) {
|
||||||
|
slot.setX(Integer.MAX_VALUE);
|
||||||
|
slot.setY(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
x = hotbarSlot1.x;
|
||||||
|
y = hotbarSlot1.y + 27;
|
||||||
|
|
||||||
for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
|
for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
|
||||||
if (i % 9 == 0) {
|
if (i % 9 == 0) {
|
||||||
x = sx + 8;
|
x = hotbarSlot1.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.SATCHEL_SLOT_START - i, client.player.playerScreenHandler);
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.SATCHEL_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
slot.setX(x - sx);
|
slot.setX(x);
|
||||||
slot.setY(y - sy);
|
slot.setY(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 18;
|
x += 18;
|
||||||
|
@ -152,14 +160,24 @@ public class ScoutClient implements ClientModInitializer {
|
||||||
y += 18;
|
y += 18;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// left pouch
|
// left pouch
|
||||||
x = sx + 8;
|
var _topLeftSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 9).findFirst();
|
||||||
y = (sy + sh) - 100;
|
Slot topLeftSlot = _topLeftSlot.isPresent() ? _topLeftSlot.get() : null;
|
||||||
|
if (topLeftSlot != null) {
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
if (!topLeftSlot.isEnabled()) {
|
||||||
y -= 1;
|
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
||||||
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.LEFT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
|
if (slot != null) {
|
||||||
|
slot.setX(Integer.MAX_VALUE);
|
||||||
|
slot.setY(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
x = topLeftSlot.x;
|
||||||
|
y = topLeftSlot.y - 18;
|
||||||
|
|
||||||
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
||||||
if (i % 3 == 0) {
|
if (i % 3 == 0) {
|
||||||
|
@ -169,20 +187,30 @@ public class ScoutClient implements ClientModInitializer {
|
||||||
|
|
||||||
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.LEFT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.LEFT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
slot.setX(x - sx);
|
slot.setX(x);
|
||||||
slot.setY(y - sy);
|
slot.setY(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
y -= 18;
|
y -= 18;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// right pouch
|
// right pouch
|
||||||
x = sx + sw - 24;
|
var _topRightSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 17).findFirst();
|
||||||
y = (sy + sh) - 100;
|
Slot topRightSlot = _topRightSlot.isPresent() ? _topRightSlot.get() : null;
|
||||||
|
if (topRightSlot != null) {
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
if (!topLeftSlot.isEnabled()) {
|
||||||
y -= 1;
|
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
||||||
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.RIGHT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
|
if (slot != null) {
|
||||||
|
slot.setX(Integer.MAX_VALUE);
|
||||||
|
slot.setY(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
x = topRightSlot.x;
|
||||||
|
y = topRightSlot.y - 18;
|
||||||
|
|
||||||
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
|
||||||
if (i % 3 == 0) {
|
if (i % 3 == 0) {
|
||||||
|
@ -192,13 +220,15 @@ public class ScoutClient implements ClientModInitializer {
|
||||||
|
|
||||||
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.RIGHT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.RIGHT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
slot.setX(x - sx);
|
slot.setX(x);
|
||||||
slot.setY(y - sy);
|
slot.setY(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
y -= 18;
|
y -= 18;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ingame.BeaconScreen;
|
|
||||||
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
|
||||||
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
|
|
||||||
import net.minecraft.screen.PlayerScreenHandler;
|
import net.minecraft.screen.PlayerScreenHandler;
|
||||||
|
|
||||||
public class ScoutUtilClient {
|
public class ScoutUtilClient {
|
||||||
|
@ -21,8 +19,6 @@ public class ScoutUtilClient {
|
||||||
|
|
||||||
// FIXME: registry system for mods to register their own blacklisted screens
|
// FIXME: registry system for mods to register their own blacklisted screens
|
||||||
public static boolean isScreenBlacklisted(Screen screen) {
|
public static boolean isScreenBlacklisted(Screen screen) {
|
||||||
return screen instanceof CreativeInventoryScreen
|
return screen instanceof CreativeInventoryScreen;
|
||||||
|| screen instanceof MerchantScreen // FIXME: needs repositioning
|
|
||||||
|| screen instanceof BeaconScreen; // FIXME: needs repositioning
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ import dev.emi.emi.api.EmiPlugin;
|
||||||
import dev.emi.emi.api.EmiRegistry;
|
import dev.emi.emi.api.EmiRegistry;
|
||||||
import dev.emi.emi.api.widget.Bounds;
|
import dev.emi.emi.api.widget.Bounds;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
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.ShulkerBoxScreen;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
import net.minecraft.screen.slot.Slot;
|
||||||
import pm.c7.scout.ScoutUtil;
|
import pm.c7.scout.ScoutUtil;
|
||||||
import pm.c7.scout.client.ScoutUtilClient;
|
import pm.c7.scout.client.ScoutUtilClient;
|
||||||
import pm.c7.scout.item.BaseBagItem;
|
import pm.c7.scout.item.BaseBagItem;
|
||||||
|
@ -23,31 +23,35 @@ public class ScoutEmiPlugin implements EmiPlugin {
|
||||||
|
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
var handledScreenAccessor = (HandledScreenAccessor) handledScreen;
|
var handledScreenAccessor = (HandledScreenAccessor<?>) handledScreen;
|
||||||
|
ScreenHandler handler = handledScreenAccessor.getHandler();
|
||||||
var sx = handledScreenAccessor.getX();
|
var sx = handledScreenAccessor.getX();
|
||||||
var sy = handledScreenAccessor.getY();
|
var sy = handledScreenAccessor.getY();
|
||||||
var sw = handledScreenAccessor.getBackgroundWidth();
|
var sw = handledScreenAccessor.getBackgroundWidth();
|
||||||
var sh = handledScreenAccessor.getBackgroundHeight();
|
var sh = handledScreenAccessor.getBackgroundHeight();
|
||||||
|
|
||||||
|
var playerInventory = client.player.getInventory();
|
||||||
|
|
||||||
ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
|
ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
|
||||||
if (!satchelStack.isEmpty()) {
|
if (!satchelStack.isEmpty()) {
|
||||||
BaseBagItem bagItem = (BaseBagItem) satchelStack.getItem();
|
BaseBagItem bagItem = (BaseBagItem) satchelStack.getItem();
|
||||||
int slots = bagItem.getSlotCount();
|
int slots = bagItem.getSlotCount();
|
||||||
int rows = (int) Math.ceil(slots / 9);
|
int rows = (int) Math.ceil(slots / 9);
|
||||||
|
|
||||||
int x = sx;
|
var _hotbarSlot1 = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 0).findFirst();
|
||||||
int y = sy + sh;
|
Slot hotbarSlot1 = _hotbarSlot1.isPresent() ? _hotbarSlot1.get() : null;
|
||||||
|
if (hotbarSlot1 != null) {
|
||||||
|
if (hotbarSlot1.isEnabled()) {
|
||||||
|
int x = sx + hotbarSlot1.x - 8;
|
||||||
|
int y = sy + hotbarSlot1.y + 22;
|
||||||
|
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
int w = 176;
|
||||||
y -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = sw;
|
|
||||||
int h = (rows * 18) + 8;
|
int h = (rows * 18) + 8;
|
||||||
|
|
||||||
consumer.accept(new Bounds(x, y, w, h));
|
consumer.accept(new Bounds(x, y, w, h));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
|
ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
|
||||||
if (!leftPouchStack.isEmpty()) {
|
if (!leftPouchStack.isEmpty()) {
|
||||||
|
@ -55,18 +59,20 @@ public class ScoutEmiPlugin implements EmiPlugin {
|
||||||
int slots = bagItem.getSlotCount();
|
int slots = bagItem.getSlotCount();
|
||||||
int columns = (int) Math.ceil(slots / 3);
|
int columns = (int) Math.ceil(slots / 3);
|
||||||
|
|
||||||
int x = sx - (columns * 18);
|
var _topLeftSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 9).findFirst();
|
||||||
int y = (sy + sh) - 100;
|
Slot topLeftSlot = _topLeftSlot.isPresent() ? _topLeftSlot.get() : null;
|
||||||
|
if (topLeftSlot != null) {
|
||||||
|
if (topLeftSlot.isEnabled()) {
|
||||||
|
int x = sx + topLeftSlot.x - 7 - (columns * 18);
|
||||||
|
int y = sy + topLeftSlot.y;
|
||||||
|
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
int w = (columns * 18) + 7;
|
||||||
y -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = (columns * 18);
|
|
||||||
int h = 68;
|
int h = 68;
|
||||||
|
|
||||||
consumer.accept(new Bounds(x, y, w, h));
|
consumer.accept(new Bounds(x, y, w, h));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
|
ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
|
||||||
if (!rightPouchStack.isEmpty()) {
|
if (!rightPouchStack.isEmpty()) {
|
||||||
|
@ -74,18 +80,20 @@ public class ScoutEmiPlugin implements EmiPlugin {
|
||||||
int slots = bagItem.getSlotCount();
|
int slots = bagItem.getSlotCount();
|
||||||
int columns = (int) Math.ceil(slots / 3);
|
int columns = (int) Math.ceil(slots / 3);
|
||||||
|
|
||||||
int x = sx + sw;
|
var _topRightSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 17).findFirst();
|
||||||
int y = (sy + sh) - 100;
|
Slot topRightSlot = _topRightSlot.isPresent() ? _topRightSlot.get() : null;
|
||||||
|
if (topRightSlot != null) {
|
||||||
|
if (topRightSlot.isEnabled()) {
|
||||||
|
int x = sx + topRightSlot.x;
|
||||||
|
int y = sy + topRightSlot.y;
|
||||||
|
|
||||||
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
|
int w = (columns * 18) + 7;
|
||||||
y -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = (columns * 18);
|
|
||||||
int h = 68;
|
int h = 68;
|
||||||
|
|
||||||
consumer.accept(new Bounds(x, y, w, h));
|
consumer.accept(new Bounds(x, y, w, h));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.screen.slot.SlotActionType;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spongepowered.asm.mixin.Dynamic;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -45,6 +46,7 @@ public abstract class ScreenHandlerMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Dynamic("Workaround for Debugify. Other calls are modified via the attached transformer class.")
|
||||||
@Redirect(method = "internalOnSlotClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/DefaultedList;get(I)Ljava/lang/Object;", ordinal = 5))
|
@Redirect(method = "internalOnSlotClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/collection/DefaultedList;get(I)Ljava/lang/Object;", ordinal = 5))
|
||||||
public Object scout$fixSlotIndexing(DefaultedList<Slot> self, int index, int slotIndex, int button, SlotActionType actionType, PlayerEntity player) {
|
public Object scout$fixSlotIndexing(DefaultedList<Slot> self, int index, int slotIndex, int button, SlotActionType actionType, PlayerEntity player) {
|
||||||
if (ScoutUtil.isBagSlot(index)) {
|
if (ScoutUtil.isBagSlot(index)) {
|
||||||
|
|
|
@ -3,12 +3,14 @@ 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.gui.screen.ingame.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
@Mixin(HandledScreen.class)
|
@Mixin(HandledScreen.class)
|
||||||
public interface HandledScreenAccessor {
|
public interface HandledScreenAccessor<T extends ScreenHandler> {
|
||||||
@Accessor("x")
|
@Accessor("x")
|
||||||
int getX();
|
int getX();
|
||||||
@Accessor("y")
|
@Accessor("y")
|
||||||
|
@ -17,4 +19,6 @@ public interface HandledScreenAccessor {
|
||||||
int getBackgroundWidth();
|
int getBackgroundWidth();
|
||||||
@Accessor("backgroundHeight")
|
@Accessor("backgroundHeight")
|
||||||
int getBackgroundHeight();
|
int getBackgroundHeight();
|
||||||
|
@Accessor("handler")
|
||||||
|
T getHandler();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,8 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
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.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.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;
|
||||||
|
@ -43,24 +41,27 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
protected int backgroundWidth;
|
protected int backgroundWidth;
|
||||||
@Shadow
|
@Shadow
|
||||||
protected int backgroundHeight;
|
protected int backgroundHeight;
|
||||||
|
@Shadow
|
||||||
|
protected T handler;
|
||||||
|
|
||||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V"))
|
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawBackground(Lnet/minecraft/client/gui/DrawContext;FII)V"))
|
||||||
private void scout$drawSatchelRow(DrawContext graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
private void scout$drawSatchelRow(DrawContext graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||||
if (this.client != null && this.client.player != null && !ScoutUtilClient.isScreenBlacklisted(this)) {
|
if (this.client != null && this.client.player != null && !ScoutUtilClient.isScreenBlacklisted(this)) {
|
||||||
|
var playerInventory = this.client.player.getInventory();
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
var _hotbarSlot1 = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 0).findFirst();
|
||||||
|
Slot hotbarSlot1 = _hotbarSlot1.isPresent() ? _hotbarSlot1.get() : null;
|
||||||
|
if (hotbarSlot1 != null) {
|
||||||
|
int x = this.x + hotbarSlot1.x - 8;
|
||||||
|
int y = this.y + hotbarSlot1.y + 22;
|
||||||
|
|
||||||
graphics.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;
|
|
||||||
|
|
||||||
if ((Object) this instanceof GenericContainerScreen || (Object) this instanceof ShulkerBoxScreen) {
|
|
||||||
y -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 32, 176, 4);
|
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 32, 176, 4);
|
||||||
y += 4;
|
y += 4;
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
|
|
||||||
for (int slot = 0; slot < slots; slot++) {
|
for (int slot = 0; slot < slots; slot++) {
|
||||||
if (slot % 9 == 0) {
|
if (slot % 9 == 0) {
|
||||||
x = this.x;
|
x = this.x + hotbarSlot1.x - 8;
|
||||||
u = 0;
|
u = 0;
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 7, 18);
|
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, u, v, 7, 18);
|
||||||
x += 7;
|
x += 7;
|
||||||
|
@ -87,29 +88,31 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x = this.x;
|
x = this.x + hotbarSlot1.x - 8;
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, 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);
|
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", remap = false))
|
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;disableDepthTest()V", remap = false))
|
||||||
private void scout$drawPouchSlots(DrawContext graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
private void scout$drawPouchSlots(DrawContext graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||||
if (this.client != null && this.client.player != null && !ScoutUtilClient.isScreenBlacklisted(this)) {
|
if (this.client != null && this.client.player != null && !ScoutUtilClient.isScreenBlacklisted(this)) {
|
||||||
|
var playerInventory = this.client.player.getInventory();
|
||||||
|
|
||||||
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()) {
|
||||||
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
|
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
|
||||||
int slots = bagItem.getSlotCount();
|
int slots = bagItem.getSlotCount();
|
||||||
int columns = (int) Math.ceil(slots / 3);
|
int columns = (int) Math.ceil(slots / 3);
|
||||||
|
|
||||||
int x = this.x;
|
var _topLeftSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 9).findFirst();
|
||||||
int y = (this.y + this.backgroundHeight) - 29;
|
Slot topLeftSlot = _topLeftSlot.isPresent() ? _topLeftSlot.get() : null;
|
||||||
|
if (topLeftSlot != null) {
|
||||||
if ((Object) this instanceof GenericContainerScreen || (Object) this instanceof ShulkerBoxScreen) {
|
int x = this.x + topLeftSlot.x - 8;
|
||||||
y -= 1;
|
int y = this.y + topLeftSlot.y + 53;
|
||||||
}
|
|
||||||
|
|
||||||
graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
@ -127,7 +130,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
x -= 7;
|
x -= 7;
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 25, 7, 7);
|
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 25, 7, 7);
|
||||||
|
|
||||||
x = this.x + 7;
|
x = this.x + topLeftSlot.x - 1;
|
||||||
y -= 54;
|
y -= 54;
|
||||||
for (int slot = 0; slot < slots; slot++) {
|
for (int slot = 0; slot < slots; slot++) {
|
||||||
if (slot % 3 == 0) {
|
if (slot % 3 == 0) {
|
||||||
|
@ -145,7 +148,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 7, 7, 18);
|
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 0, 7, 7, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = this.x;
|
x = this.x + topLeftSlot.x - 8;
|
||||||
y -= 7;
|
y -= 7;
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, 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++) {
|
||||||
|
@ -163,6 +166,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
|
|
||||||
graphics.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);
|
||||||
if (!rightPouchStack.isEmpty()) {
|
if (!rightPouchStack.isEmpty()) {
|
||||||
|
@ -170,12 +174,11 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
int slots = bagItem.getSlotCount();
|
int slots = bagItem.getSlotCount();
|
||||||
int columns = (int) Math.ceil(slots / 3);
|
int columns = (int) Math.ceil(slots / 3);
|
||||||
|
|
||||||
int x = this.x + this.backgroundWidth - 7;
|
var _topRightSlot = handler.slots.stream().filter(slot->slot.inventory.equals(playerInventory) && slot.getIndex() == 17).findFirst();
|
||||||
int y = (this.y + this.backgroundHeight) - 29;
|
Slot topRightSlot = _topRightSlot.isPresent() ? _topRightSlot.get() : null;
|
||||||
|
if (topRightSlot != null) {
|
||||||
if ((Object) this instanceof GenericContainerScreen || (Object) this instanceof ShulkerBoxScreen) {
|
int x = this.x + topRightSlot.x + 17;
|
||||||
y -= 1;
|
int y = this.y + topRightSlot.y + 53;
|
||||||
}
|
|
||||||
|
|
||||||
graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
graphics.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
@ -193,7 +196,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
}
|
}
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, 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 + topRightSlot.x - 1;
|
||||||
y -= 54;
|
y -= 54;
|
||||||
for (int slot = 0; slot < slots; slot++) {
|
for (int slot = 0; slot < slots; slot++) {
|
||||||
if (slot % 3 == 0) {
|
if (slot % 3 == 0) {
|
||||||
|
@ -211,7 +214,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, 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 + topRightSlot.x + 17;
|
||||||
y -= 7;
|
y -= 7;
|
||||||
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 25, 0, 7, 7);
|
graphics.drawTexture(ScoutUtil.SLOT_TEXTURE, x, y, 25, 0, 7, 7);
|
||||||
x += 7;
|
x += 7;
|
||||||
|
@ -231,6 +234,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "isClickOutsideBounds", at = @At("TAIL"), cancellable = true)
|
@Inject(method = "isClickOutsideBounds", at = @At("TAIL"), cancellable = true)
|
||||||
private void scout$adjustOutsideBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable<Boolean> callbackInfo) {
|
private void scout$adjustOutsideBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable<Boolean> callbackInfo) {
|
||||||
|
|
Loading…
Reference in a new issue