ForgePatch/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch

187 lines
11 KiB
Diff
Raw Normal View History

2018-11-22 05:23:24 +00:00
--- a/net/minecraft/client/gui/inventory/GuiContainer.java
+++ b/net/minecraft/client/gui/inventory/GuiContainer.java
@@ -7,7 +7,6 @@
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
-import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
@@ -68,6 +67,7 @@
int i = this.field_147003_i;
int j = this.field_147009_r;
this.func_146976_a(p_73863_3_, p_73863_1_, p_73863_2_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, p_73863_1_, p_73863_2_));
GlStateManager.func_179101_C();
RenderHelper.func_74518_a();
GlStateManager.func_179140_f();
@@ -97,7 +97,8 @@
int j1 = slot.field_75223_e;
int k1 = slot.field_75221_f;
GlStateManager.func_179135_a(true, true, true, false);
- this.func_73733_a(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
+ int slotColor = this.getSlotColor(i1);
+ this.func_73733_a(j1, k1, j1 + 16, k1 + 16, slotColor, slotColor);
GlStateManager.func_179135_a(true, true, true, true);
GlStateManager.func_179145_e();
GlStateManager.func_179126_j();
@@ -107,6 +108,7 @@
2018-11-22 05:23:24 +00:00
RenderHelper.func_74518_a();
this.func_146979_b(p_73863_1_, p_73863_2_);
RenderHelper.func_74520_c();
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, p_73863_1_, p_73863_2_));
InventoryPlayer inventoryplayer = this.field_146297_k.field_71439_g.field_71071_by;
ItemStack itemstack = this.field_147012_x.func_190926_b() ? inventoryplayer.func_70445_o() : this.field_147012_x;
if (!itemstack.func_190926_b()) {
@@ -158,8 +160,10 @@
2018-11-22 05:23:24 +00:00
GlStateManager.func_179109_b(0.0F, 0.0F, 32.0F);
this.field_73735_i = 200.0F;
this.field_146296_j.field_77023_b = 200.0F;
+ net.minecraft.client.gui.FontRenderer font = p_146982_1_.func_77973_b().getFontRenderer(p_146982_1_);
+ if (font == null) font = field_146289_q;
this.field_146296_j.func_180450_b(p_146982_1_, p_146982_2_, p_146982_3_);
- this.field_146296_j.func_180453_a(this.field_146289_q, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_);
+ this.field_146296_j.func_180453_a(font, p_146982_1_, p_146982_2_, p_146982_3_ - (this.field_147012_x.func_190926_b() ? 0 : 8), p_146982_4_);
this.field_73735_i = 0.0F;
this.field_146296_j.field_77023_b = 0.0F;
}
@@ -203,11 +207,10 @@
2018-11-22 05:23:24 +00:00
this.field_73735_i = 100.0F;
this.field_146296_j.field_77023_b = 100.0F;
if (itemstack.func_190926_b() && p_146977_1_.func_111238_b()) {
- String s1 = p_146977_1_.func_178171_c();
- if (s1 != null) {
- TextureAtlasSprite textureatlassprite = this.field_146297_k.func_147117_R().func_110572_b(s1);
+ TextureAtlasSprite textureatlassprite = p_146977_1_.getBackgroundSprite();
+ if (textureatlassprite != null) {
GlStateManager.func_179140_f();
- this.field_146297_k.func_110434_K().func_110577_a(TextureMap.field_110575_b);
+ this.field_146297_k.func_110434_K().func_110577_a(p_146977_1_.getBackgroundLocation());
this.func_175175_a(i, j, textureatlassprite, 16, 16);
GlStateManager.func_179145_e();
flag1 = true;
@@ -268,7 +271,8 @@
2018-11-22 05:23:24 +00:00
if (super.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_)) {
return true;
} else {
- boolean flag = this.field_146297_k.field_71474_y.field_74322_I.func_197984_a(p_mouseClicked_5_);
+ InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_mouseClicked_5_);
+ boolean flag = this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey);
Slot slot = this.func_195360_a(p_mouseClicked_1_, p_mouseClicked_3_);
long i = Util.func_211177_b();
this.field_146993_M = this.field_146998_K == slot && i - this.field_146997_J < 250L && this.field_146992_L == p_mouseClicked_5_;
@@ -277,6 +281,7 @@
2018-11-22 05:23:24 +00:00
int j = this.field_147003_i;
int k = this.field_147009_r;
boolean flag1 = this.func_195361_a(p_mouseClicked_1_, p_mouseClicked_3_, j, k, p_mouseClicked_5_);
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int l = -1;
if (slot != null) {
l = slot.field_75222_d;
@@ -302,7 +307,7 @@
2018-11-22 05:23:24 +00:00
}
} else if (!this.field_147007_t) {
if (this.field_146297_k.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) {
- if (this.field_146297_k.field_71474_y.field_74322_I.func_197984_a(p_mouseClicked_5_)) {
+ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
this.func_184098_a(slot, l, p_mouseClicked_5_, ClickType.CLONE);
} else {
boolean flag2 = l != -999 && (InputMappings.func_197956_a(340) || InputMappings.func_197956_a(344));
@@ -326,7 +331,7 @@
2018-11-22 05:23:24 +00:00
this.field_146987_F = 0;
} else if (p_mouseClicked_5_ == 1) {
this.field_146987_F = 1;
- } else if (this.field_146297_k.field_71474_y.field_74322_I.func_197984_a(p_mouseClicked_5_)) {
+ } else if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
this.field_146987_F = 2;
}
}
@@ -379,10 +384,13 @@
2018-11-22 05:23:24 +00:00
}
public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
+ super.mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_); //Forge, Call parent to release buttons
Slot slot = this.func_195360_a(p_mouseReleased_1_, p_mouseReleased_3_);
int i = this.field_147003_i;
int j = this.field_147009_r;
boolean flag = this.func_195361_a(p_mouseReleased_1_, p_mouseReleased_3_, i, j, p_mouseReleased_5_);
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
+ InputMappings.Input mouseKey = InputMappings.Type.MOUSE.func_197944_a(p_mouseReleased_5_);
int k = -1;
if (slot != null) {
k = slot.field_75222_d;
@@ -396,7 +404,7 @@
2018-11-22 05:23:24 +00:00
if (func_146272_n()) {
if (!this.field_146994_N.func_190926_b()) {
for(Slot slot2 : this.field_147002_h.field_75151_b) {
- if (slot2 != null && slot2.func_82869_a(this.field_146297_k.field_71439_g) && slot2.func_75216_d() && slot2.field_75224_c == slot.field_75224_c && Container.func_94527_a(slot2, this.field_146994_N, true)) {
+ if (slot2 != null && slot2.func_82869_a(this.field_146297_k.field_71439_g) && slot2.func_75216_d() && slot2.isSameInventory(slot) && Container.func_94527_a(slot2, this.field_146994_N, true)) {
this.func_184098_a(slot2, slot2.field_75222_d, p_mouseReleased_5_, ClickType.QUICK_MOVE);
}
}
@@ -460,7 +468,7 @@
2018-11-22 05:23:24 +00:00
this.func_184098_a((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), ClickType.QUICK_CRAFT);
} else if (!this.field_146297_k.field_71439_g.field_71071_by.func_70445_o().func_190926_b()) {
- if (this.field_146297_k.field_71474_y.field_74322_I.func_197984_a(p_mouseReleased_5_)) {
+ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(mouseKey)) {
this.func_184098_a(slot, k, p_mouseReleased_5_, ClickType.CLONE);
} else {
boolean flag1 = k != -999 && (InputMappings.func_197956_a(340) || InputMappings.func_197956_a(344));
@@ -509,27 +517,31 @@
2018-11-22 05:23:24 +00:00
if (super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
return true;
} else {
- if (p_keyPressed_1_ == 256 || this.field_146297_k.field_71474_y.field_151445_Q.func_197976_a(p_keyPressed_1_, p_keyPressed_2_)) {
+ if (p_keyPressed_1_ == 256 || this.field_146297_k.field_71474_y.field_151445_Q.isActiveAndMatches(InputMappings.func_197954_a(p_keyPressed_1_, p_keyPressed_2_))) {
this.field_146297_k.field_71439_g.func_71053_j();
+ return true; // Forge MC-146650: Needs to return true when the key is handled.
2018-11-22 05:23:24 +00:00
}
- this.func_195363_d(p_keyPressed_1_, p_keyPressed_2_);
+ if (this.func_195363_d(p_keyPressed_1_, p_keyPressed_2_))
+ return true; // Forge MC-146650: Needs to return true when the key is handled.
2018-11-22 05:23:24 +00:00
if (this.field_147006_u != null && this.field_147006_u.func_75216_d()) {
- if (this.field_146297_k.field_71474_y.field_74322_I.func_197976_a(p_keyPressed_1_, p_keyPressed_2_)) {
+ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(InputMappings.func_197954_a(p_keyPressed_1_, p_keyPressed_2_))) {
this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 0, ClickType.CLONE);
- } else if (this.field_146297_k.field_71474_y.field_74316_C.func_197976_a(p_keyPressed_1_, p_keyPressed_2_)) {
+ return true; // Forge MC-146650: Needs to return true when the key is handled.
2018-11-22 05:23:24 +00:00
+ } else if (this.field_146297_k.field_71474_y.field_74316_C.isActiveAndMatches(InputMappings.func_197954_a(p_keyPressed_1_, p_keyPressed_2_))) {
this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, func_146271_m() ? 1 : 0, ClickType.THROW);
+ return true; // Forge MC-146650: Needs to return true when the key is handled.
2018-11-22 05:23:24 +00:00
}
}
- return true;
+ return false; // Forge MC-146650: Needs to return false when the key is not handled.
}
}
2018-11-22 05:23:24 +00:00
protected boolean func_195363_d(int p_195363_1_, int p_195363_2_) {
if (this.field_146297_k.field_71439_g.field_71071_by.func_70445_o().func_190926_b() && this.field_147006_u != null) {
for(int i = 0; i < 9; ++i) {
- if (this.field_146297_k.field_71474_y.field_151456_ac[i].func_197976_a(p_195363_1_, p_195363_2_)) {
+ if (this.field_146297_k.field_71474_y.field_151456_ac[i].isActiveAndMatches(InputMappings.func_197954_a(p_195363_1_, p_195363_2_))) {
this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, i, ClickType.SWAP);
return true;
}
@@ -556,4 +568,16 @@
2018-11-22 05:23:24 +00:00
}
}
+
+ @javax.annotation.Nullable
+ public Slot getSlotUnderMouse() { return this.field_147006_u; }
+ public int getGuiLeft() { return field_147003_i; }
+ public int getGuiTop() { return field_147009_r; }
+ public int getXSize() { return field_146999_f; }
+ public int getYSize() { return field_147000_g; }
+
+ public int slotColor = -2130706433;
+ public int getSlotColor(int index) {
+ return slotColor;
+ }
2018-11-22 05:23:24 +00:00
}