diff --git a/build/build.properties b/build/build.properties index 792514b..9abbab6 100644 --- a/build/build.properties +++ b/build/build.properties @@ -1,4 +1,4 @@ mc_version=1.7.10 forge_version=10.13.3.1373-1.7.10 -ccl_version=1.1.3.136 -mod_version=1.0.6 +ccl_version=1.1.3.138 +mod_version=1.0.7 diff --git a/src/codechicken/core/asm/CodeChickenCoreModContainer.java b/src/codechicken/core/asm/CodeChickenCoreModContainer.java index f4d8bd4..0701df8 100644 --- a/src/codechicken/core/asm/CodeChickenCoreModContainer.java +++ b/src/codechicken/core/asm/CodeChickenCoreModContainer.java @@ -39,7 +39,7 @@ public class CodeChickenCoreModContainer extends DummyModContainer LinkedList deps = new LinkedList(); if(!getVersion().contains("$")) { deps.add(VersionParser.parseVersionReference("Forge@[10.13.3,)")); - deps.add(VersionParser.parseVersionReference("NotEnoughItems@[1.0.3,)")); + deps.add(VersionParser.parseVersionReference("NotEnoughItems@[1.0.5,)")); deps.add(VersionParser.parseVersionReference("EnderStorage@[1.4.7,)")); deps.add(VersionParser.parseVersionReference("ChickenChunks@[1.3.4,)")); deps.add(VersionParser.parseVersionReference("Translocator@[1.1.1,)")); diff --git a/src/codechicken/core/inventory/ContainerExtended.java b/src/codechicken/core/inventory/ContainerExtended.java deleted file mode 100644 index 6500520..0000000 --- a/src/codechicken/core/inventory/ContainerExtended.java +++ /dev/null @@ -1,235 +0,0 @@ -package codechicken.core.inventory; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import codechicken.lib.packet.PacketCustom; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.inventory.Slot; - -public abstract class ContainerExtended extends Container implements ICrafting -{ - public LinkedList playerCrafters = new LinkedList(); - - public ContainerExtended() { - crafters.add(this); - } - - @Override - public void addCraftingToCrafters(ICrafting icrafting) { - if (icrafting instanceof EntityPlayerMP) { - playerCrafters.add((EntityPlayerMP) icrafting); - sendContainerAndContentsToPlayer(this, getInventory(), Arrays.asList((EntityPlayerMP) icrafting)); - detectAndSendChanges(); - } else - super.addCraftingToCrafters(icrafting); - } - - @Override - public void removeCraftingFromCrafters(ICrafting icrafting) { - if (icrafting instanceof EntityPlayerMP) - playerCrafters.remove(icrafting); - else - super.removeCraftingFromCrafters(icrafting); - } - - @Override - public void sendContainerAndContentsToPlayer(Container container, List list) { - sendContainerAndContentsToPlayer(container, list, playerCrafters); - } - - public void sendContainerAndContentsToPlayer(Container container, List list, List playerCrafters) { - LinkedList largeStacks = new LinkedList(); - for (int i = 0; i < list.size(); i++) { - ItemStack stack = list.get(i); - if (stack != null && stack.stackSize > Byte.MAX_VALUE) { - list.set(i, null); - largeStacks.add(stack); - } else - largeStacks.add(null); - } - - for (EntityPlayerMP player : playerCrafters) - player.sendContainerAndContentsToPlayer(container, list); - - for (int i = 0; i < largeStacks.size(); i++) { - ItemStack stack = largeStacks.get(i); - if (stack != null) - sendLargeStack(stack, i, playerCrafters); - } - } - - public void sendLargeStack(ItemStack stack, int slot, List players) { - } - - @Override - public void sendProgressBarUpdate(Container container, int i, int j) { - for (EntityPlayerMP player : playerCrafters) - player.sendProgressBarUpdate(container, i, j); - } - - @Override - public void sendSlotContents(Container container, int slot, ItemStack stack) { - if (stack != null && stack.stackSize > Byte.MAX_VALUE) - sendLargeStack(stack, slot, playerCrafters); - else - for (EntityPlayerMP player : playerCrafters) - player.sendSlotContents(container, slot, stack); - } - - @Override - public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer player) { - if (par1 >= 0 && par1 < inventorySlots.size()) { - Slot slot = getSlot(par1); - if (slot instanceof SlotHandleClicks) - return ((SlotHandleClicks) slot).slotClick(this, player, par2, par3); - } - return super.slotClick(par1, par2, par3, player); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) { - ItemStack transferredStack = null; - Slot slot = (Slot) inventorySlots.get(slotIndex); - - if (slot != null && slot.getHasStack()) { - ItemStack stack = slot.getStack(); - transferredStack = stack.copy(); - - if (!doMergeStackAreas(slotIndex, stack)) - return null; - - if (stack.stackSize == 0) - slot.putStack(null); - else - slot.onSlotChanged(); - } - - return transferredStack; - } - - @Override - public boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverse) { - boolean merged = false; - int slotIndex = reverse ? endIndex - 1 : startIndex; - - if (stack == null) - return false; - - if (stack.isStackable())//search for stacks to increase - { - while (stack.stackSize > 0 && (reverse ? slotIndex >= startIndex : slotIndex < endIndex)) { - Slot slot = (Slot) inventorySlots.get(slotIndex); - ItemStack slotStack = slot.getStack(); - - if (slotStack != null && slotStack.getItem() == stack.getItem() && - (!stack.getHasSubtypes() || stack.getItemDamage() == slotStack.getItemDamage()) && - ItemStack.areItemStackTagsEqual(stack, slotStack)) { - int totalStackSize = slotStack.stackSize + stack.stackSize; - int maxStackSize = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit()); - if (totalStackSize <= maxStackSize) { - stack.stackSize = 0; - slotStack.stackSize = totalStackSize; - slot.onSlotChanged(); - merged = true; - } else if (slotStack.stackSize < maxStackSize) { - stack.stackSize -= maxStackSize - slotStack.stackSize; - slotStack.stackSize = maxStackSize; - slot.onSlotChanged(); - merged = true; - } - } - - slotIndex += reverse ? -1 : 1; - } - } - - if (stack.stackSize > 0)//normal transfer :) - { - slotIndex = reverse ? endIndex - 1 : startIndex; - - while (stack.stackSize > 0 && (reverse ? slotIndex >= startIndex : slotIndex < endIndex)) { - Slot slot = (Slot) this.inventorySlots.get(slotIndex); - - if (!slot.getHasStack() && slot.isItemValid(stack)) { - int maxStackSize = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit()); - if (stack.stackSize <= maxStackSize) { - slot.putStack(stack.copy()); - slot.onSlotChanged(); - stack.stackSize = 0; - merged = true; - } else { - slot.putStack(stack.splitStack(maxStackSize)); - slot.onSlotChanged(); - merged = true; - } - } - - slotIndex += reverse ? -1 : 1; - } - } - - return merged; - } - - /** - * Called when slotIndex is shift clicked on. Recommended implementation is to call mergeItemStack based on slotIndex - * - * @param stack The stack in the clicked slot - * @return True if one or more items were moved from this slots into other slots - */ - public boolean doMergeStackAreas(int slotIndex, ItemStack stack) { - return false; - } - - protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { - bindPlayerInventory(inventoryPlayer, 8, 84); - } - - protected void bindPlayerInventory(InventoryPlayer inventoryPlayer, int x, int y) { - for (int row = 0; row < 3; row++) - for (int col = 0; col < 9; col++) - addSlotToContainer(new Slot(inventoryPlayer, col + row * 9 + 9, x + col * 18, y + row * 18)); - for (int slot = 0; slot < 9; slot++) - addSlotToContainer(new Slot(inventoryPlayer, slot, x + slot * 18, y + 58)); - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return true; - } - - public void sendContainerPacket(PacketCustom packet) { - for (EntityPlayerMP player : playerCrafters) - packet.sendToPlayer(player); - } - - /** - * May be called from a client packet handler to handle additional info - */ - public void handleOutputPacket(PacketCustom packet) { - } - - /** - * May be called from a server packet handler to handle additional info - */ - public void handleInputPacket(PacketCustom packet) { - } - - /** - * May be called from a server packet handler to handle client input - */ - public void handleGuiChange(int ID, int value) { - } - - public void sendProgressBarUpdate(int barID, int value) { - for (ICrafting crafting : (List) crafters) - crafting.sendProgressBarUpdate(this, barID, value); - } -} diff --git a/src/codechicken/core/inventory/ContainerSynchronised.java b/src/codechicken/core/inventory/ContainerSynchronised.java deleted file mode 100644 index b1f64fa..0000000 --- a/src/codechicken/core/inventory/ContainerSynchronised.java +++ /dev/null @@ -1,69 +0,0 @@ -package codechicken.core.inventory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; - -import codechicken.lib.packet.PacketCustom; - -public abstract class ContainerSynchronised extends ContainerExtended -{ - private ArrayList syncVars = new ArrayList(); - - public abstract PacketCustom createSyncPacket(); - - @Override - public final void detectAndSendChanges() - { - super.detectAndSendChanges(); - - for(int i = 0; i < syncVars.size(); i++) - { - IContainerSyncVar var = syncVars.get(i); - if(var.changed()) - { - PacketCustom packet = createSyncPacket(); - packet.writeByte(i); - var.writeChange(packet); - sendContainerPacket(packet); - var.reset(); - } - } - } - - @Override - public void sendContainerAndContentsToPlayer(Container container, List list, List playerCrafters) - { - super.sendContainerAndContentsToPlayer(container, list, playerCrafters); - for(int i = 0; i < syncVars.size(); i++) - { - IContainerSyncVar var = syncVars.get(i); - PacketCustom packet = createSyncPacket(); - packet.writeByte(i); - var.writeChange(packet); - var.reset(); - for(EntityPlayerMP player : playerCrafters) - packet.sendToPlayer(player); - } - } - - public void addSyncVar(IContainerSyncVar var) - { - syncVars.add(var); - } - - @Override - public final void handleOutputPacket(PacketCustom packet) - { - syncVars.get(packet.readUByte()).readChange(packet); - } - - public List getSyncedVars() - { - return Collections.unmodifiableList(syncVars); - } -} diff --git a/src/codechicken/core/inventory/IContainerSyncVar.java b/src/codechicken/core/inventory/IContainerSyncVar.java deleted file mode 100644 index 040a443..0000000 --- a/src/codechicken/core/inventory/IContainerSyncVar.java +++ /dev/null @@ -1,14 +0,0 @@ -package codechicken.core.inventory; - -import codechicken.lib.packet.PacketCustom; - -public interface IContainerSyncVar -{ - public boolean changed(); - - public void reset(); - - public void writeChange(PacketCustom packet); - - public void readChange(PacketCustom packet); -} diff --git a/src/codechicken/core/inventory/IntegerSync.java b/src/codechicken/core/inventory/IntegerSync.java deleted file mode 100644 index 8e54113..0000000 --- a/src/codechicken/core/inventory/IntegerSync.java +++ /dev/null @@ -1,34 +0,0 @@ -package codechicken.core.inventory; - -import codechicken.lib.packet.PacketCustom; - -public abstract class IntegerSync implements IContainerSyncVar -{ - public int c_value; - - @Override - public boolean changed() - { - return getValue() != c_value; - } - - @Override - public void reset() - { - c_value = getValue(); - } - - @Override - public void writeChange(PacketCustom packet) - { - packet.writeInt(getValue()); - } - - @Override - public void readChange(PacketCustom packet) - { - c_value = packet.readInt(); - } - - public abstract int getValue(); -} diff --git a/src/codechicken/core/inventory/MappedInventoryAccess.java b/src/codechicken/core/inventory/MappedInventoryAccess.java deleted file mode 100644 index e4c9fd8..0000000 --- a/src/codechicken/core/inventory/MappedInventoryAccess.java +++ /dev/null @@ -1,122 +0,0 @@ -package codechicken.core.inventory; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class MappedInventoryAccess implements IInventory -{ - public static interface InventoryAccessor - { - public boolean canAccessSlot(int slot); - } - - public static final InventoryAccessor fullAccess = new InventoryAccessor() - { - public boolean canAccessSlot(int slot) { - return true; - } - }; - - private ArrayList slotMap = new ArrayList(); - private IInventory inv; - private ArrayList accessors = new ArrayList(); - - public MappedInventoryAccess(IInventory inv, InventoryAccessor... accessors) { - this.inv = inv; - - for (InventoryAccessor a : accessors) - this.accessors.add(a); - - reset(); - } - - public void reset() { - slotMap.clear(); - nextslot: - for (int i = 0; i < inv.getSizeInventory(); i++) { - for (InventoryAccessor a : accessors) - if (!a.canAccessSlot(i)) - continue nextslot; - - slotMap.add(i); - } - } - - @Override - public int getSizeInventory() { - return slotMap.size(); - } - - @Override - public ItemStack getStackInSlot(int slot) { - return inv.getStackInSlot(slotMap.get(slot)); - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - return inv.decrStackSize(slotMap.get(slot), amount); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return inv.getStackInSlotOnClosing(slotMap.get(slot)); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - inv.setInventorySlotContents(slotMap.get(slot), stack); - } - - @Override - public String getInventoryName() { - return inv.getInventoryName(); - } - - @Override - public int getInventoryStackLimit() { - return inv.getInventoryStackLimit(); - } - - @Override - public void markDirty() { - inv.markDirty(); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return inv.isUseableByPlayer(player); - } - - @Override - public void openInventory() { - inv.openInventory(); - } - - @Override - public void closeInventory() { - inv.closeInventory(); - } - - public void addAccessor(InventoryAccessor accessor) { - accessors.add(accessor); - reset(); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - return inv.isItemValidForSlot(slotMap.get(slot), stack); - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - public List accessors() { - return accessors; - } -} diff --git a/src/codechicken/core/inventory/SlotDummy.java b/src/codechicken/core/inventory/SlotDummy.java deleted file mode 100644 index bc5e837..0000000 --- a/src/codechicken/core/inventory/SlotDummy.java +++ /dev/null @@ -1,73 +0,0 @@ -package codechicken.core.inventory; - -import codechicken.lib.inventory.InventoryUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotDummy extends SlotHandleClicks -{ - public final int stackLimit; - public SlotDummy(IInventory inv, int slot, int x, int y) - { - this(inv, slot, x, y, 64); - } - - public SlotDummy(IInventory inv, int slot, int x, int y, int limit) - { - super(inv, slot, x, y); - stackLimit = limit; - } - - @Override - public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, int modifier) - { - ItemStack held = player.inventory.getItemStack(); - boolean shift = modifier == 1; - slotClick(held, button, shift); - return null; - } - - public void slotClick(ItemStack held, int button, boolean shift) - { - ItemStack tstack = getStack(); - if(held != null && (tstack == null || !InventoryUtils.canStack(held, tstack))) - { - int quantity = Math.min(held.stackSize, stackLimit); - if(shift) - quantity = Math.min(stackLimit, held.getMaxStackSize()*16); - if(button == 1) - quantity = 1; - putStack(InventoryUtils.copyStack(held, quantity)); - } - else if(tstack != null) - { - int inc; - if(held != null) - { - inc = button == 1 ? -held.stackSize : held.stackSize; - if(shift) - inc *= 16; - } - else - { - inc = button == 1 ? -1 : 1; - if(shift) - inc *= 16; - } - int quantity = tstack.stackSize+inc; - if(quantity <= 0) - putStack(null); - else - putStack(InventoryUtils.copyStack(tstack, quantity)); - } - } - - @Override - public void putStack(ItemStack stack) - { - if(stack != null && stack.stackSize > stackLimit) - stack = InventoryUtils.copyStack(stack, stackLimit); - super.putStack(stack); - } -} diff --git a/src/codechicken/core/inventory/SlotDummyOutput.java b/src/codechicken/core/inventory/SlotDummyOutput.java deleted file mode 100644 index 2204cea..0000000 --- a/src/codechicken/core/inventory/SlotDummyOutput.java +++ /dev/null @@ -1,19 +0,0 @@ -package codechicken.core.inventory; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotDummyOutput extends SlotHandleClicks -{ - public SlotDummyOutput(IInventory inv, int slot, int x, int y) - { - super(inv, slot, x, y); - } - - @Override - public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, int modifier) - { - return null; - } -} diff --git a/src/codechicken/core/inventory/SlotHandleClicks.java b/src/codechicken/core/inventory/SlotHandleClicks.java deleted file mode 100644 index b628a26..0000000 --- a/src/codechicken/core/inventory/SlotHandleClicks.java +++ /dev/null @@ -1,16 +0,0 @@ -package codechicken.core.inventory; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public abstract class SlotHandleClicks extends Slot -{ - public SlotHandleClicks(IInventory inv, int slot, int x, int y) - { - super(inv, slot, x, y); - } - - public abstract ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, int modifier); -}