Fix potential shading issue in GuiEditArrayEntries. Closes #3247

This commit is contained in:
LexManos 2016-09-12 14:48:55 -07:00
parent 45097fed0c
commit b879cc9b73
2 changed files with 19 additions and 16 deletions

View File

@ -64,7 +64,7 @@
+ if (this.capabilities != null) + if (this.capabilities != null)
+ { + {
+ NBTTagCompound cnbt = this.capabilities.serializeNBT(); + NBTTagCompound cnbt = this.capabilities.serializeNBT();
+ if (!cnbt.func_82582_d()) p_77955_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT()); + if (!cnbt.func_82582_d()) p_77955_1_.func_74782_a("ForgeCaps", cnbt);
+ } + }
+ +
return p_77955_1_; return p_77955_1_;

View File

@ -43,7 +43,6 @@ import static net.minecraftforge.fml.client.config.GuiUtils.VALID;
public class GuiEditArrayEntries extends GuiListExtended public class GuiEditArrayEntries extends GuiListExtended
{ {
protected GuiEditArray owningGui; protected GuiEditArray owningGui;
public Minecraft mc;
public IConfigElement configElement; public IConfigElement configElement;
public List<IArrayEntry> listEntries; public List<IArrayEntry> listEntries;
public boolean isDefault; public boolean isDefault;
@ -57,7 +56,6 @@ public class GuiEditArrayEntries extends GuiListExtended
{ {
super(mc, parent.width, parent.height, parent.titleLine2 != null ? (parent.titleLine3 != null ? 43 : 33) : 23, parent.height - 32, 20); super(mc, parent.width, parent.height, parent.titleLine2 != null ? (parent.titleLine3 != null ? 43 : 33) : 23, parent.height - 32, 20);
this.owningGui = parent; this.owningGui = parent;
this.mc = mc;
this.configElement = configElement; this.configElement = configElement;
this.beforeValues = beforeValues; this.beforeValues = beforeValues;
this.currentValues = currentValues; this.currentValues = currentValues;
@ -281,6 +279,11 @@ public class GuiEditArrayEntries extends GuiListExtended
entry.drawToolTip(mouseX, mouseY); entry.drawToolTip(mouseX, mouseY);
} }
public Minecraft getMC()
{
return this.mc;
}
/** /**
* IGuiListEntry Inner Classes * IGuiListEntry Inner Classes
*/ */
@ -405,7 +408,7 @@ public class GuiEditArrayEntries extends GuiListExtended
public StringEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, Object value) public StringEntry(GuiEditArray owningScreen, GuiEditArrayEntries owningEntryList, IConfigElement configElement, Object value)
{ {
super(owningScreen, owningEntryList, configElement); super(owningScreen, owningEntryList, configElement);
this.textFieldValue = new GuiTextField(0, owningEntryList.mc.fontRendererObj, owningEntryList.width / 4 + 1, 0, owningEntryList.controlWidth - 3, 16); this.textFieldValue = new GuiTextField(0, owningEntryList.getMC().fontRendererObj, owningEntryList.width / 4 + 1, 0, owningEntryList.controlWidth - 3, 16);
this.textFieldValue.setMaxStringLength(10000); this.textFieldValue.setMaxStringLength(10000);
this.textFieldValue.setText(value.toString()); this.textFieldValue.setText(value.toString());
this.isValidated = configElement.getValidationPattern() != null; this.isValidated = configElement.getValidationPattern() != null;
@ -499,15 +502,15 @@ public class GuiEditArrayEntries extends GuiListExtended
this.btnValue.displayString = String.valueOf(value); this.btnValue.displayString = String.valueOf(value);
btnValue.packedFGColour = value ? GuiUtils.getColorCode('2', true) : GuiUtils.getColorCode('4', true); btnValue.packedFGColour = value ? GuiUtils.getColorCode('2', true) : GuiUtils.getColorCode('4', true);
this.btnValue.drawButton(owningEntryList.mc, mouseX, mouseY); this.btnValue.drawButton(owningEntryList.getMC(), mouseX, mouseY);
} }
@Override @Override
public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY) public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY)
{ {
if (this.btnValue.mousePressed(owningEntryList.mc, x, y)) if (this.btnValue.mousePressed(owningEntryList.getMC(), x, y))
{ {
btnValue.playPressSound(owningEntryList.mc.getSoundHandler()); btnValue.playPressSound(owningEntryList.getMC().getSoundHandler());
value = !value; value = !value;
owningEntryList.recalculateState(); owningEntryList.recalculateState();
return true; return true;
@ -566,10 +569,10 @@ public class GuiEditArrayEntries extends GuiListExtended
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
{ {
if (this.getValue() != null && this.isValidated) if (this.getValue() != null && this.isValidated)
owningEntryList.mc.fontRendererObj.drawString( owningEntryList.getMC().fontRendererObj.drawString(
isValidValue ? TextFormatting.GREEN + VALID : TextFormatting.RED + INVALID, isValidValue ? TextFormatting.GREEN + VALID : TextFormatting.RED + INVALID,
listWidth / 4 - owningEntryList.mc.fontRendererObj.getStringWidth(VALID) - 2, listWidth / 4 - owningEntryList.getMC().fontRendererObj.getStringWidth(VALID) - 2,
y + slotHeight / 2 - owningEntryList.mc.fontRendererObj.FONT_HEIGHT / 2, y + slotHeight / 2 - owningEntryList.getMC().fontRendererObj.FONT_HEIGHT / 2,
16777215); 16777215);
int half = listWidth / 2; int half = listWidth / 2;
@ -578,7 +581,7 @@ public class GuiEditArrayEntries extends GuiListExtended
this.btnAddNewEntryAbove.visible = true; this.btnAddNewEntryAbove.visible = true;
this.btnAddNewEntryAbove.xPosition = half + ((half / 2) - 44); this.btnAddNewEntryAbove.xPosition = half + ((half / 2) - 44);
this.btnAddNewEntryAbove.yPosition = y; this.btnAddNewEntryAbove.yPosition = y;
this.btnAddNewEntryAbove.drawButton(owningEntryList.mc, mouseX, mouseY); this.btnAddNewEntryAbove.drawButton(owningEntryList.getMC(), mouseX, mouseY);
} }
else else
this.btnAddNewEntryAbove.visible = false; this.btnAddNewEntryAbove.visible = false;
@ -588,7 +591,7 @@ public class GuiEditArrayEntries extends GuiListExtended
this.btnRemoveEntry.visible = true; this.btnRemoveEntry.visible = true;
this.btnRemoveEntry.xPosition = half + ((half / 2) - 22); this.btnRemoveEntry.xPosition = half + ((half / 2) - 22);
this.btnRemoveEntry.yPosition = y; this.btnRemoveEntry.yPosition = y;
this.btnRemoveEntry.drawButton(owningEntryList.mc, mouseX, mouseY); this.btnRemoveEntry.drawButton(owningEntryList.getMC(), mouseX, mouseY);
} }
else else
this.btnRemoveEntry.visible = false; this.btnRemoveEntry.visible = false;
@ -607,16 +610,16 @@ public class GuiEditArrayEntries extends GuiListExtended
@Override @Override
public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY) public boolean mousePressed(int index, int x, int y, int mouseEvent, int relativeX, int relativeY)
{ {
if (this.btnAddNewEntryAbove.mousePressed(owningEntryList.mc, x, y)) if (this.btnAddNewEntryAbove.mousePressed(owningEntryList.getMC(), x, y))
{ {
btnAddNewEntryAbove.playPressSound(owningEntryList.mc.getSoundHandler()); btnAddNewEntryAbove.playPressSound(owningEntryList.getMC().getSoundHandler());
owningEntryList.addNewEntry(index); owningEntryList.addNewEntry(index);
owningEntryList.recalculateState(); owningEntryList.recalculateState();
return true; return true;
} }
else if (this.btnRemoveEntry.mousePressed(owningEntryList.mc, x, y)) else if (this.btnRemoveEntry.mousePressed(owningEntryList.getMC(), x, y))
{ {
btnRemoveEntry.playPressSound(owningEntryList.mc.getSoundHandler()); btnRemoveEntry.playPressSound(owningEntryList.getMC().getSoundHandler());
owningEntryList.removeEntry(index); owningEntryList.removeEntry(index);
owningEntryList.recalculateState(); owningEntryList.recalculateState();
return true; return true;