Files
2019-02-24 22:29:41 +08:00

157 lines
7.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java
+++ ../src-work/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java
@@ -116,6 +116,7 @@
RenderHelper.disableStandardItemLighting();
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
RenderHelper.enableGUIStandardItemLighting();
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, mouseX, mouseY));
InventoryPlayer inventoryplayer = this.mc.player.inventory;
ItemStack itemstack = this.draggedStack.isEmpty() ? inventoryplayer.getItemStack() : this.draggedStack;
@@ -180,8 +181,10 @@
GlStateManager.translate(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
this.itemRender.zLevel = 200.0F;
+ net.minecraft.client.gui.FontRenderer font = stack.getItem().getFontRenderer(stack);
+ if (font == null) font = fontRenderer;
this.itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- this.itemRender.renderItemOverlayIntoGUI(this.fontRenderer, stack, x, y - (this.draggedStack.isEmpty() ? 0 : 8), altText);
+ this.itemRender.renderItemOverlayIntoGUI(font, stack, x, y - (this.draggedStack.isEmpty() ? 0 : 8), altText);
this.zLevel = 0.0F;
this.itemRender.zLevel = 0.0F;
}
@@ -239,13 +242,12 @@
if (itemstack.isEmpty() && slotIn.isEnabled())
{
- String s1 = slotIn.getSlotTexture();
+ TextureAtlasSprite textureatlassprite = slotIn.getBackgroundSprite();
- if (s1 != null)
+ if (textureatlassprite != null)
{
- TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite(s1);
GlStateManager.disableLighting();
- this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
+ this.mc.getTextureManager().bindTexture(slotIn.getBackgroundLocation());
this.drawTexturedModalRect(i, j, textureatlassprite, 16, 16);
GlStateManager.enableLighting();
flag1 = true;
@@ -319,7 +321,7 @@
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
- boolean flag = mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100;
+ boolean flag = this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100);
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
long i = Minecraft.getSystemTime();
this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == mouseButton;
@@ -330,6 +332,7 @@
int j = this.guiLeft;
int k = this.guiTop;
boolean flag1 = this.hasClickedOutside(mouseX, mouseY, j, k);
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int l = -1;
if (slot != null)
@@ -367,7 +370,7 @@
{
if (this.mc.player.inventory.getItemStack().isEmpty())
{
- if (mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
+ if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100))
{
this.handleMouseClick(slot, l, mouseButton, ClickType.CLONE);
}
@@ -405,7 +408,7 @@
{
this.dragSplittingLimit = 1;
}
- else if (mouseButton == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
+ else if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100))
{
this.dragSplittingLimit = 2;
}
@@ -472,10 +475,12 @@
protected void mouseReleased(int mouseX, int mouseY, int state)
{
+ super.mouseReleased(mouseX, mouseY, state); //Forge, Call parent to release buttons
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
int i = this.guiLeft;
int j = this.guiTop;
boolean flag = this.hasClickedOutside(mouseX, mouseY, i, j);
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int k = -1;
if (slot != null)
@@ -496,7 +501,7 @@
{
for (Slot slot2 : this.inventorySlots.inventorySlots)
{
- if (slot2 != null && slot2.canTakeStack(this.mc.player) && slot2.getHasStack() && slot2.inventory == slot.inventory && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true))
+ if (slot2 != null && slot2.canTakeStack(this.mc.player) && slot2.getHasStack() && slot2.isSameInventory(slot) && Container.canAddItemToSlot(slot2, this.shiftClickedSlot, true))
{
this.handleMouseClick(slot2, slot2.slotNumber, state, ClickType.QUICK_MOVE);
}
@@ -583,7 +588,7 @@
}
else if (!this.mc.player.inventory.getItemStack().isEmpty())
{
- if (state == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
+ if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(state - 100))
{
this.handleMouseClick(slot, k, state, ClickType.CLONE);
}
@@ -635,7 +640,7 @@
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
- if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
+ if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
{
this.mc.player.closeScreen();
}
@@ -644,11 +649,11 @@
if (this.hoveredSlot != null && this.hoveredSlot.getHasStack())
{
- if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
+ if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, 0, ClickType.CLONE);
}
- else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
+ else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
}
@@ -661,7 +666,7 @@
{
for (int i = 0; i < 9; ++i)
{
- if (keyCode == this.mc.gameSettings.keyBindsHotbar[i].getKeyCode())
+ if (this.mc.gameSettings.keyBindsHotbar[i].isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.hoveredSlot, this.hoveredSlot.slotNumber, i, ClickType.SWAP);
return true;
@@ -694,4 +699,18 @@
this.mc.player.closeScreen();
}
}
+
+ /* ======================================== FORGE START =====================================*/
+
+ /**
+ * Returns the slot that is currently displayed under the mouse.
+ */
+ @javax.annotation.Nullable
+ public Slot getSlotUnderMouse() { return this.hoveredSlot; }
+ public int getGuiLeft() { return guiLeft; }
+ public int getGuiTop() { return guiTop; }
+ public int getXSize() { return xSize; }
+ public int getYSize() { return ySize; }
+
+ /* ======================================== FORGE END =====================================*/
}