From abdd27c23592073bf77b740f738406748e58dae1 Mon Sep 17 00:00:00 2001 From: Arthur Uzulin Date: Thu, 26 Sep 2013 15:23:06 +1000 Subject: [PATCH] "Tsuki no me" almost complete Becomes super apparent what project "Tsuki no me" is about --- .../assets/tinker/textures/gui/slotButton.png | Bin 0 -> 11665 bytes src/tconstruct/blocks/RedstoneMachine.java | 40 +- .../blocks/logic/AdvancedDrawbridgeLogic.java | 976 ++++++++++-------- src/tconstruct/client/TProxyClient.java | 160 +-- .../client/gui/AdvDrawbridgeGui.java | 115 +++ src/tconstruct/client/gui/SlotButton.java | 125 +++ src/tconstruct/common/TContent.java | 1 + src/tconstruct/common/TProxyCommon.java | 1 + .../AdvancedDrawbridgeContainer.java | 154 +-- .../items/blocks/RedstoneMachineItem.java | 2 +- .../blocks/ExpandableInventoryLogic.java | 13 +- 11 files changed, 922 insertions(+), 665 deletions(-) create mode 100644 resources/assets/tinker/textures/gui/slotButton.png create mode 100644 src/tconstruct/client/gui/AdvDrawbridgeGui.java create mode 100644 src/tconstruct/client/gui/SlotButton.java diff --git a/resources/assets/tinker/textures/gui/slotButton.png b/resources/assets/tinker/textures/gui/slotButton.png new file mode 100644 index 0000000000000000000000000000000000000000..4cdd631f16f3ff66e8357f97e4f11489f9292820 GIT binary patch literal 11665 zcmeHt=UY=x@Gl62&^v@8Rf_a3CG@5s?Ta*l0MewF2m}crHGotpK{}|QfK=(dcOs&6 z2|Y*)MG2jo-+k_@`xo37_c?oZ_srSn?C$K$XXorpf{BqH6*(I@0RaKklgHZs5fBjK ztAqqV0KTvd`0R==051&mv;N9j~`CH@9GnWzwOGaCNmX&zd~-ItANUXCLDfGhJA_ zn?>Im&Nv6!{SQTEynf(LV*JI1!gIU1rs~Qp7uE<%MxBn8Hq~Zxb8~CEIr$W)4qRLH zvE7kdA!f4;R^C?ajjvcAPnpsu@`h96U}@Q)wa`% z97Nr8OKGgA*QV!U6uT%?(Sg6C`|72f_)N1uHG1dSW}uzyEZfo81m1OPhmP%#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-2mHAu{xIi8d{4K$V>as8+a@)QB1RWy%U4e4;+t*))PW%Pz zAY(vuIlV-_{Gi@Ev2@vCqC zpp9eKTjyeTj<1(18IeQN9!i$qQzsu813YYOn)+>DNz<~vahzY$YOikCg*Q1Wd)}-$ z7oRH9rQy97xy>1oZPgUzsFV+1;rQMk2oilAf8lHIdxsx#mC!nI1a?$CaAv-?p#CjG zAbyhf1c{QJ!2ZC*`%F$U)H6Yg=`2Hdnq7^>qvSw@R?ASt?5MhTULoaA-1JV>QaZ-i z7_hjqhwrhB47zCyxLh{^?6$oGjn`8Gz86r&n1#DaOTwjTjd=8p03K{MO*rehUqc7Z z#j^#JvddVDOcz;BbeQz_?U bufferStacks = new ArrayList(); -// -// @Override -// public void setWorldObj(World par1World) { -// this.worldObj = par1World; -// fakePlayer = new FakePlayerLogic(worldObj, "Player.Drawbridge", this); -// } -// -// @Override -// public boolean getActive() { -// return active; -// } -// -// @Override -// public void setActive(boolean flag) { -// active = flag; -// working = true; -// } -// -// @Override -// public byte getRenderDirection() { -// return direction; -// } -// -// @Override -// public ForgeDirection getForgeDirection() { -// return ForgeDirection.VALID_DIRECTIONS[direction]; -// } -// -// @Override -// public void setDirection(int side) { -// } -// -// public boolean canDropInventorySlot(int slot) { -// return false; -// } -// -// @Override -// public void setDirection(float yaw, float pitch, EntityLivingBase player) { -// if (pitch > 45) { -// direction = 1; -// } else if (pitch < -45) { -// direction = 0; -// } else { -// int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; -// switch (facing) { -// case 0: -// direction = 2; -// break; -// -// case 1: -// direction = 5; -// break; -// -// case 2: -// direction = 3; -// break; -// -// case 3: -// direction = 4; -// break; -// } -// } -// } -// -// /* -// * 0 = Up 1 = Right 2 = Down 3 = Left 4 = Center, neutral -// */ -// public void setPlacementDirection(byte keycode) { -// if (keycode == 4) { -// fakePlayer.rotationYaw = 0; -// fakePlayer.rotationPitch = 0; -// } else if (this.direction == 0 || this.direction == 1) { -// switch (keycode) { -// case 0: -// fakePlayer.rotationYaw = 0; -// break; -// case 1: -// fakePlayer.rotationYaw = 90; -// break; -// case 2: -// fakePlayer.rotationYaw = 180; -// break; -// case 3: -// fakePlayer.rotationYaw = 270; -// break; -// } -// -// if (this.direction == 0) -// fakePlayer.rotationPitch = -90; -// else -// fakePlayer.rotationPitch = 90; -// } else { -// if (keycode == 0) // Forward -// { -// fakePlayer.rotationYaw = mapDirection() * 90; -// -// if (keycode == 0) -// fakePlayer.rotationPitch = 90; -// else -// fakePlayer.rotationPitch = -90; -// } else if (keycode == 2) // Backward -// { -// int face = mapDirection() + 2; -// if (face > 3) -// face -= 4; -// fakePlayer.rotationYaw = face * 90; -// -// if (keycode == 0) -// fakePlayer.rotationPitch = 90; -// else -// fakePlayer.rotationPitch = -90; -// } else { -// fakePlayer.rotationPitch = 0; -// -// int facing = mapDirection(); -// if (keycode == 1) -// facing += 1; -// else -// facing -= 1; -// -// if (facing >= 4) -// facing = 0; -// if (facing < 0) -// facing = 3; -// -// fakePlayer.rotationYaw = facing * 90; -// } -// } -// placementDirection = keycode; -// } -// -// int mapDirection() { -// if (this.direction == 2) // North -// return 0; -// if (this.direction == 5) // East -// return 1; -// if (this.direction == 3) // South -// return 2; -// -// return 3; // West -// } -// -// public byte getPlacementDirection() { -// return placementDirection; -// } -// -// @Override -// public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) { -// return new AdvancedDrawbridgeContainer(inventoryplayer, this); -// } -// -// @Override -// protected String getDefaultName() { -// return "tinker.drawbridge"; -// } -// -// @Override -// public void setInventorySlotContents(int slot, ItemStack itemstack) { -// super.setInventorySlotContents(slot, itemstack); -// if (slot == 1) -// worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); -// } -// -// @Override -// public ItemStack decrStackSize(int slot, int quantity) { -// ItemStack stack = super.decrStackSize(slot, quantity); -// if (slot == 1) -// worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); -// return stack; -// } -// -// public void updateEntity() { -// if (working) { -// ticks++; -// if (ticks == 5) { -// ticks = 0; -// if (active) // Placement -// { -// if (inventory[0] != null && inventory[0].stackSize > 0 && extension < 15) { -// extension++; -// int xPos = xCoord; -// int yPos = yCoord; -// int zPos = zCoord; -// -// switch (direction) { -// case 0: -// yPos -= extension; -// break; -// case 1: -// yPos += extension; -// break; -// case 2: -// zPos -= extension; -// break; -// case 3: -// zPos += extension; -// break; -// case 4: -// xPos -= extension; -// break; -// case 5: -// xPos += extension; -// break; -// } -// -// Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; -// if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos)) { -// // tryExtend(worldObj, xPos, yPos, zPos, direction); -// int blockToItem = TConstructRegistry.blockToItemMapping[bufferStack.itemID]; -// if (blockToItem == 0) { -// if (inventory[0].itemID >= 4096 || Block.blocksList[inventory[0].itemID] == null) -// return; -// Block placeBlock = Block.blocksList[bufferStack.itemID]; -// placeBlockAt(bufferStack, fakePlayer, worldObj, xPos, yPos, zPos, direction, 0, 0, 0, bufferStack.getItemDamage(), placeBlock); -// } else { -// Block placeBlock = Block.blocksList[blockToItem]; -// placeBlockAt(bufferStack, fakePlayer, worldObj, xPos, yPos, zPos, direction, 0, 0, 0, bufferStack.getItemDamage(), placeBlock); -// } -// worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F); -// decrStackSize(0, 1); -// } else { -// extension--; -// working = false; -// } -// } -// -// else { -// working = false; -// } -// } else -// // Retraction -// { -// if ((inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) && extension > 0) { -// int xPos = xCoord; -// int yPos = yCoord; -// int zPos = zCoord; -// -// switch (direction) { -// case 0: -// yPos -= extension; -// break; -// case 1: -// yPos += extension; -// break; -// case 2: -// zPos -= extension; -// break; -// case 3: -// zPos += extension; -// break; -// case 4: -// xPos -= extension; -// break; -// case 5: -// xPos += extension; -// break; -// } -// -// Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; -// if (block != null) { -// int meta = worldObj.getBlockMetadata(xPos, yPos, zPos); -// if (bufferStack != null && validBlock(block) && validMetadata(block.blockID, meta)) { -// worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F); -// if (worldObj.setBlock(xPos, yPos, zPos, 0)) -// if (inventory[0] == null) { -// inventory[0] = bufferStack.copy(); -// } else { -// inventory[0].stackSize++; -// } -// } else { -// working = false; -// } -// } -// extension--; -// } else { -// working = false; -// } -// } -// } -// } -// } -// -// /** -// * Called to actually place the block, after the location is determined and -// * all permission checks have been made. Copied from ItemBlock -// * -// * @param stack -// * The item stack that was used to place the block. This can be -// * changed inside the method. -// * @param player -// * The player who is placing the block. Can be null if the block -// * is not being placed by a player. -// * @param side -// * The side the player (or machine) right-clicked on. -// */ -// public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata, Block block) { -// if (!world.setBlock(x, y, z, block.blockID, metadata, 3)) { -// return false; -// } -// -// if (world.getBlockId(x, y, z) == block.blockID) { -// block.onBlockPlacedBy(world, x, y, z, player, stack); -// block.onPostBlockPlaced(world, x, y, z, metadata); -// } -// -// return true; -// } -// -// boolean validBlock(Block block) { -// int type = TConstructRegistry.interchangableBlockMapping[block.blockID]; -// if (type != 0) { -// if (type == bufferStack.itemID) -// return true; -// } -// int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID]; -// if (blockToItem != 0) { -// if (blockToItem == bufferStack.itemID) -// return true; -// } -// return block.blockID == bufferStack.itemID; -// } -// -// boolean validMetadata(int blockID, int metadata) { -// int type = TConstructRegistry.drawbridgeState[blockID]; -// if (type == 0) { -// return metadata == bufferStack.getItemDamage(); -// } -// if (type == 1) { -// return true; -// } -// if (type == 2) { -// return false; -// } -// if (type == 3) { -// return true; // TODO: rotational metadata, probably not needed -// // anymore -// } -// if (type == 4) { -// return true; -// } -// if (type == 5) { -// return metadata == bufferStack.getItemDamage(); -// } -// return false; -// } -// -// @Override -// public void readFromNBT(NBTTagCompound tags) { -// super.readFromNBT(tags); -// active = tags.getBoolean("Active"); -// working = tags.getBoolean("Working"); -// extension = tags.getByte("Extension"); -// -// NBTTagCompound bufferInv = (NBTTagCompound) tags.getTag("BufferInv"); -// if (bufferInv != null) { -// bufferStack = ItemStack.loadItemStackFromNBT(bufferInv); -// } -// -// readCustomNBT(tags); -// } -// -// @Override -// public void writeToNBT(NBTTagCompound tags) { -// super.writeToNBT(tags); -// tags.setBoolean("Active", active); -// tags.setBoolean("Working", working); -// tags.setByte("Extension", extension); -// -// if (bufferStack != null) { -// NBTTagCompound bufferInv = new NBTTagCompound(); -// bufferStack.writeToNBT(bufferInv); -// tags.setTag("BufferInv", bufferInv); -// } -// -// writeCustomNBT(tags); -// } -// -// public void readCustomNBT(NBTTagCompound tags) { -// direction = tags.getByte("Direction"); -// placementDirection = tags.getByte("Placement"); -// } -// -// public void writeCustomNBT(NBTTagCompound tags) { -// tags.setByte("Direction", direction); -// tags.setByte("Placement", placementDirection); -// } -// -// /* Packets */ -// @Override -// public Packet getDescriptionPacket() { -// NBTTagCompound tag = new NBTTagCompound(); -// writeToNBT(tag); -// return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); -// } -// -// @Override -// public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { -// readFromNBT(packet.data); -// worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); -// } -// -// public boolean hasExtended() { -// return extension != 0; -// } -// -// @Override -// public void onInventoryChanged() { -// super.onInventoryChanged(); -// if (getStackInSlot(0) != null) { -// bufferStack = getStackInSlot(0).copy(); -// bufferStack.stackSize = 1; -// } -// this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); -// } -//} +package tconstruct.blocks.logic; + +import net.minecraft.inventory.InventoryBasic; + +import net.minecraft.nbt.NBTTagList; + +import java.util.ArrayList; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.*; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.*; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import tconstruct.inventory.AdvancedDrawbridgeContainer; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.blocks.*; +import tconstruct.library.util.*; +import tconstruct.util.player.FakePlayerLogic; + +public class AdvancedDrawbridgeLogic extends ExpandableInventoryLogic implements IFacingLogic, IActiveLogic, IDrawbridgeLogicBase { + boolean active; + boolean working; + int ticks; + public int selSlot = 0; + byte extension; + byte direction; + byte placementDirection = 4; + FakePlayerLogic fakePlayer; + + ArrayList bufferStacks = new ArrayList(); + + public InvCamo camoInventory = new InvCamo(); + + @Override + public void setWorldObj(World par1World) { + this.worldObj = par1World; + fakePlayer = new FakePlayerLogic(worldObj, "Player.Drawbridge", this); + } + + @Override + public boolean getActive() { + return active; + } + + @Override + public void setActive(boolean flag) { + active = flag; + working = true; + } + + @Override + public byte getRenderDirection() { + return direction; + } + + @Override + public ForgeDirection getForgeDirection() { + return ForgeDirection.VALID_DIRECTIONS[direction]; + } + + @Override + public void setDirection(int side) { + } + + public boolean canDropInventorySlot(int slot) { + return false; + } + + @Override + public void setDirection(float yaw, float pitch, EntityLivingBase player) { + if (pitch > 45) { + direction = 1; + } else if (pitch < -45) { + direction = 0; + } else { + int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3; + switch (facing) { + case 0: + direction = 2; + break; + + case 1: + direction = 5; + break; + + case 2: + direction = 3; + break; + + case 3: + direction = 4; + break; + } + } + } + + /* + * 0 = Up 1 = Right 2 = Down 3 = Left 4 = Center, neutral + */ + public void setPlacementDirection(byte keycode) { + if (keycode == 4) { + fakePlayer.rotationYaw = 0; + fakePlayer.rotationPitch = 0; + } else if (this.direction == 0 || this.direction == 1) { + switch (keycode) { + case 0: + fakePlayer.rotationYaw = 0; + break; + case 1: + fakePlayer.rotationYaw = 90; + break; + case 2: + fakePlayer.rotationYaw = 180; + break; + case 3: + fakePlayer.rotationYaw = 270; + break; + } + + if (this.direction == 0) + fakePlayer.rotationPitch = -90; + else + fakePlayer.rotationPitch = 90; + } else { + if (keycode == 0) // Forward + { + fakePlayer.rotationYaw = mapDirection() * 90; + + if (keycode == 0) + fakePlayer.rotationPitch = 90; + else + fakePlayer.rotationPitch = -90; + } else if (keycode == 2) // Backward + { + int face = mapDirection() + 2; + if (face > 3) + face -= 4; + fakePlayer.rotationYaw = face * 90; + + if (keycode == 0) + fakePlayer.rotationPitch = 90; + else + fakePlayer.rotationPitch = -90; + } else { + fakePlayer.rotationPitch = 0; + + int facing = mapDirection(); + if (keycode == 1) + facing += 1; + else + facing -= 1; + + if (facing >= 4) + facing = 0; + if (facing < 0) + facing = 3; + + fakePlayer.rotationYaw = facing * 90; + } + } + placementDirection = keycode; + } + + int mapDirection() { + if (this.direction == 2) // North + return 0; + if (this.direction == 5) // East + return 1; + if (this.direction == 3) // South + return 2; + + return 3; // West + } + + public byte getPlacementDirection() { + return placementDirection; + } + + public ItemStack getStackInBufferSlot(int slot) { + return slot < bufferStacks.size() ? bufferStacks.get(slot) : null; + } + + public void setBufferSlotContents(int slot, ItemStack itemstack) { + if (slot < bufferStacks.size()) { + bufferStacks.set(slot, itemstack); + } else if (slot == bufferStacks.size()) { + bufferStacks.add(itemstack); + } else if (slot < getMaxSize()) { + bufferStacks.ensureCapacity(slot); + bufferStacks.set(slot, itemstack); + } else { + return; + } + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) { + return new AdvancedDrawbridgeContainer(inventoryplayer, this); + } + + @Override + protected String getDefaultName() { + return "tinker.drawbridge"; + } + + @Override + public ItemStack decrStackSize(int slot, int quantity) { + ItemStack stack = super.decrStackSize(slot, quantity); + if (slot == 1) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return stack; + } + + public void updateEntity() { + if (working) { + ticks++; + if (ticks == 5) { + ticks = 0; + if (active) // Placement + { + if (getStackInSlot(extension) != null && getStackInSlot(extension).stackSize > 0 && extension < 15) { + extension++; + int xPos = xCoord; + int yPos = yCoord; + int zPos = zCoord; + + switch (direction) { + case 0: + yPos -= extension; + break; + case 1: + yPos += extension; + break; + case 2: + zPos -= extension; + break; + case 3: + zPos += extension; + break; + case 4: + xPos -= extension; + break; + case 5: + xPos += extension; + break; + } + + Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; + if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos)) { + // tryExtend(worldObj, xPos, yPos, zPos, direction); + int blockToItem = TConstructRegistry.blockToItemMapping[getStackInBufferSlot(extension).itemID]; + if (blockToItem == 0) { + if (getStackInSlot(extension).itemID >= 4096 || Block.blocksList[getStackInSlot(extension).itemID] == null) + return; + Block placeBlock = Block.blocksList[getStackInBufferSlot(extension).itemID]; + placeBlockAt(getStackInBufferSlot(extension), fakePlayer, worldObj, xPos, yPos, zPos, direction, 0, 0, 0, getStackInBufferSlot(extension).getItemDamage(), placeBlock); + } else { + Block placeBlock = Block.blocksList[blockToItem]; + placeBlockAt(getStackInBufferSlot(extension), fakePlayer, worldObj, xPos, yPos, zPos, direction, 0, 0, 0, getStackInBufferSlot(extension).getItemDamage(), placeBlock); + } + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F); + decrStackSize(0, 1); + } else { + extension--; + working = false; + } + } else { + working = false; + } + } else + // Retraction + { + if ((getStackInSlot(extension) == null || getStackInSlot(extension).stackSize < getStackInSlot(extension).getMaxStackSize()) && extension > 0) { + int xPos = xCoord; + int yPos = yCoord; + int zPos = zCoord; + + switch (direction) { + case 0: + yPos -= extension; + break; + case 1: + yPos += extension; + break; + case 2: + zPos -= extension; + break; + case 3: + zPos += extension; + break; + case 4: + xPos -= extension; + break; + case 5: + xPos += extension; + break; + } + + Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)]; + if (block != null) { + int meta = worldObj.getBlockMetadata(xPos, yPos, zPos); + if (getStackInBufferSlot(extension) != null && validBlock(extension, block) && validMetadata(extension, block.blockID, meta)) { + worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F); + if (worldObj.setBlock(xPos, yPos, zPos, 0)) + if (getStackInSlot(extension) == null) { + setInventorySlotContents(extension, getStackInBufferSlot(extension).copy()); + } else { + getStackInSlot(extension).stackSize++; + } + } else { + working = false; + } + } + extension--; + } else { + working = false; + } + } + } + } + } + + /** + * Called to actually place the block, after the location is determined and + * all permission checks have been made. Copied from ItemBlock + * + * @param stack + * The item stack that was used to place the block. This can be + * changed inside the method. + * @param player + * The player who is placing the block. Can be null if the block + * is not being placed by a player. + * @param side + * The side the player (or machine) right-clicked on. + */ + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata, Block block) { + if (!world.setBlock(x, y, z, block.blockID, metadata, 3)) { + return false; + } + + if (world.getBlockId(x, y, z) == block.blockID) { + block.onBlockPlacedBy(world, x, y, z, player, stack); + block.onPostBlockPlaced(world, x, y, z, metadata); + } + + return true; + } + + boolean validBlock(int slot, Block block) { + int type = TConstructRegistry.interchangableBlockMapping[block.blockID]; + if (type != 0) { + if (type == getStackInBufferSlot(slot).itemID) + return true; + } + int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID]; + if (blockToItem != 0) { + if (blockToItem == getStackInBufferSlot(slot).itemID) + return true; + } + return block.blockID == getStackInBufferSlot(slot).itemID; + } + + boolean validMetadata(int slot, int blockID, int metadata) { + int type = TConstructRegistry.drawbridgeState[blockID]; + if (type == 0) { + return metadata == getStackInBufferSlot(slot).getItemDamage(); + } + if (type == 1) { + return true; + } + if (type == 2) { + return false; + } + if (type == 3) { + return true; // TODO: rotational metadata, probably not needed + // anymore + } + if (type == 4) { + return true; + } + if (type == 5) { + return metadata == getStackInBufferSlot(slot).getItemDamage(); + } + return false; + } + + @Override + public void readFromNBT(NBTTagCompound tags) { + super.readFromNBT(tags); + active = tags.getBoolean("Active"); + working = tags.getBoolean("Working"); + extension = tags.getByte("Extension"); + + NBTTagCompound camoTag = (NBTTagCompound) tags.getTag("Camo"); + if (camoTag != null) { + camoInventory.setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(camoTag)); + } + + readBufferFromNBT(tags); + + readCustomNBT(tags); + } + + @Override + public void writeToNBT(NBTTagCompound tags) { + super.writeToNBT(tags); + tags.setBoolean("Active", active); + tags.setBoolean("Working", working); + tags.setByte("Extension", extension); + + if (camoInventory.getStackInSlot(0) != null) { + NBTTagCompound camoTag = new NBTTagCompound(); + camoInventory.getStackInSlot(0).writeToNBT(camoTag); + tags.setTag("Camo", camoTag); + } + + writeBufferToNBT(tags); + + writeCustomNBT(tags); + } + + public void readBufferFromNBT(NBTTagCompound tags) { + NBTTagList nbttaglist = tags.getTagList("Buffer"); + bufferStacks = new ArrayList(); + bufferStacks.ensureCapacity(nbttaglist.tagCount() > getMaxSize() ? getMaxSize() : nbttaglist.tagCount()); + for (int iter = 0; iter < nbttaglist.tagCount(); iter++) { + NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter); + byte slotID = tagList.getByte("Slot"); + if (slotID >= 0 && slotID < bufferStacks.size()) { + setBufferSlotContents(slotID, ItemStack.loadItemStackFromNBT(tagList)); + } + } + } + + public void writeBufferToNBT(NBTTagCompound tags) { + NBTTagList nbttaglist = new NBTTagList(); + for (int iter = 0; iter < bufferStacks.size(); iter++) { + if (getStackInBufferSlot(iter) != null) { + NBTTagCompound tagList = new NBTTagCompound(); + tagList.setByte("Slot", (byte) iter); + getStackInBufferSlot(iter).writeToNBT(tagList); + nbttaglist.appendTag(tagList); + } + } + + tags.setTag("Buffer", nbttaglist); + } + + public void readCustomNBT(NBTTagCompound tags) { + direction = tags.getByte("Direction"); + placementDirection = tags.getByte("Placement"); + } + + public void writeCustomNBT(NBTTagCompound tags) { + tags.setByte("Direction", direction); + tags.setByte("Placement", placementDirection); + } + + /* Packets */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void onDataPacket(INetworkManager net, Packet132TileEntityData packet) { + readFromNBT(packet.data); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + public boolean hasExtended() { + return extension != 0; + } + + @Override + public void onInventoryChanged() { + super.onInventoryChanged(); + for (int i = 0; i < getMaxSize(); i++) { + if (getStackInSlot(i) != null) { + setBufferSlotContents(i, getStackInSlot(0).copy()); + getStackInBufferSlot(i).stackSize = 1; + } + } + this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public int getMaxSize() { + return 16; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + public class InvCamo extends InventoryBasic { + + private InvCamo() { + super("camoSlot", false, 1); + } + + public ItemStack getCamoStack() { + return this.getStackInSlot(0); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack content) { + super.setInventorySlotContents(slot, content); + if (slot == 0) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + @Override + public void onInventoryChanged() { + super.onInventoryChanged(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } +} diff --git a/src/tconstruct/client/TProxyClient.java b/src/tconstruct/client/TProxyClient.java index d9ef408a..3baed116 100644 --- a/src/tconstruct/client/TProxyClient.java +++ b/src/tconstruct/client/TProxyClient.java @@ -1,159 +1,47 @@ package tconstruct.client; +import com.google.common.collect.Lists; +import cpw.mods.fml.client.registry.*; +import cpw.mods.fml.common.registry.*; +import cpw.mods.fml.relauncher.Side; import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - +import java.util.*; +import javax.xml.parsers.*; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.model.ModelSlime; -import net.minecraft.client.particle.EntityAuraFX; -import net.minecraft.client.particle.EntityBreakingFX; -import net.minecraft.client.particle.EntityBubbleFX; -import net.minecraft.client.particle.EntityCloudFX; -import net.minecraft.client.particle.EntityCritFX; -import net.minecraft.client.particle.EntityDropParticleFX; -import net.minecraft.client.particle.EntityEnchantmentTableParticleFX; -import net.minecraft.client.particle.EntityExplodeFX; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.particle.EntityFireworkSparkFX; -import net.minecraft.client.particle.EntityFlameFX; -import net.minecraft.client.particle.EntityFootStepFX; -import net.minecraft.client.particle.EntityHeartFX; -import net.minecraft.client.particle.EntityHugeExplodeFX; -import net.minecraft.client.particle.EntityLargeExplodeFX; -import net.minecraft.client.particle.EntityLavaFX; -import net.minecraft.client.particle.EntityNoteFX; -import net.minecraft.client.particle.EntityPortalFX; -import net.minecraft.client.particle.EntityReddustFX; -import net.minecraft.client.particle.EntitySmokeFX; -import net.minecraft.client.particle.EntitySnowShovelFX; -import net.minecraft.client.particle.EntitySpellParticleFX; -import net.minecraft.client.particle.EntitySplashFX; -import net.minecraft.client.particle.EntitySuspendFX; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.particle.*; +import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.Entity; +import net.minecraft.client.settings.*; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraft.util.ResourceLocation; +import net.minecraft.item.*; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.RenderBlockFluid; - import org.lwjgl.opengl.GL11; import org.w3c.dom.Document; - import tconstruct.TConstruct; -import tconstruct.blocks.logic.CastingBasinLogic; -import tconstruct.blocks.logic.CastingTableLogic; -import tconstruct.blocks.logic.CraftingStationLogic; -import tconstruct.blocks.logic.DrawbridgeLogic; -import tconstruct.blocks.logic.DryingRackLogic; -import tconstruct.blocks.logic.FrypanLogic; -import tconstruct.blocks.logic.PartBuilderLogic; -import tconstruct.blocks.logic.PatternChestLogic; -import tconstruct.blocks.logic.SmelteryLogic; -import tconstruct.blocks.logic.StencilTableLogic; -import tconstruct.blocks.logic.TileEntityLandmine; -import tconstruct.blocks.logic.ToolForgeLogic; -import tconstruct.blocks.logic.ToolStationLogic; -import tconstruct.client.block.BarricadeRender; -import tconstruct.client.block.BlockRenderCastingChannel; -import tconstruct.client.block.CastingBasinSpecialRender; -import tconstruct.client.block.CastingTableSpecialRenderer; -import tconstruct.client.block.DryingRackRender; -import tconstruct.client.block.DryingRackSpecialRender; -import tconstruct.client.block.FrypanRender; -import tconstruct.client.block.MachineRender; -import tconstruct.client.block.OreberryRender; -import tconstruct.client.block.PaneConnectedRender; -import tconstruct.client.block.PaneRender; -import tconstruct.client.block.PunjiRender; -import tconstruct.client.block.RenderLandmine; -import tconstruct.client.block.SearedRender; -import tconstruct.client.block.SlimeChannelRender; -import tconstruct.client.block.SlimePadRender; -import tconstruct.client.block.SmallFontRenderer; -import tconstruct.client.block.SmelteryRender; -import tconstruct.client.block.TableForgeRender; -import tconstruct.client.block.TableRender; -import tconstruct.client.block.TankRender; -import tconstruct.client.entity.CartRender; -import tconstruct.client.entity.CrystalRender; -import tconstruct.client.entity.FancyItemRender; -import tconstruct.client.entity.SlimeRender; -import tconstruct.client.entity.projectile.ArrowRenderCustom; -import tconstruct.client.entity.projectile.DaggerRenderCustom; -import tconstruct.client.entity.projectile.LaunchedItemRender; -import tconstruct.client.gui.ArmorExtendedGui; -import tconstruct.client.gui.CraftingStationGui; -import tconstruct.client.gui.DrawbridgeGui; -import tconstruct.client.gui.FrypanGui; -import tconstruct.client.gui.GuiLandmine; -import tconstruct.client.gui.GuiManual; -import tconstruct.client.gui.KnapsackGui; -import tconstruct.client.gui.PartCrafterGui; -import tconstruct.client.gui.PatternChestGui; -import tconstruct.client.gui.SmelteryGui; -import tconstruct.client.gui.StencilTableGui; -import tconstruct.client.gui.ToolForgeGui; -import tconstruct.client.gui.ToolStationGui; -import tconstruct.client.pages.BlankPage; -import tconstruct.client.pages.BlockCastPage; -import tconstruct.client.pages.BookPage; -import tconstruct.client.pages.ContentsTablePage; -import tconstruct.client.pages.CraftingPage; -import tconstruct.client.pages.FurnacePage; -import tconstruct.client.pages.MaterialPage; -import tconstruct.client.pages.ModifierPage; -import tconstruct.client.pages.PicturePage; -import tconstruct.client.pages.SectionPage; -import tconstruct.client.pages.SidebarPage; -import tconstruct.client.pages.TextPage; -import tconstruct.client.pages.TitlePage; -import tconstruct.client.pages.ToolPage; -import tconstruct.client.tabs.InventoryTabArmorExtended; -import tconstruct.client.tabs.InventoryTabKnapsack; -import tconstruct.client.tabs.InventoryTabVanilla; -import tconstruct.client.tabs.TabRegistry; -import tconstruct.common.TContent; -import tconstruct.common.TProxyCommon; -import tconstruct.entity.BlueSlime; -import tconstruct.entity.CartEntity; -import tconstruct.entity.Crystal; -import tconstruct.entity.FancyEntityItem; -import tconstruct.entity.projectile.ArrowEntity; -import tconstruct.entity.projectile.DaggerEntity; -import tconstruct.entity.projectile.LaunchedPotion; +import tconstruct.blocks.logic.*; +import tconstruct.client.block.*; +import tconstruct.client.entity.*; +import tconstruct.client.entity.projectile.*; +import tconstruct.client.gui.*; +import tconstruct.client.pages.*; +import tconstruct.client.tabs.*; +import tconstruct.common.*; +import tconstruct.entity.*; +import tconstruct.entity.projectile.*; import tconstruct.inventory.ContainerLandmine; import tconstruct.library.TConstructRegistry; -import tconstruct.library.client.TConstructClientRegistry; -import tconstruct.library.client.ToolGuiElement; +import tconstruct.library.client.*; import tconstruct.library.crafting.ToolBuilder; import tconstruct.library.tools.ToolCore; -import tconstruct.util.player.ArmorExtended; -import tconstruct.util.player.KnapsackInventory; - -import com.google.common.collect.Lists; - -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.registry.TickRegistry; -import cpw.mods.fml.common.registry.VillagerRegistry; -import cpw.mods.fml.relauncher.Side; +import tconstruct.util.player.*; public class TProxyClient extends TProxyCommon { @@ -188,6 +76,8 @@ public class TProxyClient extends TProxyCommon return new GuiLandmine(new ContainerLandmine(player, (TileEntityLandmine) world.getBlockTileEntity(x, y, z))); if (ID == craftingStationID) return new CraftingStationGui(player.inventory, (CraftingStationLogic) world.getBlockTileEntity(x, y, z), x, y, z); + if (ID == advDrawbridgeID) + return new AdvDrawbridgeGui(player.inventory, (AdvancedDrawbridgeLogic) world.getBlockTileEntity(x, y, z), world, x, y, z); if (ID == manualGuiID) { diff --git a/src/tconstruct/client/gui/AdvDrawbridgeGui.java b/src/tconstruct/client/gui/AdvDrawbridgeGui.java new file mode 100644 index 00000000..812b4f41 --- /dev/null +++ b/src/tconstruct/client/gui/AdvDrawbridgeGui.java @@ -0,0 +1,115 @@ +package tconstruct.client.gui; + +import cpw.mods.fml.common.network.PacketDispatcher; +import java.io.*; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.util.*; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import tconstruct.blocks.logic.AdvancedDrawbridgeLogic; + +public class AdvDrawbridgeGui extends GuiContainer +{ + public AdvancedDrawbridgeLogic logic; + + public AdvDrawbridgeGui(InventoryPlayer inventoryplayer, AdvancedDrawbridgeLogic frypan, World world, int x, int y, int z) + { + super(frypan.getGuiContainer(inventoryplayer, world, x, y, z)); + logic = frypan; + } + + protected void drawGuiContainerForegroundLayer (int par1, int par2) + { + //fontRenderer.drawString(StatCollector.translateToLocal("aggregator.glowstone"), 60, 6, 0x404040); + fontRenderer.drawString("Drawbridge", 8, 6, 0x404040); + fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + } + + private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/drawbridge.png"); + + protected void drawGuiContainerBackgroundLayer (float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(background); + int cornerX = (width - xSize) / 2; + int cornerY = (height - ySize) / 2; + drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize); + } + + public void initGui () + { + super.initGui(); + int cornerX = (this.width - this.xSize) / 2; + int cornerY = (this.height - this.ySize) / 2; + + this.buttonList.clear(); + GuiButton button = new DrawbridgeButton(0, cornerX + 131, cornerY + 18, 176, 0, 21, 22); + if (logic.getPlacementDirection() == 0) + button.enabled = false; + this.buttonList.add(button); + button = new DrawbridgeButton(1, cornerX + 146, cornerY + 34, 199, 23, 22, 21); + if (logic.getPlacementDirection() == 1) + button.enabled = false; + this.buttonList.add(button); + button = new DrawbridgeButton(2, cornerX + 132, cornerY + 48, 199, 0, 21, 22); + if (logic.getPlacementDirection() == 2) + button.enabled = false; + this.buttonList.add(button); + button = new DrawbridgeButton(3, cornerX + 117, cornerY + 34, 178, 23, 22, 21); + if (logic.getPlacementDirection() == 3) + button.enabled = false; + this.buttonList.add(button); + button = new DrawbridgeButton(4, cornerX + 135, cornerY + 40, 217, 0, 10, 10); + if (logic.getPlacementDirection() == 4) + button.enabled = false; + this.buttonList.add(button); + + this.buttonList.add(new SlotButton(5, this.width / 2 - 13, this.height / 2 - 52, 26, 26, "")); + } + + protected void actionPerformed (GuiButton button) + { + if(button.id == 5){ + return; + } + + for (Object o : buttonList) + { + GuiButton b = (GuiButton) o; + b.enabled = true; + } + button.enabled = false; + + logic.setPlacementDirection((byte) button.id); + updateServer((byte) button.id); + } + + void updateServer (byte direction) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(5); + outputStream.writeInt(logic.worldObj.provider.dimensionId); + outputStream.writeInt(logic.xCoord); + outputStream.writeInt(logic.yCoord); + outputStream.writeInt(logic.zCoord); + outputStream.writeByte(direction); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToServer(packet); + } +} diff --git a/src/tconstruct/client/gui/SlotButton.java b/src/tconstruct/client/gui/SlotButton.java new file mode 100644 index 00000000..fb76051e --- /dev/null +++ b/src/tconstruct/client/gui/SlotButton.java @@ -0,0 +1,125 @@ +package tconstruct.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.GuiButton; + +public class SlotButton extends GuiButton { + protected static final ResourceLocation buttonTextures = new ResourceLocation("tinker:textures/gui/slotButton.png"); + + /** Button width in pixels */ + protected int width; + + /** Button height in pixels */ + protected int height; + + /** The x position of this control. */ + public int xPosition; + + /** The y position of this control. */ + public int yPosition; + + /** The string displayed on this control. */ + public String displayString; + + /** ID for this control. */ + public int id; + + /** True if this control is enabled, false to disable. */ + public boolean enabled; + + /** Hides the button completely if false. */ + public boolean drawButton; + protected boolean field_82253_i; + + public SlotButton(int par1, int par2, int par3, String par4Str) { + this(par1, par2, par3, 200, 20, par4Str); + } + + public SlotButton(int par1, int par2, int par3, int par4, int par5, String par6Str) { + super(par1, par2, par3, par4, par5, par6Str); + this.width = 200; + this.height = 20; + this.enabled = true; + this.drawButton = true; + this.id = par1; + this.xPosition = par2; + this.yPosition = par3; + this.width = par4; + this.height = par5; + this.displayString = par6Str; + } + + /** + * Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over + * this button and 2 if it IS hovering over this button. + */ + protected int getHoverState(boolean par1) { + byte b0 = 1; + + if (!this.enabled) { + b0 = 0; + } else if (par1) { + b0 = 2; + } + + return b0; + } + + /** + * Draws this button to the screen. + */ + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { + if (this.drawButton) { + FontRenderer fontrenderer = par1Minecraft.fontRenderer; + par1Minecraft.getTextureManager().bindTexture(buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_82253_i = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + int k = this.getHoverState(this.field_82253_i); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 26, this.width / 2, this.height); + this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 26, this.width / 2, this.height); + this.mouseDragged(par1Minecraft, par2, par3); + int l = 14737632; + + if (!this.enabled) { + l = -6250336; + } else if (this.field_82253_i) { + l = 16777120; + } + + this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + } + } + + /** + * Fired when the mouse button is dragged. Equivalent of + * MouseListener.mouseDragged(MouseEvent e). + */ + protected void mouseDragged(Minecraft par1Minecraft, int par2, int par3) { + } + + /** + * Fired when the mouse button is released. Equivalent of + * MouseListener.mouseReleased(MouseEvent e). + */ + public void mouseReleased(int par1, int par2) { + } + + /** + * Returns true if the mouse has been pressed on this control. Equivalent of + * MouseListener.mousePressed(MouseEvent e). + */ + public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) { + return this.enabled && this.drawButton && par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + } + + public boolean func_82252_a() { + return this.field_82253_i; + } + + public void func_82251_b(int par1, int par2) { + } +} \ No newline at end of file diff --git a/src/tconstruct/common/TContent.java b/src/tconstruct/common/TContent.java index 841ab2a3..5c3365ed 100644 --- a/src/tconstruct/common/TContent.java +++ b/src/tconstruct/common/TContent.java @@ -406,6 +406,7 @@ public class TContent implements IFuelHandler GameRegistry.registerBlock(redstoneMachine, RedstoneMachineItem.class, "Redstone.Machine"); GameRegistry.registerTileEntity(DrawbridgeLogic.class, "Drawbridge"); GameRegistry.registerTileEntity(FirestarterLogic.class, "Firestarter"); + GameRegistry.registerTileEntity(AdvancedDrawbridgeLogic.class, "AdvDrawbridge"); //Traps landmine = new BlockLandmine(PHConstruct.landmine).setHardness(0.5F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setCreativeTab(CreativeTabs.tabRedstone) diff --git a/src/tconstruct/common/TProxyCommon.java b/src/tconstruct/common/TProxyCommon.java index d0885ecd..a8e80d3b 100644 --- a/src/tconstruct/common/TProxyCommon.java +++ b/src/tconstruct/common/TProxyCommon.java @@ -31,6 +31,7 @@ public class TProxyCommon implements IGuiHandler public static int drawbridgeID = 9; public static int landmineID = 10; public static int craftingStationID = 11; + public static int advDrawbridgeID = 12; public static int inventoryGui = 100; public static int armorGuiID = 101; public static int knapsackGuiID = 102; diff --git a/src/tconstruct/inventory/AdvancedDrawbridgeContainer.java b/src/tconstruct/inventory/AdvancedDrawbridgeContainer.java index 2b8d9756..1696b35b 100644 --- a/src/tconstruct/inventory/AdvancedDrawbridgeContainer.java +++ b/src/tconstruct/inventory/AdvancedDrawbridgeContainer.java @@ -1,78 +1,78 @@ -//package tconstruct.inventory; -// -//import net.minecraft.entity.player.*; -//import net.minecraft.inventory.*; -//import net.minecraft.item.ItemStack; -//import tconstruct.blocks.logic.*; -// -//public class AdvancedDrawbridgeContainer extends Container -//{ -// public AdvancedDrawbridgeLogic logic; -// public int progress = 0; -// public int fuel = 0; -// public int fuelGague = 0; -// -// public AdvancedDrawbridgeContainer(InventoryPlayer inventoryplayer, AdvancedDrawbridgeLogic logic) -// { -// this.logic = logic; -// +package tconstruct.inventory; + +import net.minecraft.entity.player.*; +import net.minecraft.inventory.*; +import net.minecraft.item.ItemStack; +import tconstruct.blocks.logic.*; + +public class AdvancedDrawbridgeContainer extends Container +{ + public AdvancedDrawbridgeLogic logic; + public int progress = 0; + public int fuel = 0; + public int fuelGague = 0; + + public AdvancedDrawbridgeContainer(InventoryPlayer inventoryplayer, AdvancedDrawbridgeLogic logic) + { + this.logic = logic; + // this.addSlotToContainer(new DrawbridgeSlot(logic, logic.selSlot < logic.getSizeInventory() ? logic.selSlot : 0, 80, 36, logic)); -// this.addSlotToContainer(new SlotOpaqueBlocksOnly(logic, 1, 35, 36)); -// -// /* Player inventory */ -// for (int column = 0; column < 3; column++) -// { -// for (int row = 0; row < 9; row++) -// { -// this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); -// } -// } -// -// for (int column = 0; column < 9; column++) -// { -// this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); -// } -// } -// -// @Override -// public boolean canInteractWith (EntityPlayer entityplayer) -// { -// return logic.isUseableByPlayer(entityplayer); -// } -// -// @Override -// public ItemStack transferStackInSlot (EntityPlayer player, int slotID) -// { -// ItemStack stack = null; -// Slot slot = (Slot) this.inventorySlots.get(slotID); -// -// if (slot != null && slot.getHasStack()) -// { -// ItemStack slotStack = slot.getStack(); -// stack = slotStack.copy(); -// -// if (slotID < logic.getSizeInventory()) -// { -// if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) -// { -// return null; -// } -// } -// else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) -// { -// return null; -// } -// -// if (slotStack.stackSize == 0) -// { -// slot.putStack((ItemStack) null); -// } -// else -// { -// slot.onSlotChanged(); -// } -// } -// -// return stack; -// } -//} + this.addSlotToContainer(new SlotOpaqueBlocksOnly(logic.camoInventory, 0, 35, 36)); + + /* Player inventory */ + for (int column = 0; column < 3; column++) + { + for (int row = 0; row < 9; row++) + { + this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18)); + } + } + + for (int column = 0; column < 9; column++) + { + this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142)); + } + } + + @Override + public boolean canInteractWith (EntityPlayer entityplayer) + { + return logic.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot (EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); + + if (slotID < logic.getSizeInventory()) + { + if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + } + + return stack; + } +} diff --git a/src/tconstruct/items/blocks/RedstoneMachineItem.java b/src/tconstruct/items/blocks/RedstoneMachineItem.java index 75ce50c9..dd7faa6e 100644 --- a/src/tconstruct/items/blocks/RedstoneMachineItem.java +++ b/src/tconstruct/items/blocks/RedstoneMachineItem.java @@ -10,7 +10,7 @@ import net.minecraft.util.MathHelper; public class RedstoneMachineItem extends ItemBlock { - public static final String blockType[] = { "drawbridge", "firestarter" }; + public static final String blockType[] = { "drawbridge", "firestarter", "advdrawbridge" }; public RedstoneMachineItem(int id) { diff --git a/src/tconstruct/library/blocks/ExpandableInventoryLogic.java b/src/tconstruct/library/blocks/ExpandableInventoryLogic.java index 642ee5b1..5bc13e71 100644 --- a/src/tconstruct/library/blocks/ExpandableInventoryLogic.java +++ b/src/tconstruct/library/blocks/ExpandableInventoryLogic.java @@ -1,6 +1,6 @@ package tconstruct.library.blocks; -import java.util.ArrayList; +import java.util.*; import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.item.ItemStack; @@ -13,7 +13,7 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements super(0); } - protected ArrayList inventory; + protected ArrayList inventory = new ArrayList(); protected String invName; @Override @@ -151,6 +151,15 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements return this.invName != null && this.invName.length() > 0; } + public void cleanInventory(){ + Iterator i1 = inventory.iterator(); + while(i1.hasNext()){ + if(i1.next() == null){ + i1.remove(); + } + } + } + @Override public boolean isItemValidForSlot(int slot, ItemStack itemstack) { if (slot < getSizeInventory()) {