change inventory system
This commit is contained in:
parent
6bb1c7c050
commit
9bd1ac3b45
2 changed files with 20 additions and 308 deletions
|
@ -4,7 +4,6 @@ import java.text.DecimalFormat;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
@ -28,7 +27,6 @@ import client.renderer.entity.RenderItem;
|
|||
import client.window.Bind;
|
||||
import client.window.Button;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Sets;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.entity.npc.Attribute;
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
@ -69,13 +67,8 @@ public abstract class GuiContainer extends Gui
|
|||
protected int ySize = 166;
|
||||
public Container inventorySlots;
|
||||
private Slot theSlot;
|
||||
protected final Set<Slot> dragSplittingSlots = Sets.<Slot>newHashSet();
|
||||
protected final List<Overlay> drawnOverlays = Lists.<Overlay>newArrayList();
|
||||
protected boolean dragSplitting;
|
||||
private int dragSplittingLimit;
|
||||
private int dragSplittingButton;
|
||||
private boolean ignoreMouseUp;
|
||||
private int dragSplittingRemnant;
|
||||
private long lastClickTime;
|
||||
private Slot lastClickSlot;
|
||||
private int lastClickButton;
|
||||
|
@ -438,17 +431,7 @@ public abstract class GuiContainer extends Gui
|
|||
int k2 = 8;
|
||||
String s = null;
|
||||
|
||||
if (this.dragSplitting && this.dragSplittingSlots.size() > 1)
|
||||
{
|
||||
stack = stack.copy();
|
||||
stack.setSize(this.dragSplittingRemnant);
|
||||
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
s = "" + Color.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
else if(stack == this.cheatStack) {
|
||||
if(stack == this.cheatStack) {
|
||||
s = Color.DARK_GREEN + "+" + Color.GREEN + formatAmount(stack.getSize());
|
||||
}
|
||||
|
||||
|
@ -542,38 +525,6 @@ public abstract class GuiContainer extends Gui
|
|||
ItemStack itemstack1 = this.gm.player.getMouseItem();
|
||||
String s = null;
|
||||
|
||||
if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
|
||||
{
|
||||
if (this.dragSplittingSlots.size() == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Container.canAddItemToSlot(slotIn, itemstack1, true) && this.inventorySlots.canDragIntoSlot(slotIn))
|
||||
{
|
||||
itemstack = itemstack1.copy();
|
||||
flag = true;
|
||||
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack() == null ? 0 : slotIn.getStack().getSize());
|
||||
|
||||
if (itemstack.getSize() > itemstack.getMaxStackSize())
|
||||
{
|
||||
s = Color.YELLOW + formatAmount(itemstack.getMaxStackSize());
|
||||
itemstack.setSize(itemstack.getMaxStackSize());
|
||||
}
|
||||
|
||||
if (itemstack.getSize() > slotIn.getItemStackLimit(itemstack))
|
||||
{
|
||||
s = Color.YELLOW + formatAmount(slotIn.getItemStackLimit(itemstack));
|
||||
itemstack.setSize(slotIn.getItemStackLimit(itemstack));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dragSplittingSlots.remove(slotIn);
|
||||
this.updateDragSplitting();
|
||||
}
|
||||
}
|
||||
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
|
||||
GlState.enableDepth();
|
||||
|
@ -583,35 +534,6 @@ public abstract class GuiContainer extends Gui
|
|||
this.itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
private void updateDragSplitting()
|
||||
{
|
||||
ItemStack itemstack = this.gm.player.getMouseItem();
|
||||
|
||||
if (itemstack != null && this.dragSplitting)
|
||||
{
|
||||
this.dragSplittingRemnant = itemstack.getSize();
|
||||
|
||||
for (Slot slot : this.dragSplittingSlots)
|
||||
{
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
int i = slot.getStack() == null ? 0 : slot.getStack().getSize();
|
||||
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
|
||||
|
||||
if (itemstack1.getSize() > itemstack1.getMaxStackSize())
|
||||
{
|
||||
itemstack1.setSize(itemstack1.getMaxStackSize());
|
||||
}
|
||||
|
||||
if (itemstack1.getSize() > slot.getItemStackLimit(itemstack1))
|
||||
{
|
||||
itemstack1.setSize(slot.getItemStackLimit(itemstack1));
|
||||
}
|
||||
|
||||
this.dragSplittingRemnant -= itemstack1.getSize() - i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Slot getSlotAtPosition(int x, int y)
|
||||
{
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
|
||||
|
@ -680,43 +602,29 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
if (l != -1)
|
||||
{
|
||||
if (!this.dragSplitting)
|
||||
if (this.gm.player.getMouseItem() == null)
|
||||
{
|
||||
if (this.gm.player.getMouseItem() == null)
|
||||
boolean flag2 = l != -999 && this.gm.shift();
|
||||
int i1 = 0;
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
boolean flag2 = l != -999 && this.gm.shift();
|
||||
int i1 = 0;
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
i1 = 1;
|
||||
}
|
||||
else if (l == -999)
|
||||
{
|
||||
i1 = 4;
|
||||
}
|
||||
|
||||
this.handleMouseClick(slot, l, mouseButton, i1);
|
||||
|
||||
this.ignoreMouseUp = true;
|
||||
this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack() : null;
|
||||
i1 = 1;
|
||||
}
|
||||
else
|
||||
else if (l == -999)
|
||||
{
|
||||
this.dragSplitting = true;
|
||||
this.dragSplittingButton = mouseButton;
|
||||
this.dragSplittingSlots.clear();
|
||||
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
this.dragSplittingLimit = 0;
|
||||
}
|
||||
else if (mouseButton == 1)
|
||||
{
|
||||
this.dragSplittingLimit = 1;
|
||||
}
|
||||
i1 = 4;
|
||||
}
|
||||
|
||||
this.handleMouseClick(slot, l, mouseButton, i1);
|
||||
|
||||
this.ignoreMouseUp = true;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// this.dragSplitting = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,16 +635,6 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
public void mouseDragged(int mouseX, int mouseY)
|
||||
{
|
||||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
ItemStack itemstack = this.gm.player.getMouseItem();
|
||||
|
||||
if (this.dragSplitting && slot != null && itemstack != null && itemstack.getSize() > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
|
||||
{
|
||||
this.dragSplittingSlots.add(slot);
|
||||
this.updateDragSplitting();
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int state)
|
||||
|
@ -782,32 +680,13 @@ public abstract class GuiContainer extends Gui
|
|||
}
|
||||
else
|
||||
{
|
||||
if (this.dragSplitting && this.dragSplittingButton != state)
|
||||
{
|
||||
this.dragSplitting = false;
|
||||
this.dragSplittingSlots.clear();
|
||||
this.ignoreMouseUp = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ignoreMouseUp)
|
||||
{
|
||||
this.ignoreMouseUp = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dragSplitting && !this.dragSplittingSlots.isEmpty())
|
||||
{
|
||||
this.handleMouseClick((Slot)null, -999, Container.getDragCode(0, this.dragSplittingLimit), 5);
|
||||
|
||||
for (Slot slot1 : this.dragSplittingSlots)
|
||||
{
|
||||
this.handleMouseClick(slot1, slot1.slotNumber, Container.getDragCode(1, this.dragSplittingLimit), 5);
|
||||
}
|
||||
|
||||
this.handleMouseClick((Slot)null, -999, Container.getDragCode(2, this.dragSplittingLimit), 5);
|
||||
}
|
||||
else if (this.gm.player.getMouseItem() != null)
|
||||
if (this.gm.player.getMouseItem() != null)
|
||||
{
|
||||
boolean flag1 = k != -999 && this.gm.shift();
|
||||
|
||||
|
@ -824,8 +703,6 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
this.lastClickTime = 0L;
|
||||
}
|
||||
|
||||
this.dragSplitting = false;
|
||||
}
|
||||
|
||||
private boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY)
|
||||
|
@ -987,7 +864,6 @@ public abstract class GuiContainer extends Gui
|
|||
private void setCurrentTab(CheatTab tab)
|
||||
{
|
||||
selectedTab = tab;
|
||||
this.dragSplittingSlots.clear();
|
||||
ITEM_LIST.clear();
|
||||
tab.filter(ITEM_LIST);
|
||||
if(!this.cheatLast.isBlank() && this.gm.player != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue