mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 02:54:27 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -90,16 +90,16 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
super.initGui();
|
||||
this.mc.thePlayer.openContainer = this.inventorySlots;
|
||||
if (this.gui != null) {
|
||||
guiLeft = (this.width - this.xSize)/2;
|
||||
guiTop = (this.height - this.ySize)/2;
|
||||
guiLeft = (this.width - this.xSize) / 2;
|
||||
guiTop = (this.height - this.ySize) / 2;
|
||||
this.components.clear();
|
||||
this.clickListeners.clear();
|
||||
this.keyListeners.clear();
|
||||
this.dataHolders.clear();
|
||||
Iterator var1 = this.gui.getComponents().iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
ICustomGuiComponent c = (ICustomGuiComponent)var1.next();
|
||||
while (var1.hasNext()) {
|
||||
ICustomGuiComponent c = (ICustomGuiComponent) var1.next();
|
||||
this.addComponent(c);
|
||||
}
|
||||
}
|
||||
@@ -111,15 +111,14 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
Iterator var1 = this.dataHolders.iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
IDataHolder component = (IDataHolder)var1.next();
|
||||
while (var1.hasNext()) {
|
||||
IDataHolder component = (IDataHolder) var1.next();
|
||||
if (component instanceof GuiTextField) {
|
||||
((GuiTextField)component).updateCursorCounter();
|
||||
((GuiTextField) component).updateCursorCounter();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead)
|
||||
{
|
||||
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
@@ -133,12 +132,12 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
Iterator var4 = this.components.values().iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
while (var4.hasNext()) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
IGuiComponent component = (IGuiComponent)var4.next();
|
||||
IGuiComponent component = (IGuiComponent) var4.next();
|
||||
component.onRender(this.mc, mouseX, mouseY, Mouse.getDWheel(), partialTicks);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@@ -153,8 +152,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
drawScreenSuper(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public void drawScreenSuper(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
public void drawScreenSuper(int mouseX, int mouseY, float partialTicks) {
|
||||
//this.drawDefaultBackground();
|
||||
int k = this.guiLeft;
|
||||
int l = this.guiTop;
|
||||
@@ -166,23 +164,21 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)k, (float)l, 0.0F);
|
||||
GL11.glTranslatef((float) k, (float) l, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
this.theSlot = null;
|
||||
short short1 = 240;
|
||||
short short2 = 240;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F, (float) short2 / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int k1;
|
||||
|
||||
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1)
|
||||
{
|
||||
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
|
||||
for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i1);
|
||||
this.drawSlot(slot);
|
||||
|
||||
if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b())
|
||||
{
|
||||
if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.func_111238_b()) {
|
||||
this.theSlot = slot;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
@@ -204,24 +200,19 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
|
||||
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
byte b0 = 8;
|
||||
k1 = this.draggedStack == null ? 8 : 16;
|
||||
String s = null;
|
||||
|
||||
if (this.draggedStack != null && this.isRightMouseClick)
|
||||
{
|
||||
if (this.draggedStack != null && this.isRightMouseClick) {
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F);
|
||||
}
|
||||
else if (this.field_147007_t && this.field_147008_s.size() > 1)
|
||||
{
|
||||
itemstack.stackSize = MathHelper.ceiling_float_int((float) itemstack.stackSize / 2.0F);
|
||||
} else if (this.field_147007_t && this.field_147008_s.size() > 1) {
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize = this.field_146996_I;
|
||||
|
||||
if (itemstack.stackSize == 0)
|
||||
{
|
||||
if (itemstack.stackSize == 0) {
|
||||
s = "" + EnumChatFormatting.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
@@ -229,27 +220,24 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
this.drawItemStack(itemstack, mouseX - k - b0, mouseY - l - k1, s);
|
||||
}
|
||||
|
||||
if (this.returningStack != null)
|
||||
{
|
||||
float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
|
||||
if (this.returningStack != null) {
|
||||
float f1 = (float) (Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
|
||||
|
||||
if (f1 >= 1.0F)
|
||||
{
|
||||
if (f1 >= 1.0F) {
|
||||
f1 = 1.0F;
|
||||
this.returningStack = null;
|
||||
}
|
||||
|
||||
k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y;
|
||||
int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z;
|
||||
int l1 = this.field_147011_y + (int)((float)k1 * f1);
|
||||
int i2 = this.field_147010_z + (int)((float)j2 * f1);
|
||||
this.drawItemStack(this.returningStack, l1, i2, (String)null);
|
||||
int l1 = this.field_147011_y + (int) ((float) k1 * f1);
|
||||
int i2 = this.field_147010_z + (int) ((float) j2 * f1);
|
||||
this.drawItemStack(this.returningStack, l1, i2, (String) null);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
{
|
||||
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack()) {
|
||||
ItemStack itemstack1 = this.theSlot.getStack();
|
||||
this.renderToolTip(itemstack1, mouseX, mouseY);
|
||||
}
|
||||
@@ -259,8 +247,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
|
||||
private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_)
|
||||
{
|
||||
private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_) {
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
this.zLevel = 200.0F;
|
||||
itemRender.zLevel = 200.0F;
|
||||
@@ -273,13 +260,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
private boolean isMouseOverSlot(Slot slot, int posX, int posY)
|
||||
{
|
||||
private boolean isMouseOverSlot(Slot slot, int posX, int posY) {
|
||||
return this.isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, posX, posY);
|
||||
}
|
||||
|
||||
protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY)
|
||||
{
|
||||
protected boolean isPointInRegion(int slotDisplayX, int slotDisplayY, int slotSizeX, int slotSizeY, int posX, int posY) {
|
||||
int k1 = this.guiLeft;
|
||||
int l1 = this.guiTop;
|
||||
posX -= k1;
|
||||
@@ -287,8 +272,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
return posX >= slotDisplayX - 1 && posX < slotDisplayX + slotSizeX + 1 && posY >= slotDisplayY - 1 && posY < slotDisplayY + slotSizeY + 1;
|
||||
}
|
||||
|
||||
private void drawSlot(Slot p_146977_1_)
|
||||
{
|
||||
private void drawSlot(Slot p_146977_1_) {
|
||||
int i = p_146977_1_.xDisplayPosition;
|
||||
int j = p_146977_1_.yDisplayPosition;
|
||||
ItemStack itemstack = p_146977_1_.getStack();
|
||||
@@ -297,38 +281,29 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
|
||||
String s = null;
|
||||
|
||||
if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
|
||||
{
|
||||
if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) {
|
||||
itemstack = itemstack.copy();
|
||||
itemstack.stackSize /= 2;
|
||||
}
|
||||
else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null)
|
||||
{
|
||||
if (this.field_147008_s.size() == 1)
|
||||
{
|
||||
} else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null) {
|
||||
if (this.field_147008_s.size() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_))
|
||||
{
|
||||
if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_)) {
|
||||
itemstack = itemstack1.copy();
|
||||
flag = true;
|
||||
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize);
|
||||
|
||||
if (itemstack.stackSize > itemstack.getMaxStackSize())
|
||||
{
|
||||
if (itemstack.stackSize > itemstack.getMaxStackSize()) {
|
||||
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
|
||||
itemstack.stackSize = itemstack.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack.stackSize > p_146977_1_.getSlotStackLimit())
|
||||
{
|
||||
if (itemstack.stackSize > p_146977_1_.getSlotStackLimit()) {
|
||||
s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit();
|
||||
itemstack.stackSize = p_146977_1_.getSlotStackLimit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.field_147008_s.remove(p_146977_1_);
|
||||
this.func_146980_g();
|
||||
}
|
||||
@@ -337,12 +312,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
if (itemstack == null) {
|
||||
IIcon iicon = p_146977_1_.getBackgroundIconIndex();
|
||||
|
||||
if (iicon != null)
|
||||
{
|
||||
if (iicon != null) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND); // Forge: Blending needs to be enabled for this.
|
||||
this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture);
|
||||
@@ -353,10 +326,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
if (!flag1) {
|
||||
if (flag) {
|
||||
drawRect(i, j, i + 16, j + 16, -2130706433);
|
||||
}
|
||||
|
||||
@@ -369,30 +340,25 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
private void func_146980_g()
|
||||
{
|
||||
private void func_146980_g() {
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if (itemstack != null && this.field_147007_t)
|
||||
{
|
||||
if (itemstack != null && this.field_147007_t) {
|
||||
this.field_146996_I = itemstack.stackSize;
|
||||
ItemStack itemstack1;
|
||||
int i;
|
||||
|
||||
for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i)
|
||||
{
|
||||
Slot slot = (Slot)iterator.next();
|
||||
for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i) {
|
||||
Slot slot = (Slot) iterator.next();
|
||||
itemstack1 = itemstack.copy();
|
||||
i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
|
||||
Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i);
|
||||
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize())
|
||||
{
|
||||
if (itemstack1.stackSize > itemstack1.getMaxStackSize()) {
|
||||
itemstack1.stackSize = itemstack1.getMaxStackSize();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize > slot.getSlotStackLimit())
|
||||
{
|
||||
if (itemstack1.stackSize > slot.getSlotStackLimit()) {
|
||||
itemstack1.stackSize = slot.getSlotStackLimit();
|
||||
}
|
||||
}
|
||||
@@ -408,26 +374,26 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
|
||||
private void addComponent(ICustomGuiComponent component) {
|
||||
ScriptGuiComponent c = (ScriptGuiComponent)component;
|
||||
switch(c.getType()) {
|
||||
ScriptGuiComponent c = (ScriptGuiComponent) component;
|
||||
switch (c.getType()) {
|
||||
case 0:
|
||||
CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton)component);
|
||||
CustomGuiButton button = CustomGuiButton.fromComponent((ScriptGuiButton) component);
|
||||
button.setParent(this);
|
||||
this.components.put(button.getID(), button);
|
||||
this.addClickListener(button);
|
||||
break;
|
||||
case 1:
|
||||
CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel)component);
|
||||
CustomGuiLabel lbl = CustomGuiLabel.fromComponent((ScriptGuiLabel) component);
|
||||
lbl.setParent(this);
|
||||
this.components.put(lbl.getID(), lbl);
|
||||
break;
|
||||
case 2:
|
||||
CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect)component);
|
||||
CustomGuiTexturedRect rect = CustomGuiTexturedRect.fromComponent((ScriptGuiTexturedRect) component);
|
||||
rect.setParent(this);
|
||||
this.components.put(rect.getID(), rect);
|
||||
break;
|
||||
case 3:
|
||||
CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField)component);
|
||||
CustomGuiTextField textField = CustomGuiTextField.fromComponent((ScriptGuiTextField) component);
|
||||
textField.setParent(this);
|
||||
this.components.put(textField.getID(), textField);
|
||||
this.addDataHolder(textField);
|
||||
@@ -435,8 +401,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
this.addKeyListener(textField);
|
||||
break;
|
||||
case 4:
|
||||
CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll)component).isMultiSelect());
|
||||
scroll.fromComponent((ScriptGuiScroll)component);
|
||||
CustomGuiScrollComponent scroll = new CustomGuiScrollComponent(this.mc, this, component.getID(), ((ScriptGuiScroll) component).isMultiSelect());
|
||||
scroll.fromComponent((ScriptGuiScroll) component);
|
||||
scroll.setParent(this);
|
||||
this.components.put(scroll.getID(), scroll);
|
||||
this.addDataHolder(scroll);
|
||||
@@ -444,7 +410,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
break;
|
||||
case 6:
|
||||
CustomGuiLine line = CustomGuiLine.fromComponent((ScriptGuiLine) component);
|
||||
this.components.put(line.getID(),line);
|
||||
this.components.put(line.getID(), line);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -460,10 +426,11 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
|
||||
public String prevScrollClicked = null;
|
||||
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false));
|
||||
if(Integer.toString(scroll.selected).equals(prevScrollClicked)){
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true));
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent) scroll), false));
|
||||
if (Integer.toString(scroll.selected).equals(prevScrollClicked)) {
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent) scroll), true));
|
||||
}
|
||||
prevScrollClicked = Integer.toString(scroll.selected);
|
||||
}
|
||||
@@ -473,21 +440,20 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
PacketClient.sendClient(new CustomGuiClosePacket(this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
if (this.mc.thePlayer != null)
|
||||
{
|
||||
if (this.mc.thePlayer != null) {
|
||||
this.inventorySlots.onContainerClosed(this.mc.thePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void onTextFieldUnfocused(CustomGuiTextField textField){
|
||||
public void onTextFieldUnfocused(CustomGuiTextField textField) {
|
||||
PacketClient.sendClient(new CustomGuiUnfocusedPacket(textField.getID(), this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
public ScriptGui updateGui() {
|
||||
Iterator var1 = this.dataHolders.iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
IDataHolder component = (IDataHolder)var1.next();
|
||||
while (var1.hasNext()) {
|
||||
IDataHolder component = (IDataHolder) var1.next();
|
||||
this.gui.updateComponent(component.toComponent());
|
||||
}
|
||||
|
||||
@@ -499,8 +465,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
if (scroll.multiSelect) {
|
||||
Iterator var3 = scroll.getSelectedList().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
String s = (String)var3.next();
|
||||
while (var3.hasNext()) {
|
||||
String s = (String) var3.next();
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
} else {
|
||||
@@ -513,28 +479,23 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
if (keyCode == 1 && closeOnEsc)
|
||||
{
|
||||
if (keyCode == 1 && closeOnEsc) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
|
||||
this.checkHotbarKeys(keyCode);
|
||||
|
||||
if (this.theSlot != null && this.theSlot.getHasStack())
|
||||
{
|
||||
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
|
||||
{
|
||||
if (this.theSlot != null && this.theSlot.getHasStack()) {
|
||||
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode()) {
|
||||
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3);
|
||||
}
|
||||
else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
|
||||
{
|
||||
} else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode()) {
|
||||
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator var3 = this.keyListeners.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
while (var3.hasNext()) {
|
||||
CustomGuiTextField listener = (CustomGuiTextField) var3.next();
|
||||
listener.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
@@ -557,12 +518,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
boolean flag1 = true;
|
||||
int k1 = -1;
|
||||
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
|
||||
{
|
||||
Slot invSlot = (Slot)this.inventorySlots.inventorySlots.get(i);
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) {
|
||||
Slot invSlot = (Slot) this.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if (invSlot.equals(slot))
|
||||
{
|
||||
if (invSlot.equals(slot)) {
|
||||
flag1 = false;
|
||||
}
|
||||
}
|
||||
@@ -629,8 +588,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
Iterator var4 = this.clickListeners.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
IClickListener listener = (IClickListener)var4.next();
|
||||
while (var4.hasNext()) {
|
||||
IClickListener listener = (IClickListener) var4.next();
|
||||
listener.mouseClicked(this, mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@@ -654,8 +613,8 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScriptGui gui = (ScriptGui)(new ScriptGui()).fromNBT(compound);
|
||||
((ContainerCustomGui)this.inventorySlots).setGui(gui, mc.thePlayer);
|
||||
ScriptGui gui = (ScriptGui) (new ScriptGui()).fromNBT(compound);
|
||||
((ContainerCustomGui) this.inventorySlots).setGui(gui, mc.thePlayer);
|
||||
this.gui = gui;
|
||||
this.xSize = gui.getWidth();
|
||||
this.ySize = gui.getHeight();
|
||||
@@ -670,14 +629,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
/**
|
||||
* This function is what controls the hotbar shortcut check when you press a number key when hovering a stack.
|
||||
*/
|
||||
protected boolean checkHotbarKeys(int p_146983_1_)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode())
|
||||
{
|
||||
protected boolean checkHotbarKeys(int p_146983_1_) {
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) {
|
||||
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2);
|
||||
return true;
|
||||
}
|
||||
@@ -687,18 +642,15 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_)
|
||||
{
|
||||
if (slot != null)
|
||||
{
|
||||
protected void handleMouseClick(Slot slot, int index, int p_146984_3_, int p_146984_4_) {
|
||||
if (slot != null) {
|
||||
index = slot.slotNumber;
|
||||
}
|
||||
|
||||
this.mc.playerController.windowClick(this.inventorySlots.windowId, index, p_146984_3_, p_146984_4_, this.mc.thePlayer);
|
||||
}
|
||||
|
||||
protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_)
|
||||
{
|
||||
protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) {
|
||||
super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); //Forge, Call parent to release buttons
|
||||
Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_);
|
||||
int l = this.guiLeft;
|
||||
@@ -706,96 +658,74 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize;
|
||||
int j1 = -1;
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
if (slot != null) {
|
||||
j1 = slot.slotNumber;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
j1 = -999;
|
||||
}
|
||||
|
||||
Slot slot1;
|
||||
Iterator iterator;
|
||||
|
||||
if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot))
|
||||
{
|
||||
if (isShiftKeyDown())
|
||||
{
|
||||
if (slot != null && slot.inventory != null && this.field_146994_N != null)
|
||||
{
|
||||
if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack) null, slot)) {
|
||||
if (isShiftKeyDown()) {
|
||||
if (slot != null && slot.inventory != null && this.field_146994_N != null) {
|
||||
iterator = this.inventorySlots.inventorySlots.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
slot1 = (Slot)iterator.next();
|
||||
while (iterator.hasNext()) {
|
||||
slot1 = (Slot) iterator.next();
|
||||
|
||||
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true))
|
||||
{
|
||||
if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true)) {
|
||||
this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.handleMouseClick(slot, j1, p_146286_3_, 6);
|
||||
}
|
||||
|
||||
this.field_146993_M = false;
|
||||
this.field_146997_J = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.field_147007_t && this.field_146988_G != p_146286_3_)
|
||||
{
|
||||
} else {
|
||||
if (this.field_147007_t && this.field_146988_G != p_146286_3_) {
|
||||
this.field_147007_t = false;
|
||||
this.field_147008_s.clear();
|
||||
this.field_146995_H = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.field_146995_H)
|
||||
{
|
||||
if (this.field_146995_H) {
|
||||
this.field_146995_H = false;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean flag1;
|
||||
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (p_146286_3_ == 0 || p_146286_3_ == 1)
|
||||
{
|
||||
if (this.draggedStack == null && slot != this.clickedSlot)
|
||||
{
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) {
|
||||
if (p_146286_3_ == 0 || p_146286_3_ == 1) {
|
||||
if (this.draggedStack == null && slot != this.clickedSlot) {
|
||||
this.draggedStack = this.clickedSlot.getStack();
|
||||
}
|
||||
|
||||
flag1 = Container.func_94527_a(slot, this.draggedStack, false);
|
||||
|
||||
if (j1 != -1 && this.draggedStack != null && flag1)
|
||||
{
|
||||
if (j1 != -1 && this.draggedStack != null && flag1) {
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
|
||||
this.handleMouseClick(slot, j1, 0, 0);
|
||||
|
||||
if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() != null) {
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0);
|
||||
this.field_147011_y = p_146286_1_ - l;
|
||||
this.field_147010_z = p_146286_2_ - i1;
|
||||
this.returningStackDestSlot = this.clickedSlot;
|
||||
this.returningStack = this.draggedStack;
|
||||
this.returningStackTime = Minecraft.getSystemTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.returningStack = null;
|
||||
}
|
||||
}
|
||||
else if (this.draggedStack != null)
|
||||
{
|
||||
} else if (this.draggedStack != null) {
|
||||
this.field_147011_y = p_146286_1_ - l;
|
||||
this.field_147010_z = p_146286_2_ - i1;
|
||||
this.returningStackDestSlot = this.clickedSlot;
|
||||
@@ -806,32 +736,23 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
this.draggedStack = null;
|
||||
this.clickedSlot = null;
|
||||
}
|
||||
}
|
||||
else if (this.field_147007_t && !this.field_147008_s.isEmpty())
|
||||
{
|
||||
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5);
|
||||
} else if (this.field_147007_t && !this.field_147008_s.isEmpty()) {
|
||||
this.handleMouseClick((Slot) null, -999, Container.func_94534_d(0, this.field_146987_F), 5);
|
||||
iterator = this.field_147008_s.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
slot1 = (Slot)iterator.next();
|
||||
while (iterator.hasNext()) {
|
||||
slot1 = (Slot) iterator.next();
|
||||
this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5);
|
||||
}
|
||||
|
||||
this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5);
|
||||
}
|
||||
else if (this.mc.thePlayer.inventory.getItemStack() != null)
|
||||
{
|
||||
if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
|
||||
{
|
||||
this.handleMouseClick((Slot) null, -999, Container.func_94534_d(2, this.field_146987_F), 5);
|
||||
} else if (this.mc.thePlayer.inventory.getItemStack() != null) {
|
||||
if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) {
|
||||
this.handleMouseClick(slot, j1, p_146286_3_, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (flag1) {
|
||||
this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
}
|
||||
|
||||
@@ -840,22 +761,18 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null)
|
||||
{
|
||||
if (this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
this.field_146997_J = 0L;
|
||||
}
|
||||
|
||||
this.field_147007_t = false;
|
||||
}
|
||||
|
||||
private Slot getSlotAtPosition(int posX, int posY)
|
||||
{
|
||||
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k)
|
||||
{
|
||||
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k);
|
||||
private Slot getSlotAtPosition(int posX, int posY) {
|
||||
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(k);
|
||||
|
||||
if (this.isMouseOverSlot(slot, posX, posY))
|
||||
{
|
||||
if (this.isMouseOverSlot(slot, posX, posY)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
@@ -863,47 +780,34 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_)
|
||||
{
|
||||
protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_) {
|
||||
Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_);
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
|
||||
{
|
||||
if (p_146273_3_ == 0 || p_146273_3_ == 1)
|
||||
{
|
||||
if (this.draggedStack == null)
|
||||
{
|
||||
if (slot != this.clickedSlot)
|
||||
{
|
||||
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) {
|
||||
if (p_146273_3_ == 0 || p_146273_3_ == 1) {
|
||||
if (this.draggedStack == null) {
|
||||
if (slot != this.clickedSlot) {
|
||||
this.draggedStack = this.clickedSlot.getStack().copy();
|
||||
}
|
||||
}
|
||||
else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false))
|
||||
{
|
||||
} else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false)) {
|
||||
long i1 = Minecraft.getSystemTime();
|
||||
|
||||
if (this.field_146985_D == slot)
|
||||
{
|
||||
if (i1 - this.field_146986_E > 500L)
|
||||
{
|
||||
if (this.field_146985_D == slot) {
|
||||
if (i1 - this.field_146986_E > 500L) {
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
|
||||
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
|
||||
this.field_146986_E = i1 + 750L;
|
||||
--this.draggedStack.stackSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.field_146985_D = slot;
|
||||
this.field_146986_E = i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
|
||||
{
|
||||
} else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) {
|
||||
this.field_147008_s.add(slot);
|
||||
this.func_146980_g();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user