diff options
author | DoKM <54663875+DoKM@users.noreply.github.com> | 2021-09-26 21:02:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 21:02:13 +0200 |
commit | 4ce3332d0cacdfa6b621d5b60f4f8e9251a9fd40 (patch) | |
tree | 3471e063d9c1d55147cd5da20c3fc21b802153e8 | |
parent | 369027f8c0b6eec54dafb2428653c5f8147f4aaa (diff) | |
parent | 8450813a942016f4ce866490f4a4503158372f24 (diff) | |
download | NotEnoughUpdates-4ce3332d0cacdfa6b621d5b60f4f8e9251a9fd40.tar.gz NotEnoughUpdates-4ce3332d0cacdfa6b621d5b60f4f8e9251a9fd40.tar.bz2 NotEnoughUpdates-4ce3332d0cacdfa6b621d5b60f4f8e9251a9fd40.zip |
Merge pull request #36 from DeDiamondPro/master
better pv command block
3 files changed, 16 insertions, 16 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 9cb63a67..09fa865f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -27,12 +27,9 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -1428,8 +1425,8 @@ public class NEUEventListener { GuiChest eventGui = (GuiChest) guiScreen; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); - if(containerName.contains(" Profile") && eventGui.isMouseOverSlot(cc.inventorySlots.get(42), mouseX, mouseY) - && Mouse.getEventButton() >= 0) { + if(containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 && + eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && Mouse.getEventButton() >= 0) { event.setCanceled(true); if(Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null && eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null){ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java index 65ccd73f..bc92df0e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java @@ -57,6 +57,8 @@ public class BetterContainers { public static HashMap<Integer, ItemStack> itemCache = new HashMap<>(); + public static int profileViewerStackIndex = -1; + public static void clickSlot(int slot) { clickedSlotMillis = System.currentTimeMillis(); clickedSlot = slot; @@ -121,9 +123,7 @@ public class BetterContainers { } public static boolean isBlankStack(int index, ItemStack stack) { - if(index == 42 && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && - (SBInfo.getInstance().lastOpenContainerName.contains("'s Profile") || - SBInfo.getInstance().lastOpenContainerName.contains("s' Profile"))) { + if(index != -1 && index == profileViewerStackIndex) { return false; } @@ -137,9 +137,7 @@ public class BetterContainers { } public static boolean isButtonStack(int index, ItemStack stack) { - if(index == 42 && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && - (SBInfo.getInstance().lastOpenContainerName.contains("'s Profile") || - SBInfo.getInstance().lastOpenContainerName.contains("s' Profile"))) { + if(index == profileViewerStackIndex) { return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index 89d97dfa..db72f903 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -54,8 +54,10 @@ public abstract class MixinGuiContainer extends GuiScreen { GuiContainer $this = (GuiContainer)(Object)this; - if(slot.slotNumber == 42 && $this instanceof GuiChest) { - hasProfileViewerStack = false; + if(!hasProfileViewerStack && $this instanceof GuiChest && slot.getSlotIndex() > 9 && (slot.getSlotIndex() % 9 == 6 || slot.getSlotIndex() % 9 == 7) && + BetterContainers.isBlankStack(-1, slot.getStack())) { + BetterContainers.profileViewerStackIndex = -1; + hasProfileViewerStack = true; GuiChest eventGui = (GuiChest) $this; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; @@ -80,12 +82,15 @@ public abstract class MixinGuiContainer extends GuiScreen { this.itemRender.zLevel = 0.0F; this.zLevel = 0.0F; - hasProfileViewerStack = true; + BetterContainers.profileViewerStackIndex = slot.getSlotIndex(); } } } } - } + } else if (slot.getSlotIndex() == 0) + hasProfileViewerStack = false; + else if(!($this instanceof GuiChest)) + BetterContainers.profileViewerStackIndex = -1; if(slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) { GlStateManager.pushMatrix(); @@ -117,7 +122,7 @@ public abstract class MixinGuiContainer extends GuiScreen { value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;renderToolTip(Lnet/minecraft/item/ItemStack;II)V")) public void drawScreen_renderTooltip(GuiContainer guiContainer, ItemStack stack, int x, int y) { - if(hasProfileViewerStack && theSlot.slotNumber == 42) { + if(theSlot.slotNumber == BetterContainers.profileViewerStackIndex) { this.renderToolTip(profileViewerStack, x, y); } else { this.renderToolTip(stack, x, y); |