From ba8feb526da0a1ce15a179e1e5ee44582f769768 Mon Sep 17 00:00:00 2001 From: Lance5057 Date: Fri, 18 Mar 2016 06:14:33 -0500 Subject: Added modifiers, beautified code --- .../finishingAnvil/Container_FinishingAnvil.java | 20 +- .../blocks/finishingAnvil/FinishingAnvil.java | 246 ++++++++++---------- .../blocks/finishingAnvil/Gui_FinishingAnvil.java | 258 +++++++++++---------- .../blocks/finishingAnvil/ModelFinishingAnvil.java | 98 ++++---- .../finishingAnvil/RenderItem_FinishingAnvil.java | 49 ++-- .../finishingAnvil/Renderer_FinishingAnvil.java | 47 ++-- .../finishingAnvil/TileEntity_FinishingAnvil.java | 127 +++++----- 7 files changed, 451 insertions(+), 394 deletions(-) (limited to 'src/main/java/lance5057/tDefense/finishingAnvil/blocks') diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Container_FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Container_FinishingAnvil.java index 499e81b..3b775f2 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Container_FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Container_FinishingAnvil.java @@ -11,23 +11,23 @@ public class Container_FinishingAnvil extends Container public Container_FinishingAnvil(InventoryPlayer inventoryPlayer, TileEntity_FinishingAnvil te) { addSlotToContainer(new Slot(te, 0, 48, 32)); - - for (int x = 0; x < 9; x++) + + for(int x = 0; x < 9; x++) { addSlotToContainer(new Slot(inventoryPlayer, x, 8 + 18 * x, 142)); } - - for (int y = 0; y < 3; y++) + + for(int y = 0; y < 3; y++) + { + for(int x = 0; x < 9; x++) { - for (int x = 0; x < 9; x++) - { - addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18)); - } + addSlotToContainer(new Slot(inventoryPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18)); } + } } - + @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) + public boolean canInteractWith(EntityPlayer p_75145_1_) { return true; } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/FinishingAnvil.java index b3bf540..e12586a 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/FinishingAnvil.java @@ -22,127 +22,139 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class FinishingAnvil extends BlockContainer { - public FinishingAnvil() { - super(Material.iron); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - @Override - public void onBlockAdded(World world, int i, int j, int k) - { - super.onBlockAdded(world, i, j, k); - world.markBlockForUpdate(i, j, k); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, - EntityPlayer player, int metadata, float what, float these, float are) { - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity == null || player.isSneaking()) { - return false; - } - //code to open gui explained later - player.openGui(TinkersDefense.instance, TinkersDefense.GUI_ANVIL_INV, player.worldObj, x, y, z); - return true; - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block par5, int par6) { - dropItems(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); - } - - private void dropItems(World world, int x, int y, int z){ - Random rand = new Random(); - - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) { - return; - } - IInventory inventory = (IInventory) tileEntity; - - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack item = inventory.getStackInSlot(i); - - if (item != null && item.stackSize > 0) { - float rx = rand.nextFloat() * 0.8F + 0.1F; - float ry = rand.nextFloat() * 0.8F + 0.1F; - float rz = rand.nextFloat() * 0.8F + 0.1F; - - EntityItem entityItem = new EntityItem(world, - x + rx, y + ry, z + rz, - new ItemStack(item.getItem(), item.stackSize, item.getItemDamage())); - - if (item.hasTagCompound()) { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); - } - - float factor = 0.05F; - entityItem.motionX = rand.nextGaussian() * factor; - entityItem.motionY = rand.nextGaussian() * factor + 0.2F; - entityItem.motionZ = rand.nextGaussian() * factor; - world.spawnEntityInWorld(entityItem); - item.stackSize = 0; - } - } -} +public class FinishingAnvil extends BlockContainer +{ + public FinishingAnvil() + { + super(Material.iron); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } - //You don't want the normal render type, or it wont render properly. - @Override - public int getRenderType() { - return -1; - } - - //It's not an opaque cube, so you need this. - @Override - public boolean isOpaqueCube() { - return false; - } - - //It's not a normal block, so you need this too. - public boolean renderAsNormalBlock() { - return false; - } - - //This is the icon to use for showing the block in your hand. - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("tinkersdefense:WIP"); - } + @Override + public void onBlockAdded(World world, int i, int j, int k) + { + super.onBlockAdded(world, i, j, k); + world.markBlockForUpdate(i, j, k); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are) + { + TileEntity tileEntity = world.getTileEntity(x, y, z); + if(tileEntity == null || player.isSneaking()) + { + return false; + } + //code to open gui explained later + player.openGui(TinkersDefense.instance, TinkersDefense.GUI_ANVIL_INV, player.worldObj, x, y, z); + return true; + } @Override - public TileEntity createNewTileEntity(World w, int md) { + public void breakBlock(World world, int x, int y, int z, Block par5, int par6) + { + dropItems(world, x, y, z); + super.breakBlock(world, x, y, z, par5, par6); + } + + private void dropItems(World world, int x, int y, int z) + { + Random rand = new Random(); + + TileEntity tileEntity = world.getTileEntity(x, y, z); + if(!(tileEntity instanceof IInventory)) + { + return; + } + IInventory inventory = (IInventory) tileEntity; + + for(int i = 0; i < inventory.getSizeInventory(); i++) + { + ItemStack item = inventory.getStackInSlot(i); + + if(item != null && item.stackSize > 0) + { + float rx = rand.nextFloat() * 0.8F + 0.1F; + float ry = rand.nextFloat() * 0.8F + 0.1F; + float rz = rand.nextFloat() * 0.8F + 0.1F; + + EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage())); + + if(item.hasTagCompound()) + { + entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); + } + + float factor = 0.05F; + entityItem.motionX = rand.nextGaussian() * factor; + entityItem.motionY = rand.nextGaussian() * factor + 0.2F; + entityItem.motionZ = rand.nextGaussian() * factor; + world.spawnEntityInWorld(entityItem); + item.stackSize = 0; + } + } + } + + //You don't want the normal render type, or it wont render properly. + @Override + public int getRenderType() + { + return -1; + } + + //It's not an opaque cube, so you need this. + @Override + public boolean isOpaqueCube() + { + return false; + } + + //It's not a normal block, so you need this too. + public boolean renderAsNormalBlock() + { + return false; + } + + //This is the icon to use for showing the block in your hand. + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("tinkersdefense:WIP"); + } + + @Override + public TileEntity createNewTileEntity(World w, int md) + { TileEntity_FinishingAnvil te = new TileEntity_FinishingAnvil(); - return te; + return te; } - + @Override - public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) - { - int j1 = p_149660_9_; - - if ((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) - { - j1 = 1; - } - - if ((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) - { - j1 = 2; - } - - if ((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) - { - j1 = 3; - } - - if ((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) - { - j1 = 4; - } - - return j1; - } + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_9_; + + if((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) + { + j1 = 1; + } + + if((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) + { + j1 = 2; + } + + if((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) + { + j1 = 3; + } + + if((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) + { + j1 = 4; + } + + return j1; + } } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Gui_FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Gui_FinishingAnvil.java index e36aab8..a4167bb 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Gui_FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Gui_FinishingAnvil.java @@ -17,41 +17,41 @@ import tconstruct.library.tools.ToolCore; public class Gui_FinishingAnvil extends GuiContainer { - private float xSize_lo; - private float ySize_lo; - - private ItemStack bigCopy; - private Boolean isNull = true; - private ItemStack editItem; - private RenderItem bigRender = new RenderItem_FinishingAnvil(this); - - public final TileEntity_FinishingAnvil inventory; - private ResourceLocation forGui; - - private int leftButtonPosX = 0; - private int leftButtonPosY = 0; - private int xLIcon_one, yLIcon_one; - private int xLIcon_two, yLIcon_two; - private int xLIcon_three, yLIcon_three; - private int leftSelect = 0; - - private int rightButtonPosX = 0; - private int rightButtonPosY = 2; - private int xRIcon_one, yRIcon_one; - private int xRIcon_two, yRIcon_two; - private int xRIcon_three, yRIcon_three; - - String[] renders; - - NBTTagCompound tags; - - private static final ResourceLocation iconLocation = new ResourceLocation("tinkersdefense", "textures/gui/finishinganvil.png"); + private float xSize_lo; + private float ySize_lo; + + private ItemStack bigCopy; + private Boolean isNull = true; + private ItemStack editItem; + private RenderItem bigRender = new RenderItem_FinishingAnvil(this); + + public final TileEntity_FinishingAnvil inventory; + private ResourceLocation forGui; + + private int leftButtonPosX = 0; + private int leftButtonPosY = 0; + private int xLIcon_one, yLIcon_one; + private int xLIcon_two, yLIcon_two; + private int xLIcon_three, yLIcon_three; + private int leftSelect = 0; + + private int rightButtonPosX = 0; + private int rightButtonPosY = 2; + private int xRIcon_one, yRIcon_one; + private int xRIcon_two, yRIcon_two; + private int xRIcon_three, yRIcon_three; + + String[] renders; + + NBTTagCompound tags; + + private static final ResourceLocation iconLocation = new ResourceLocation("tinkersdefense", "textures/gui/finishinganvil.png"); public Gui_FinishingAnvil(InventoryPlayer invPlayer, TileEntity_FinishingAnvil te) { super(new Container_FinishingAnvil(invPlayer, te)); this.inventory = te; - + renders = new String[4]; renders[0] = "Head"; renders[1] = "Accessory"; @@ -63,20 +63,20 @@ public class Gui_FinishingAnvil extends GuiContainer public void initGui() { super.initGui(); - this.buttonList.add(new GuiButton(1 ,this.guiLeft+25, this.guiTop+10, 10, 10,"")); - this.buttonList.add(new GuiButton(2 ,this.guiLeft+25, this.guiTop+59, 10, 10,"")); - this.buttonList.add(new GuiButton(3 ,this.guiLeft+47, this.guiTop+49, 18, 18,"")); - - this.buttonList.add(new GuiButton(4 ,this.guiLeft+5, this.guiTop+10, 20, 20,"")); - this.buttonList.add(new GuiButton(5 ,this.guiLeft+5, this.guiTop+30, 20, 20,"")); - this.buttonList.add(new GuiButton(6 ,this.guiLeft+5, this.guiTop+50, 20, 20,"")); - - this.buttonList.add(new GuiButton(7 ,this.guiLeft+120, this.guiTop+10, 10, 10,"")); - this.buttonList.add(new GuiButton(8 ,this.guiLeft+120, this.guiTop+59, 10, 10,"")); - - this.buttonList.add(new GuiButton(9 ,this.guiLeft+130, this.guiTop+10, 20, 20,"")); - this.buttonList.add(new GuiButton(10 ,this.guiLeft+130, this.guiTop+30, 20, 20,"")); - this.buttonList.add(new GuiButton(11 ,this.guiLeft+130, this.guiTop+50, 20, 20,"")); + this.buttonList.add(new GuiButton(1, this.guiLeft + 25, this.guiTop + 10, 10, 10, "")); + this.buttonList.add(new GuiButton(2, this.guiLeft + 25, this.guiTop + 59, 10, 10, "")); + this.buttonList.add(new GuiButton(3, this.guiLeft + 47, this.guiTop + 49, 18, 18, "")); + + this.buttonList.add(new GuiButton(4, this.guiLeft + 5, this.guiTop + 10, 20, 20, "")); + this.buttonList.add(new GuiButton(5, this.guiLeft + 5, this.guiTop + 30, 20, 20, "")); + this.buttonList.add(new GuiButton(6, this.guiLeft + 5, this.guiTop + 50, 20, 20, "")); + + this.buttonList.add(new GuiButton(7, this.guiLeft + 120, this.guiTop + 10, 10, 10, "")); + this.buttonList.add(new GuiButton(8, this.guiLeft + 120, this.guiTop + 59, 10, 10, "")); + + this.buttonList.add(new GuiButton(9, this.guiLeft + 130, this.guiTop + 10, 20, 20, "")); + this.buttonList.add(new GuiButton(10, this.guiLeft + 130, this.guiTop + 30, 20, 20, "")); + this.buttonList.add(new GuiButton(11, this.guiLeft + 130, this.guiTop + 50, 20, 20, "")); } @@ -84,91 +84,111 @@ public class Gui_FinishingAnvil extends GuiContainer protected void actionPerformed(GuiButton button) { if(tags != null) - switch(button.id) - { - case 1: if(this.leftButtonPosX > 0) this.leftButtonPosX--; break; - case 2: if(this.leftButtonPosX+2 < ((ToolCore)bigCopy.getItem()).getPartAmount()) this.leftButtonPosX++; break; - - case 3: - TinkersDefense.INSTANCE.sendToServer(new Message_FinishingAnvil(inventory.xCoord, inventory.yCoord, inventory.zCoord, this.bigCopy)); - break; - - case 4: leftSelect = 0; rightButtonPosY = 2; break; - case 5: leftSelect = 1; rightButtonPosY = 3; break; - case 6: leftSelect = 2; rightButtonPosY = 4; break; - - case 7: if(this.rightButtonPosX > 0) this.rightButtonPosX--; break; - case 8: this.rightButtonPosX++; break; - - case 9: - if(tags.hasKey("Render"+renders[leftSelect])) + switch(button.id) { - tags.setInteger("Render"+renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX) * TinkersDefense.config.MaterialIndex)); - if(rightButtonPosX > 0) - tags.setInteger(renders[leftSelect]+"Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); - else - tags.removeTag(renders[leftSelect]+"Color"); - } - break; - - case 10: - if(tags.hasKey("Render"+renders[leftSelect])) - { - tags.setInteger("Render"+renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX + 1) * TinkersDefense.config.MaterialIndex)); - tags.setInteger(renders[leftSelect]+"Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); - } - break; - - case 11: - if(tags.hasKey("Render"+renders[leftSelect])) - { - tags.setInteger("Render"+renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX + 2) * TinkersDefense.config.MaterialIndex)); - tags.setInteger(renders[leftSelect]+"Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); + case 1: + if(this.leftButtonPosX > 0) + this.leftButtonPosX--; + break; + case 2: + if(this.leftButtonPosX + 2 < ((ToolCore) bigCopy.getItem()).getPartAmount()) + this.leftButtonPosX++; + break; + + case 3: + TinkersDefense.INSTANCE.sendToServer(new Message_FinishingAnvil(inventory.xCoord, inventory.yCoord, inventory.zCoord, this.bigCopy)); + break; + + case 4: + leftSelect = 0; + rightButtonPosY = 2; + break; + case 5: + leftSelect = 1; + rightButtonPosY = 3; + break; + case 6: + leftSelect = 2; + rightButtonPosY = 4; + break; + + case 7: + if(this.rightButtonPosX > 0) + this.rightButtonPosX--; + break; + case 8: + this.rightButtonPosX++; + break; + + case 9: + if(tags.hasKey("Render" + renders[leftSelect])) + { + tags.setInteger("Render" + renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX) * TinkersDefense.config.MaterialIndex)); + if(rightButtonPosX > 0) + tags.setInteger(renders[leftSelect] + "Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); + else + tags.removeTag(renders[leftSelect] + "Color"); + } + break; + + case 10: + if(tags.hasKey("Render" + renders[leftSelect])) + { + tags.setInteger("Render" + renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX + 1) * TinkersDefense.config.MaterialIndex)); + tags.setInteger(renders[leftSelect] + "Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); + } + break; + + case 11: + if(tags.hasKey("Render" + renders[leftSelect])) + { + tags.setInteger("Render" + renders[leftSelect], bigCopy.getTagCompound().getCompoundTag("InfiTool").getInteger(renders[leftSelect]) + ((rightButtonPosX + 2) * TinkersDefense.config.MaterialIndex)); + tags.setInteger(renders[leftSelect] + "Color", TConstructRegistry.getMaterial(tags.getInteger(renders[leftSelect])).primaryColor()); + } + break; } - break; - } } + public void drawScreen(int par1, int par2, float par3) { - - + if(inventory.getStackInSlot(0) != null && isNull == true - /*inventory.getStackInSlot(0).getItem() != this.bigCopy*/) + /*inventory.getStackInSlot(0).getItem() != this.bigCopy*/) { - this.bigCopy = inventory.getStackInSlot(0).copy(); - if(bigCopy.hasTagCompound() && bigCopy.getTagCompound().hasKey("InfiTool")) - tags = bigCopy.getTagCompound().getCompoundTag("InfiTool"); - isNull = false; + this.bigCopy = inventory.getStackInSlot(0).copy(); + if(bigCopy.hasTagCompound() && bigCopy.getTagCompound().hasKey("InfiTool")) + tags = bigCopy.getTagCompound().getCompoundTag("InfiTool"); + isNull = false; } else if(inventory.getStackInSlot(0) == null) { this.bigCopy = null; isNull = true; } - + super.drawScreen(par1, par2, par3); - this.xSize_lo = (float)par1; - this.ySize_lo = (float)par2; + this.xSize_lo = (float) par1; + this.ySize_lo = (float) par2; } protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.forGui = new ResourceLocation("tinkersdefense", "textures/gui/finishinganvil.png"); - + this.xLIcon_one = 0; this.yLIcon_one = 176; this.xLIcon_two = 0; this.yLIcon_two = 176; this.xLIcon_three = 0; this.yLIcon_three = 176; - + this.xRIcon_one = 0; this.yRIcon_one = 176; this.xRIcon_two = 0; this.yRIcon_two = 176; this.xRIcon_three = 0; this.yRIcon_three = 176; - + if(inventory.getStackInSlot(0) != null) { editItem = inventory.getStackInSlot(0); @@ -176,16 +196,16 @@ public class Gui_FinishingAnvil extends GuiContainer { //this.drawTexturedModelRectFromIcon(this.guiLeft+4, this.guiTop+14, // ((ToolCore)this.inventorySlots.inventorySlots.get(0)).getHeadItem(), 16, 16); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.forGui = new ResourceLocation("tinkersdefense","textures/gui/"+((ToolCore)editItem.getItem()).getDefaultFolder()+".png"); + this.forGui = new ResourceLocation("tinkersdefense", "textures/gui/" + ((ToolCore) editItem.getItem()).getDefaultFolder() + ".png"); this.xLIcon_one = 32; this.yLIcon_one = 0; this.xLIcon_two = 48; this.yLIcon_two = 0; this.xLIcon_three = 64; this.yLIcon_three = 0; - + this.xRIcon_one = 0; this.yRIcon_one = 0; this.xRIcon_two = 16; @@ -194,34 +214,34 @@ public class Gui_FinishingAnvil extends GuiContainer this.yRIcon_three = 0; } } - + this.mc.getTextureManager().bindTexture(this.forGui); if(inventory.getStackInSlot(0) != null) - this.drawTexturedModalRect(7,12 + (leftSelect * 20),16,0,16,16); - - this.drawTexturedModalRect(7,12,this.xLIcon_one+(this.leftButtonPosX*16),this.yLIcon_one+(this.leftButtonPosY*16),16,16); - this.drawTexturedModalRect(7,32,this.xLIcon_two+(this.leftButtonPosX*16),this.yLIcon_two+(this.leftButtonPosY*16),16,16); - this.drawTexturedModalRect(7,52,this.xLIcon_three+(this.leftButtonPosX*16),this.yLIcon_three+(this.leftButtonPosY*16),16,16); - - this.drawTexturedModalRect(132,12,this.xRIcon_one+(this.rightButtonPosX*16),this.yRIcon_one+(this.rightButtonPosY*16),16,16); - this.drawTexturedModalRect(132,32,this.xRIcon_two+(this.rightButtonPosX*16),this.yRIcon_two+(this.rightButtonPosY*16),16,16); - this.drawTexturedModalRect(132,52,this.xRIcon_three+(this.rightButtonPosX*16),this.yRIcon_three+(this.rightButtonPosY*16),16,16); - + this.drawTexturedModalRect(7, 12 + (leftSelect * 20), 16, 0, 16, 16); + + this.drawTexturedModalRect(7, 12, this.xLIcon_one + (this.leftButtonPosX * 16), this.yLIcon_one + (this.leftButtonPosY * 16), 16, 16); + this.drawTexturedModalRect(7, 32, this.xLIcon_two + (this.leftButtonPosX * 16), this.yLIcon_two + (this.leftButtonPosY * 16), 16, 16); + this.drawTexturedModalRect(7, 52, this.xLIcon_three + (this.leftButtonPosX * 16), this.yLIcon_three + (this.leftButtonPosY * 16), 16, 16); + + this.drawTexturedModalRect(132, 12, this.xRIcon_one + (this.rightButtonPosX * 16), this.yRIcon_one + (this.rightButtonPosY * 16), 16, 16); + this.drawTexturedModalRect(132, 32, this.xRIcon_two + (this.rightButtonPosX * 16), this.yRIcon_two + (this.rightButtonPosY * 16), 16, 16); + this.drawTexturedModalRect(132, 52, this.xRIcon_three + (this.rightButtonPosX * 16), this.yRIcon_three + (this.rightButtonPosY * 16), 16, 16); + bigRender.renderItemAndEffectIntoGUI(fontRendererObj, this.mc.getTextureManager(), bigCopy, 23, 5); } protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - int k = ((this.width - this.xSize) / 2); - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize+80, this.ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + int k = ((this.width - this.xSize) / 2); + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize + 80, this.ySize); } - + protected void injectIcons() { - + } } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/ModelFinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/ModelFinishingAnvil.java index b261efc..cf7253a 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/ModelFinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/ModelFinishingAnvil.java @@ -8,54 +8,58 @@ import net.minecraft.entity.Entity; * Armor Anvil - lance5057 * Created using Tabula 4.1.1 */ -public class ModelFinishingAnvil extends ModelBase { - public ModelRenderer Log; - public ModelRenderer HammerHead; - public ModelRenderer HammerHandle; - public ModelRenderer AnvilBase; - public ModelRenderer AnvilStem; - public ModelRenderer AnvilTop; +public class ModelFinishingAnvil extends ModelBase +{ + public ModelRenderer Log; + public ModelRenderer HammerHead; + public ModelRenderer HammerHandle; + public ModelRenderer AnvilBase; + public ModelRenderer AnvilStem; + public ModelRenderer AnvilTop; - public ModelFinishingAnvil() { - this.textureWidth = 64; - this.textureHeight = 64; - this.AnvilTop = new ModelRenderer(this, 0, 22); - this.AnvilTop.setRotationPoint(-4.0F, 6.0F, -6.0F); - this.AnvilTop.addBox(0.0F, 0.0F, 0.0F, 8, 6, 12, 0.0F); - this.HammerHead = new ModelRenderer(this, 15, 21); - this.HammerHead.setRotationPoint(-1.3F, 4.0F, 0.0F); - this.HammerHead.addBox(0.0F, 0.0F, 0.0F, 3, 2, 2, 0.0F); - this.setRotateAngle(HammerHead, 0.091106186954104F, -0.5462880558742251F, 0.0F); - this.AnvilStem = new ModelRenderer(this, 10, 32); - this.AnvilStem.setRotationPoint(-2.0F, 12.0F, -3.0F); - this.AnvilStem.addBox(0.0F, 0.0F, 0.0F, 4, 2, 6, 0.0F); - this.HammerHandle = new ModelRenderer(this, 17, 47); - this.HammerHandle.setRotationPoint(1.0F, 0.5F, -6.0F); - this.HammerHandle.addBox(0.0F, 0.0F, 0.0F, 1, 1, 6, 0.0F); - this.AnvilBase = new ModelRenderer(this, 2, 28); - this.AnvilBase.setRotationPoint(-4.0F, 14.0F, -5.0F); - this.AnvilBase.addBox(0.0F, 0.0F, 0.0F, 8, 2, 10, 0.0F); - this.Log = new ModelRenderer(this, 0, 40); - this.Log.setRotationPoint(-8.0F, 16.0F, -8.0F); - this.Log.addBox(0.0F, 0.0F, 0.0F, 16, 8, 16, 0.0F); - this.HammerHead.addChild(this.HammerHandle); - } + public ModelFinishingAnvil() + { + this.textureWidth = 64; + this.textureHeight = 64; + this.AnvilTop = new ModelRenderer(this, 0, 22); + this.AnvilTop.setRotationPoint(-4.0F, 6.0F, -6.0F); + this.AnvilTop.addBox(0.0F, 0.0F, 0.0F, 8, 6, 12, 0.0F); + this.HammerHead = new ModelRenderer(this, 15, 21); + this.HammerHead.setRotationPoint(-1.3F, 4.0F, 0.0F); + this.HammerHead.addBox(0.0F, 0.0F, 0.0F, 3, 2, 2, 0.0F); + this.setRotateAngle(HammerHead, 0.091106186954104F, -0.5462880558742251F, 0.0F); + this.AnvilStem = new ModelRenderer(this, 10, 32); + this.AnvilStem.setRotationPoint(-2.0F, 12.0F, -3.0F); + this.AnvilStem.addBox(0.0F, 0.0F, 0.0F, 4, 2, 6, 0.0F); + this.HammerHandle = new ModelRenderer(this, 17, 47); + this.HammerHandle.setRotationPoint(1.0F, 0.5F, -6.0F); + this.HammerHandle.addBox(0.0F, 0.0F, 0.0F, 1, 1, 6, 0.0F); + this.AnvilBase = new ModelRenderer(this, 2, 28); + this.AnvilBase.setRotationPoint(-4.0F, 14.0F, -5.0F); + this.AnvilBase.addBox(0.0F, 0.0F, 0.0F, 8, 2, 10, 0.0F); + this.Log = new ModelRenderer(this, 0, 40); + this.Log.setRotationPoint(-8.0F, 16.0F, -8.0F); + this.Log.addBox(0.0F, 0.0F, 0.0F, 16, 8, 16, 0.0F); + this.HammerHead.addChild(this.HammerHandle); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { - this.AnvilTop.render(f5); - this.HammerHead.render(f5); - this.AnvilStem.render(f5); - this.AnvilBase.render(f5); - this.Log.render(f5); - } + @Override + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + this.AnvilTop.render(f5); + this.HammerHead.render(f5); + this.AnvilStem.render(f5); + this.AnvilBase.render(f5); + this.Log.render(f5); + } - /** - * This is a helper function from Tabula to set the rotation of model parts - */ - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + /** + * This is a helper function from Tabula to set the rotation of model parts + */ + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) + { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/RenderItem_FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/RenderItem_FinishingAnvil.java index 8fc450b..0515740 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/RenderItem_FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/RenderItem_FinishingAnvil.java @@ -11,33 +11,34 @@ import org.lwjgl.opengl.GL11; public class RenderItem_FinishingAnvil extends RenderItem { - private Gui_FinishingAnvil anvilGui; + private Gui_FinishingAnvil anvilGui; + RenderItem_FinishingAnvil(Gui_FinishingAnvil gui) { super(); anvilGui = gui; } - - @Override - public void renderItemAndEffectIntoGUI(FontRenderer fontRenderer, TextureManager textureManager, ItemStack itemStack, int x, int y) - { - if (itemStack == null) - { - return; - } - - RenderHelper.enableGUIStandardItemLighting(); - - Slot slot = anvilGui.inventorySlots.getSlotFromInventory(anvilGui.inventory, 0); - - if(slot.getStack() != null) - { - GL11.glPushMatrix(); - - GL11.glScalef(3.0f,3.0f,1.0f); - super.renderItemAndEffectIntoGUI(fontRenderer, textureManager, itemStack, x, y); - - GL11.glPopMatrix(); - } - } + + @Override + public void renderItemAndEffectIntoGUI(FontRenderer fontRenderer, TextureManager textureManager, ItemStack itemStack, int x, int y) + { + if(itemStack == null) + { + return; + } + + RenderHelper.enableGUIStandardItemLighting(); + + Slot slot = anvilGui.inventorySlots.getSlotFromInventory(anvilGui.inventory, 0); + + if(slot.getStack() != null) + { + GL11.glPushMatrix(); + + GL11.glScalef(3.0f, 3.0f, 1.0f); + super.renderItemAndEffectIntoGUI(fontRenderer, textureManager, itemStack, x, y); + + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Renderer_FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Renderer_FinishingAnvil.java index 06ac9ed..db95e9f 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Renderer_FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/Renderer_FinishingAnvil.java @@ -10,34 +10,35 @@ import org.lwjgl.opengl.GL11; public class Renderer_FinishingAnvil extends TileEntitySpecialRenderer { - private final ModelFinishingAnvil model; - - public Renderer_FinishingAnvil() { - this.model = new ModelFinishingAnvil(); -} - + private final ModelFinishingAnvil model; + + public Renderer_FinishingAnvil() + { + this.model = new ModelFinishingAnvil(); + } + @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { GL11.glPushMatrix(); - - GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - - ResourceLocation textures = (new ResourceLocation("tinkersdefense:textures/blocks/ArmorAnvil.png")); - - Minecraft.getMinecraft().renderEngine.bindTexture(textures); - - GL11.glPushMatrix(); - - int meta = te.getBlockMetadata(); - - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - - this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - + + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + + ResourceLocation textures = (new ResourceLocation("tinkersdefense:textures/blocks/ArmorAnvil.png")); + + Minecraft.getMinecraft().renderEngine.bindTexture(textures); + + GL11.glPushMatrix(); + + int meta = te.getBlockMetadata(); + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + + this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/TileEntity_FinishingAnvil.java b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/TileEntity_FinishingAnvil.java index 7148e03..3e68d51 100644 --- a/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/TileEntity_FinishingAnvil.java +++ b/src/main/java/lance5057/tDefense/finishingAnvil/blocks/finishingAnvil/TileEntity_FinishingAnvil.java @@ -13,55 +13,60 @@ import net.minecraftforge.common.util.Constants; public class TileEntity_FinishingAnvil extends TileEntity implements IInventory { - public static int invSize = 1; - public ItemStack[] inventory; - - private final String name = "Anvil Inventory"; - + public static int invSize = 1; + public ItemStack[] inventory; + + private final String name = "Anvil Inventory"; + public TileEntity_FinishingAnvil() { super(); inventory = new ItemStack[invSize]; } - + @Override public void updateEntity() { super.updateEntity(); } - + @Override - public Packet getDescriptionPacket() { - NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag); + public Packet getDescriptionPacket() + { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag); } - + @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { - readFromNBT(pkt.func_148857_g()); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { + readFromNBT(pkt.func_148857_g()); } - + @Override - public int getSizeInventory() { + public int getSizeInventory() + { return invSize; } @Override - public ItemStack getStackInSlot(int slot) { + public ItemStack getStackInSlot(int slot) + { return inventory[slot]; } @Override - public ItemStack decrStackSize(int slot, int amount) { + public ItemStack decrStackSize(int slot, int amount) + { ItemStack stack = getStackInSlot(slot); - if (stack != null) + if(stack != null) { - if (stack.stackSize > amount) + if(stack.stackSize > amount) { stack = stack.splitStack(amount); - - if (stack.stackSize == 0) + + if(stack.stackSize == 0) { setInventorySlotContents(slot, null); } @@ -70,17 +75,18 @@ public class TileEntity_FinishingAnvil extends TileEntity implements IInventory { setInventorySlotContents(slot, null); } - + this.markDirty(); } return stack; } @Override - public ItemStack getStackInSlotOnClosing(int slot) { + public ItemStack getStackInSlotOnClosing(int slot) + { ItemStack stack = getStackInSlot(slot); - - if (stack != null) + + if(stack != null) { setInventorySlotContents(slot, stack); } @@ -88,82 +94,95 @@ public class TileEntity_FinishingAnvil extends TileEntity implements IInventory } @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) { + public void setInventorySlotContents(int slot, ItemStack itemstack) + { this.inventory[slot] = itemstack; - if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) + if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { - itemstack.stackSize = this.getInventoryStackLimit(); + itemstack.stackSize = this.getInventoryStackLimit(); } - this.markDirty(); + this.markDirty(); } @Override - public String getInventoryName() { + public String getInventoryName() + { return name; } @Override - public boolean hasCustomInventoryName() { + public boolean hasCustomInventoryName() + { return name.length() > 0; } @Override - public int getInventoryStackLimit() { + public int getInventoryStackLimit() + { return 1; } @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) + { return true; } @Override - public void openInventory() { - + public void openInventory() + { + } @Override - public void closeInventory() { - + public void closeInventory() + { + } @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) + { return true; } - + @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); - writeInventoryToNBT(compound); + writeInventoryToNBT(compound); } - + @Override - public void readFromNBT(NBTTagCompound compound) - { + public void readFromNBT(NBTTagCompound compound) + { super.readFromNBT(compound); - readInventoryFromNBT(compound); - } - - public void readInventoryFromNBT(NBTTagCompound tags) { + readInventoryFromNBT(compound); + } + + public void readInventoryFromNBT(NBTTagCompound tags) + { NBTTagList nbttaglist = tags.getTagList("Items", Constants.NBT.TAG_COMPOUND); - for (int iter = 0; iter < nbttaglist.tagCount(); iter++) { + for(int iter = 0; iter < nbttaglist.tagCount(); iter++) + { NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter); byte slotID = tagList.getByte("Slot"); - if (slotID >= 0 && slotID < inventory.length) { + if(slotID >= 0 && slotID < inventory.length) + { inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); } } } - -public void writeInventoryToNBT(NBTTagCompound tags) { + public void writeInventoryToNBT(NBTTagCompound tags) + { NBTTagList nbttaglist = new NBTTagList(); - for (int iter = 0; iter < inventory.length; iter++) { - if (inventory[iter] != null) { + for(int iter = 0; iter < inventory.length; iter++) + { + if(inventory[iter] != null) + { NBTTagCompound tagList = new NBTTagCompound(); tagList.setByte("Slot", (byte) iter); inventory[iter].writeToNBT(tagList); -- cgit v1.2.3