From 4f7ad220df0438b6f3382110577b53f29da46453 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 24 May 2018 15:50:07 -0400 Subject: Update of all changes --- .../tileentity/TileEntityBlockShadow.java | 164 ++-- .../jewelrycraft/tileentity/TileEntityCrystal.java | 59 +- .../tileentity/TileEntityDisplayer.java | 255 ++++--- .../tileentity/TileEntityHandPedestal.java | 53 +- .../tileentity/TileEntityJewelrsCraftingTable.java | 382 +++++----- .../tileentity/TileEntityMidasTouch.java | 138 ++-- .../jewelrycraft/tileentity/TileEntityMolder.java | 271 +++---- .../tileentity/TileEntityMoltenMetal.java | 20 +- .../tileentity/TileEntityShadowEye.java | 839 +++++++++++++-------- .../tileentity/TileEntityShadowHand.java | 4 +- .../jewelrycraft/tileentity/TileEntitySmelter.java | 386 +++++----- .../renders/TileEntityDisplayerRender.java | 323 ++++---- .../renders/TileEntityHandPedestalRender.java | 73 +- .../TileEntityJewelrsCraftingTableRender.java | 259 ++++--- .../renders/TileEntityMidasTouchRender.java | 50 +- .../tileentity/renders/TileEntityMolderRender.java | 248 +++--- .../renders/TileEntityShadowEyeRender.java | 171 +++-- .../renders/TileEntityShadowHandRender.java | 22 +- .../renders/TileEntitySmelterRender.java | 220 +++--- 19 files changed, 2173 insertions(+), 1764 deletions(-) mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java (limited to 'src/main/java/darkknight/jewelrycraft/tileentity') diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java old mode 100644 new mode 100755 index b16ce31..b17047e --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java @@ -8,81 +8,91 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.EnumSkyBlock; -public class TileEntityBlockShadow extends TileEntity -{ - public int metadata; - - /** - * - */ - public TileEntityBlockShadow() - { - metadata = -1; - } - - /** - * @param nbt - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("metadata", metadata); - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - metadata = nbt.getInteger("metadata"); - } - - /** - * - */ - @Override - public void updateEntity() - { - super.updateEntity(); - int blockLight, realLight; - int lightValue = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted; - float sunPosAngle = worldObj.getCelestialAngleRadians(1.0F); - if (sunPosAngle < (float)Math.PI) sunPosAngle += (0.0F - sunPosAngle) * 0.2F; - else sunPosAngle += ((float)Math.PI * 2F - sunPosAngle) * 0.2F; - lightValue = Math.round(lightValue * MathHelper.cos(sunPosAngle)); - if (lightValue < 0) lightValue = 0; - if (lightValue > 15) lightValue = 15; - blockLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getSavedLightValue(EnumSkyBlock.Block, xCoord & 15, yCoord, zCoord & 15); - realLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getBlockLightValue(xCoord & 15, yCoord, zCoord & 15, 0); - if (blockLight == 0 && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) || lightValue >= blockLight) metadata = 15 - lightValue; - else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) metadata = 15 - realLight; - else if (lightValue < blockLight) metadata = 15 - blockLight; - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 2); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntityBlockShadow extends TileEntity { + public int metadata; + + /** + * + */ + public TileEntityBlockShadow() { + metadata = -1; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("metadata", metadata); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + metadata = nbt.getInteger("metadata"); + } + + /** + * + */ + @Override + public void updateEntity() { + super.updateEntity(); + int blockLight, realLight; + int lightValue = worldObj.getSavedLightValue(EnumSkyBlock.Sky, + xCoord, yCoord, zCoord) - worldObj.skylightSubtracted; + float sunPosAngle = worldObj.getCelestialAngleRadians(1.0F); + if (sunPosAngle < (float) Math.PI) + sunPosAngle += (0.0F - sunPosAngle) * 0.2F; + else + sunPosAngle += ((float) Math.PI * 2F - sunPosAngle) * 0.2F; + lightValue = Math.round(lightValue * MathHelper.cos(sunPosAngle)); + if (lightValue < 0) + lightValue = 0; + if (lightValue > 15) + lightValue = 15; + blockLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord) + .getSavedLightValue(EnumSkyBlock.Block, xCoord & 15, + yCoord, zCoord & 15); + realLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord) + .getBlockLightValue(xCoord & 15, yCoord, zCoord & 15, 0); + if (blockLight == 0 + && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) + || lightValue >= blockLight) + metadata = 15 - lightValue; + else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) + metadata = 15 - realLight; + else if (lightValue < blockLight) + metadata = 15 - blockLight; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, + metadata, 2); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, + worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java old mode 100644 new mode 100755 index c7ca018..46288b4 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityCrystal.java @@ -9,34 +9,35 @@ import net.minecraft.tileentity.TileEntity; /** * @author Sorin */ -public class TileEntityCrystal extends TileEntity -{ - public int shine = 120; - boolean descent = false; - int timer = 0; - - @Override - public void updateEntity() - { - if (ConfigHandler.CRYSTAL_GLOW){ - timer++; - if (timer > 20){ - if (shine < 230 && !descent){ - shine += 2; - if (shine >= 230) descent = true; - }else if (shine > 100 && descent){ - shine -= 2; - if (shine <= 100) descent = false; - } - this.worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - timer = 0; - } - } - } - - public boolean canUpdate() - { - return ConfigHandler.CRYSTAL_GLOW; - } +public class TileEntityCrystal extends TileEntity { + public int shine = 120; + boolean descent = false; + int timer = 0; + + @Override + public void updateEntity() { + if (ConfigHandler.CRYSTAL_GLOW) { + timer++; + if (timer > 20) { + if (shine < 230 && !descent) { + shine += 2; + if (shine >= 230) + descent = true; + } else if (shine > 100 && descent) { + shine -= 2; + if (shine <= 100) + descent = false; + } + this.worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, + zCoord, xCoord, yCoord, zCoord); + timer = 0; + } + } + } + + @Override + public boolean canUpdate() { + return ConfigHandler.CRYSTAL_GLOW; + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java old mode 100644 new mode 100755 index c23ee15..a0c2600 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java @@ -8,126 +8,137 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TileEntityDisplayer extends TileEntity -{ - public float ringTranslation1, ringTranslation2, ringTranslation3, rotAngle; - public boolean isDescending1, isDescending2, isDescending3, isDirty, hasObject; - public ItemStack object; - public int quantity, infoIndex, timer = 0; - - /** - * - */ - public TileEntityDisplayer() - { - ringTranslation1 = 0.6f; - ringTranslation2 = 0.3f; - ringTranslation3 = 0.0f; - rotAngle = 0; - quantity = 0; - infoIndex = 1; - isDescending1 = false; - isDescending2 = false; - isDescending3 = false; - isDirty = false; - hasObject = false; - object = new ItemStack(Item.getItemById(0), 0, 0); - } - - /** - * @param nbt - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setFloat("translation1", ringTranslation1); - nbt.setFloat("translation2", ringTranslation2); - nbt.setFloat("translation3", ringTranslation3); - nbt.setFloat("angle", rotAngle); - nbt.setInteger("quantity", quantity); - nbt.setInteger("infoIndex", infoIndex); - nbt.setBoolean("descending1", isDescending1); - nbt.setBoolean("descending2", isDescending2); - nbt.setBoolean("descending3", isDescending3); - nbt.setBoolean("hasObject", hasObject); - NBTTagCompound tag = new NBTTagCompound(); - object.writeToNBT(tag); - nbt.setTag("object", tag); - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - ringTranslation1 = nbt.getFloat("translation1"); - ringTranslation2 = nbt.getFloat("translation2"); - ringTranslation3 = nbt.getFloat("translation3"); - rotAngle = nbt.getFloat("angle"); - quantity = nbt.getInteger("quantity"); - infoIndex = nbt.getInteger("infoIndex"); - isDescending1 = nbt.getBoolean("descending1"); - isDescending2 = nbt.getBoolean("descending2"); - isDescending3 = nbt.getBoolean("descending3"); - hasObject = nbt.getBoolean("hasObject"); - object = new ItemStack(Item.getItemById(0), 0, 0); - object.readFromNBT(nbt.getCompoundTag("object")); - } - - /** - * - */ - @Override - public void updateEntity() - { - super.updateEntity(); - if (isDirty){ - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = false; - } - if (ringTranslation1 >= 0.6) isDescending1 = true; - if (ringTranslation1 <= 0) isDescending1 = false; - if (!isDescending1) ringTranslation1 += 0.03; - if (isDescending1) ringTranslation1 -= 0.03; - if (ringTranslation2 >= 0.6) isDescending2 = true; - if (ringTranslation2 <= 0) isDescending2 = false; - if (!isDescending2) ringTranslation2 += 0.02; - if (isDescending2) ringTranslation2 -= 0.02; - if (ringTranslation3 >= 0.6) isDescending3 = true; - if (ringTranslation3 <= 0) isDescending3 = false; - if (!isDescending3) ringTranslation3 += 0.01; - if (isDescending3) ringTranslation3 -= 0.01; - if (rotAngle < 360F) rotAngle += 3F; - if (rotAngle >= 360F) rotAngle = 0F; - timer++; - if (timer >= 40){ - infoIndex++; - timer = 0; - } - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntityDisplayer extends TileEntity { + public float ringTranslation1, ringTranslation2, + ringTranslation3, rotAngle; + public boolean isDescending1, isDescending2, isDescending3, + isDirty, hasObject; + public ItemStack object; + public int quantity, infoIndex, timer = 0; + + /** + * + */ + public TileEntityDisplayer() { + ringTranslation1 = 0.6f; + ringTranslation2 = 0.3f; + ringTranslation3 = 0.0f; + rotAngle = 0; + quantity = 0; + infoIndex = 1; + isDescending1 = false; + isDescending2 = false; + isDescending3 = false; + isDirty = false; + hasObject = false; + object = new ItemStack(Item.getItemById(0), 0, 0); + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setFloat("translation1", ringTranslation1); + nbt.setFloat("translation2", ringTranslation2); + nbt.setFloat("translation3", ringTranslation3); + nbt.setFloat("angle", rotAngle); + nbt.setInteger("quantity", quantity); + nbt.setInteger("infoIndex", infoIndex); + nbt.setBoolean("descending1", isDescending1); + nbt.setBoolean("descending2", isDescending2); + nbt.setBoolean("descending3", isDescending3); + nbt.setBoolean("hasObject", hasObject); + NBTTagCompound tag = new NBTTagCompound(); + object.writeToNBT(tag); + nbt.setTag("object", tag); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + ringTranslation1 = nbt.getFloat("translation1"); + ringTranslation2 = nbt.getFloat("translation2"); + ringTranslation3 = nbt.getFloat("translation3"); + rotAngle = nbt.getFloat("angle"); + quantity = nbt.getInteger("quantity"); + infoIndex = nbt.getInteger("infoIndex"); + isDescending1 = nbt.getBoolean("descending1"); + isDescending2 = nbt.getBoolean("descending2"); + isDescending3 = nbt.getBoolean("descending3"); + hasObject = nbt.getBoolean("hasObject"); + object = new ItemStack(Item.getItemById(0), 0, 0); + object.readFromNBT(nbt.getCompoundTag("object")); + } + + /** + * + */ + @Override + public void updateEntity() { + super.updateEntity(); + if (isDirty) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (ringTranslation1 >= 0.6) + isDescending1 = true; + if (ringTranslation1 <= 0) + isDescending1 = false; + if (!isDescending1) + ringTranslation1 += 0.03; + if (isDescending1) + ringTranslation1 -= 0.03; + if (ringTranslation2 >= 0.6) + isDescending2 = true; + if (ringTranslation2 <= 0) + isDescending2 = false; + if (!isDescending2) + ringTranslation2 += 0.02; + if (isDescending2) + ringTranslation2 -= 0.02; + if (ringTranslation3 >= 0.6) + isDescending3 = true; + if (ringTranslation3 <= 0) + isDescending3 = false; + if (!isDescending3) + ringTranslation3 += 0.01; + if (isDescending3) + ringTranslation3 -= 0.01; + if (rotAngle < 360F) + rotAngle += 3F; + if (rotAngle >= 360F) + rotAngle = 0F; + timer++; + if (timer >= 40) { + infoIndex++; + timer = 0; + } + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java old mode 100644 new mode 100755 index e4a8602..c44cd88 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java @@ -24,8 +24,8 @@ public class TileEntityHandPedestal extends TileEntity { private boolean isHandOpen; /** - * - */ + * + */ public TileEntityHandPedestal() { isDirty = false; heldItemStack = null; @@ -55,14 +55,17 @@ public class TileEntityHandPedestal extends TileEntity { @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - if (tagCompound.hasKey("object", 10)) setHeldItemStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("object"))); - else removeHeldItemStack(); + if (tagCompound.hasKey("object", 10)) + setHeldItemStack(ItemStack.loadItemStackFromNBT( + tagCompound.getCompoundTag("object"))); + else + removeHeldItemStack(); isHandOpen = tagCompound.getBoolean("isHandOpen"); } /** - * - */ + * + */ @Override public void updateEntity() { super.updateEntity(); @@ -74,12 +77,14 @@ public class TileEntityHandPedestal extends TileEntity { } /** - * - */ + * + */ private void updateGrip() { prevGrip = grip; - if (grip > 0 && isHandOpen) grip -= 1 / gripScale; - else if (grip < gripMax && !isHandOpen) grip += 1 / gripScale; + if (grip > 0 && isHandOpen) + grip -= 1 / gripScale; + else if (grip < gripMax && !isHandOpen) + grip += 1 / gripScale; } /** @@ -89,7 +94,8 @@ public class TileEntityHandPedestal extends TileEntity { public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, + nbttagcompound); } /** @@ -97,14 +103,15 @@ public class TileEntityHandPedestal extends TileEntity { * @param packet */ @Override - public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + public void onDataPacket(NetworkManager networkManager, + S35PacketUpdateTileEntity packet) { readFromNBT(packet.func_148857_g()); worldObj.func_147479_m(xCoord, yCoord, zCoord); } /** - * - */ + * + */ @Override public void markDirty() { super.markDirty(); @@ -125,28 +132,30 @@ public class TileEntityHandPedestal extends TileEntity { if (heldItemStack != null && heldItemStack.getItem() != null) { heldItemStack.stackSize = 1; this.heldItemStack = heldItemStack; - if (heldItemStack.getItem() instanceof ItemBlock) gripScale = 0.5f; - else gripScale = 1; + if (heldItemStack.getItem() instanceof ItemBlock) + gripScale = 0.5f; + else + gripScale = 1; } } /** - * - */ + * + */ public void removeHeldItemStack() { heldItemStack = null; } /** - * - */ + * + */ public void openHand() { isHandOpen = true; } /** - * - */ + * + */ public void closeHand() { isHandOpen = false; } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java old mode 100644 new mode 100755 index 830da74..1b0ec8a --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -13,127 +13,143 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class TileEntityJewelrsCraftingTable extends TileEntity -{ - public boolean hasJewelry, hasEndItem, isDirty, hasGem, crafting; - public ItemStack jewelry, endItem, gem; - public int carving, effect; - public float angle; - - /** - * - */ - public TileEntityJewelrsCraftingTable() - { - jewelry = new ItemStack(Item.getItemById(0), 0, 0); - endItem = new ItemStack(Item.getItemById(0), 0, 0); - gem = new ItemStack(Item.getItemById(0), 0, 0); - hasJewelry = false; - hasEndItem = false; - hasGem = false; - crafting = false; - carving = 0; - effect = 0; - angle = 0; - isDirty = false; - } - - /** - * @param nbt - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setBoolean("hasJewelry", hasJewelry); - nbt.setBoolean("hasEndItem", hasEndItem); - nbt.setBoolean("hasJewel", hasGem); - nbt.setBoolean("crafting", crafting); - nbt.setInteger("timer", carving); - nbt.setInteger("effect", effect); - nbt.setFloat("angle", angle); - NBTTagCompound tag1 = new NBTTagCompound(); - NBTTagCompound tag2 = new NBTTagCompound(); - NBTTagCompound tag3 = new NBTTagCompound(); - jewelry.writeToNBT(tag1); - nbt.setTag("jewelry", tag1); - endItem.writeToNBT(tag2); - nbt.setTag("endItem", tag2); - gem.writeToNBT(tag3); - nbt.setTag("jewel", tag3); - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - hasJewelry = nbt.getBoolean("hasJewelry"); - hasEndItem = nbt.getBoolean("hasEndItem"); - hasGem = nbt.getBoolean("hasJewel"); - crafting = nbt.getBoolean("crafting"); - carving = nbt.getInteger("timer"); - effect = nbt.getInteger("effect"); - angle = nbt.getFloat("angle"); - jewelry = new ItemStack(Item.getItemById(0), 0, 0); - jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); - endItem = new ItemStack(Item.getItemById(0), 0, 0); - endItem.readFromNBT(nbt.getCompoundTag("endItem")); - gem = new ItemStack(Item.getItemById(0), 0, 0); - gem.readFromNBT(nbt.getCompoundTag("jewel")); - } - - /** - * - */ - @Override - public void updateEntity() - { - super.updateEntity(); - if (isDirty){ - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = false; - } - if (angle < 360F) angle += 3F; - else angle = 0F; - if (hasJewelry && hasGem && !hasEndItem && crafting){ - if (carving > 0) carving--; - if (crafting) for(int l = 0; l < ConfigHandler.GEM_PLACEMENT_TIME / (carving + 2); ++l){ - if (worldObj.rand.nextInt(10) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F); - if (getBlockMetadata() == 0) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); - if (getBlockMetadata() == 1) worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - if (getBlockMetadata() == 2) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D); - if (getBlockMetadata() == 3) worldObj.spawnParticle("instantSpell", xCoord + 0.2F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - } - if (carving == 0){ - hasEndItem = true; - endItem = jewelry.copy(); - if (hasGem && gem != new ItemStack(Item.getItemById(0), 0, 0)) if (!JewelryNBT.hasTag(jewelry, "gem")){ - JewelryNBT.addGem(endItem, gem); - hasGem = false; - gem = new ItemStack(Item.getItemById(0), 0, 0); - }else{ - ItemStack aux = JewelryNBT.gem(jewelry); - JewelryNBT.addGem(endItem, gem); - if (JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy(); - else{ - hasGem = false; - gem = new ItemStack(Item.getItemById(0), 0, 0); - } - } - hasJewelry = false; - jewelry = new ItemStack(Item.getItemById(0), 0, 0); - carving = -1; - crafting = false; - isDirty = true; - } - } - } - - public void setGemItemStack(ItemStack itemStack) - { +public class TileEntityJewelrsCraftingTable extends TileEntity { + public boolean hasJewelry, hasEndItem, isDirty, hasGem, crafting; + public ItemStack jewelry, endItem, gem; + public int carving, effect; + public float angle; + + /** + * + */ + public TileEntityJewelrsCraftingTable() { + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + endItem = new ItemStack(Item.getItemById(0), 0, 0); + gem = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelry = false; + hasEndItem = false; + hasGem = false; + crafting = false; + carving = 0; + effect = 0; + angle = 0; + isDirty = false; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setBoolean("hasJewelry", hasJewelry); + nbt.setBoolean("hasEndItem", hasEndItem); + nbt.setBoolean("hasJewel", hasGem); + nbt.setBoolean("crafting", crafting); + nbt.setInteger("timer", carving); + nbt.setInteger("effect", effect); + nbt.setFloat("angle", angle); + NBTTagCompound tag1 = new NBTTagCompound(); + NBTTagCompound tag2 = new NBTTagCompound(); + NBTTagCompound tag3 = new NBTTagCompound(); + jewelry.writeToNBT(tag1); + nbt.setTag("jewelry", tag1); + endItem.writeToNBT(tag2); + nbt.setTag("endItem", tag2); + gem.writeToNBT(tag3); + nbt.setTag("jewel", tag3); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + hasJewelry = nbt.getBoolean("hasJewelry"); + hasEndItem = nbt.getBoolean("hasEndItem"); + hasGem = nbt.getBoolean("hasJewel"); + crafting = nbt.getBoolean("crafting"); + carving = nbt.getInteger("timer"); + effect = nbt.getInteger("effect"); + angle = nbt.getFloat("angle"); + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); + endItem = new ItemStack(Item.getItemById(0), 0, 0); + endItem.readFromNBT(nbt.getCompoundTag("endItem")); + gem = new ItemStack(Item.getItemById(0), 0, 0); + gem.readFromNBT(nbt.getCompoundTag("jewel")); + } + + /** + * + */ + @Override + public void updateEntity() { + super.updateEntity(); + if (isDirty) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (angle < 360F) + angle += 3F; + else + angle = 0F; + if (hasJewelry && hasGem && !hasEndItem && crafting) { + if (carving > 0) + carving--; + if (crafting) + for (int l = 0; l < ConfigHandler.GEM_PLACEMENT_TIME + / (carving + 2); ++l) { + if (worldObj.rand.nextInt(10) == 0) + worldObj.playSoundEffect(xCoord, yCoord + 0.5F, + zCoord, "random.orb", 0.05F, 1F); + if (getBlockMetadata() == 0) + worldObj.spawnParticle("instantSpell", + xCoord + 0.5F, (double) yCoord + 0.8F, + zCoord + 0.2F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 1) + worldObj.spawnParticle("instantSpell", + xCoord + 0.8F, (double) yCoord + 0.8F, + zCoord + 0.5F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 2) + worldObj.spawnParticle("instantSpell", + xCoord + 0.5F, (double) yCoord + 0.8F, + zCoord + 0.8F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 3) + worldObj.spawnParticle("instantSpell", + xCoord + 0.2F, (double) yCoord + 0.8F, + zCoord + 0.5F, 0.0D, 0.0D, 0.0D); + } + if (carving == 0) { + hasEndItem = true; + endItem = jewelry.copy(); + if (hasGem + && gem != new ItemStack(Item.getItemById(0), 0, 0)) + if (!JewelryNBT.hasTag(jewelry, "gem")) { + JewelryNBT.addGem(endItem, gem); + hasGem = false; + gem = new ItemStack(Item.getItemById(0), 0, 0); + } else { + ItemStack aux = JewelryNBT.gem(jewelry); + JewelryNBT.addGem(endItem, gem); + if (JewelrycraftUtil.rand.nextBoolean()) + gem = aux.copy(); + else { + hasGem = false; + gem = new ItemStack(Item.getItemById(0), 0, 0); + } + } + hasJewelry = false; + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + carving = -1; + crafting = false; + isDirty = true; + } + } + } + + public void setGemItemStack(ItemStack itemStack) { if (itemStack != null && itemStack.getItem() != null) { this.gem = itemStack.copy(); this.gem.stackSize = 1; @@ -141,9 +157,8 @@ public class TileEntityJewelrsCraftingTable extends TileEntity this.isDirty = true; } } - - public void setJewelryItemStack(ItemStack itemStack) - { + + public void setJewelryItemStack(ItemStack itemStack) { if (itemStack != null && itemStack.getItem() != null) { this.jewelry = itemStack.copy(); this.jewelry.stackSize = 1; @@ -151,73 +166,70 @@ public class TileEntityJewelrsCraftingTable extends TileEntity this.isDirty = true; } } - - public void setCrafting() - { + + public void setCrafting() { carving = ConfigHandler.GEM_PLACEMENT_TIME; angle = 0; crafting = true; isDirty = true; } - - public void removeGem() - { - dropItem(worldObj, xCoord, yCoord, zCoord, gem.copy()); - gem = new ItemStack(Item.getItemById(0), 0, 0); - hasGem = false; - carving = -1; - crafting = false; - angle = 0F; - isDirty = true; + + public void removeGem() { + dropItem(worldObj, xCoord, yCoord, zCoord, gem.copy()); + gem = new ItemStack(Item.getItemById(0), 0, 0); + hasGem = false; + carving = -1; + crafting = false; + angle = 0F; + isDirty = true; } - - public void removeJewelry() - { - dropItem(worldObj, xCoord, yCoord, zCoord, jewelry.copy()); - jewelry = new ItemStack(Item.getItemById(0), 0, 0); - hasJewelry = false; - carving = -1; - crafting = false; - angle = 0F; - isDirty = true; + + public void removeJewelry() { + dropItem(worldObj, xCoord, yCoord, zCoord, jewelry.copy()); + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelry = false; + carving = -1; + crafting = false; + angle = 0F; + isDirty = true; } - - public void removeResult() - { - dropItem(worldObj, xCoord, yCoord, zCoord, endItem.copy()); - endItem = new ItemStack(Item.getItemById(0), 0, 0); - hasEndItem = false; - isDirty = true; + + public void removeResult() { + dropItem(worldObj, xCoord, yCoord, zCoord, endItem.copy()); + endItem = new ItemStack(Item.getItemById(0), 0, 0); + hasEndItem = false; + isDirty = true; + } + + public void dropItem(World world, double x, double y, double z, + ItemStack stack) { + EntityItem entityitem = + new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.21000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); } - - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.21000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java old mode 100644 new mode 100755 index 1cee6d0..5d37f65 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java @@ -9,75 +9,71 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TileEntityMidasTouch extends TileEntity -{ - public Entity target; - - public TileEntityMidasTouch() - {} - - public void setEntity(Entity ent) - { - target = ent; - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - if (target != null){ - int id = EntityList.getEntityID(target); - NBTTagCompound tag = new NBTTagCompound(); - target.writeToNBT(tag); - nbt.setInteger("entityID", id); - nbt.setTag("entity", tag); - } - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - NBTTagCompound en = (NBTTagCompound)nbt.getTag("entity"); - int entityID = nbt.getInteger("entityID"); - EntityLivingBase entity = (EntityLivingBase)EntityList.createEntityByID(entityID, worldObj); - if (entity != null){ - entity.readFromNBT(en); - target = entity; - } - } - - /** - * - */ - @Override - public boolean canUpdate() - { - return false; - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntityMidasTouch extends TileEntity { + public Entity target; + + public TileEntityMidasTouch() { + } + + public void setEntity(Entity ent) { + target = ent; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (target != null) { + int id = EntityList.getEntityID(target); + NBTTagCompound tag = new NBTTagCompound(); + target.writeToNBT(tag); + nbt.setInteger("entityID", id); + nbt.setTag("entity", tag); + } + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + NBTTagCompound en = (NBTTagCompound) nbt.getTag("entity"); + int entityID = nbt.getInteger("entityID"); + EntityLivingBase entity = (EntityLivingBase) EntityList + .createEntityByID(entityID, worldObj); + if (entity != null) { + entity.readFromNBT(en); + target = entity; + } + } + + /** + * + */ + @Override + public boolean canUpdate() { + return false; + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java old mode 100644 new mode 100755 index b2fe655..9fca5fc --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -10,135 +10,144 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TileEntityMolder extends TileEntity -{ - public int cooling; - public boolean hasMoltenMetal, hasJewelBase, hasMold, isDirty; - public ItemStack mold, jewelBase, moltenMetal, ringMetal; - public float quantity; - - /** - * - */ - public TileEntityMolder() - { - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - jewelBase = new ItemStack(Item.getItemById(0), 0, 0); - mold = new ItemStack(Item.getItemById(0), 0, 0); - ringMetal = new ItemStack(Item.getItemById(0), 0, 0); - cooling = -1; - quantity = 0f; - hasJewelBase = false; - hasMoltenMetal = false; - hasMold = false; - isDirty = false; - } - - /** - * @param nbt - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("cooling", cooling); - nbt.setFloat("quantity", quantity); - nbt.setBoolean("hasJewelBase", hasJewelBase); - nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); - nbt.setBoolean("hasMold", hasMold); - NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound tag1 = new NBTTagCompound(); - NBTTagCompound tag2 = new NBTTagCompound(); - NBTTagCompound tag3 = new NBTTagCompound(); - mold.writeToNBT(tag); - nbt.setTag("mold", tag); - jewelBase.writeToNBT(tag1); - nbt.setTag("jewelBase", tag1); - moltenMetal.writeToNBT(tag2); - nbt.setTag("moltenMetal", tag2); - ringMetal.writeToNBT(tag3); - nbt.setTag("ringMetal", tag3); - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - cooling = nbt.getInteger("cooling"); - quantity = nbt.getFloat("quantity"); - hasJewelBase = nbt.getBoolean("hasJewelBase"); - hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); - hasMold = nbt.getBoolean("hasMold"); - mold = new ItemStack(Item.getItemById(0), 0, 0); - mold.readFromNBT(nbt.getCompoundTag("mold")); - jewelBase = new ItemStack(Item.getItemById(0), 0, 0); - jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase")); - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); - ringMetal = new ItemStack(Item.getItemById(0), 0, 0); - ringMetal.readFromNBT(nbt.getCompoundTag("ringMetal")); - } - - /** - * - */ - @Override - public void updateEntity() - { - super.updateEntity(); - if (isDirty){ - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = false; - } - if (hasMoltenMetal && moltenMetal.getItem() != Item.getItemById(0) && quantity > 0f){ - if (worldObj.rand.nextInt(20) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.fizz", 0.5F, 1F); - for(int l = 0; l < 2; ++l) - worldObj.spawnParticle("reddust", xCoord + Math.random(), (double)yCoord + 0.2F, zCoord + Math.random(), 0.0D, 1.0D, 1.0D); - } - if (hasMoltenMetal && !hasJewelBase && quantity >= 0.1f){ - ringMetal = moltenMetal.copy(); - if (cooling > 0) cooling--; - if (cooling <= 0f){ - if (mold.getItemDamage() == 0) jewelBase = moltenMetal; - else if (mold.getItemDamage() == 1) jewelBase = new ItemStack(ItemList.ring); - else if (mold.getItemDamage() == 2) jewelBase = new ItemStack(ItemList.necklace); - else if (mold.getItemDamage() == 3) jewelBase = new ItemStack(ItemList.bracelet); - else if (mold.getItemDamage() == 4) jewelBase = new ItemStack(ItemList.earrings); - ringMetal.stackSize = 1; - jewelBase.stackSize = 1; - if (mold.getItemDamage() != 0 && jewelBase != new ItemStack(Item.getItemById(0), 0, 0)) JewelryNBT.addMetal(jewelBase, ringMetal); - hasMoltenMetal = false; - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - hasJewelBase = true; - cooling = -1; - quantity = 0f; - isDirty = true; - } - } - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntityMolder extends TileEntity { + public int cooling; + public boolean hasMoltenMetal, hasJewelBase, hasMold, isDirty; + public ItemStack mold, jewelBase, moltenMetal, ringMetal; + public float quantity; + + /** + * + */ + public TileEntityMolder() { + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + mold = new ItemStack(Item.getItemById(0), 0, 0); + ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + cooling = -1; + quantity = 0f; + hasJewelBase = false; + hasMoltenMetal = false; + hasMold = false; + isDirty = false; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("cooling", cooling); + nbt.setFloat("quantity", quantity); + nbt.setBoolean("hasJewelBase", hasJewelBase); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + nbt.setBoolean("hasMold", hasMold); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + NBTTagCompound tag2 = new NBTTagCompound(); + NBTTagCompound tag3 = new NBTTagCompound(); + mold.writeToNBT(tag); + nbt.setTag("mold", tag); + jewelBase.writeToNBT(tag1); + nbt.setTag("jewelBase", tag1); + moltenMetal.writeToNBT(tag2); + nbt.setTag("moltenMetal", tag2); + ringMetal.writeToNBT(tag3); + nbt.setTag("ringMetal", tag3); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + cooling = nbt.getInteger("cooling"); + quantity = nbt.getFloat("quantity"); + hasJewelBase = nbt.getBoolean("hasJewelBase"); + hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + hasMold = nbt.getBoolean("hasMold"); + mold = new ItemStack(Item.getItemById(0), 0, 0); + mold.readFromNBT(nbt.getCompoundTag("mold")); + jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase")); + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); + ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + ringMetal.readFromNBT(nbt.getCompoundTag("ringMetal")); + } + + /** + * + */ + @Override + public void updateEntity() { + super.updateEntity(); + if (isDirty) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (hasMoltenMetal && moltenMetal.getItem() != Item.getItemById(0) + && quantity > 0f) { + if (worldObj.rand.nextInt(20) == 0) + worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, + "random.fizz", 0.5F, 1F); + for (int l = 0; l < 2; ++l) + worldObj.spawnParticle("reddust", xCoord + Math.random(), + (double) yCoord + 0.2F, zCoord + Math.random(), + 0.0D, 1.0D, 1.0D); + } + if (hasMoltenMetal && !hasJewelBase && quantity >= 0.1f) { + ringMetal = moltenMetal.copy(); + if (cooling > 0) + cooling--; + if (cooling <= 0f) { + if (mold.getItemDamage() == 0) + jewelBase = moltenMetal; + else if (mold.getItemDamage() == 1) + jewelBase = new ItemStack(ItemList.ring); + else if (mold.getItemDamage() == 2) + jewelBase = new ItemStack(ItemList.necklace); + else if (mold.getItemDamage() == 3) + jewelBase = new ItemStack(ItemList.bracelet); + else if (mold.getItemDamage() == 4) + jewelBase = new ItemStack(ItemList.earrings); + ringMetal.stackSize = 1; + jewelBase.stackSize = 1; + if (mold.getItemDamage() != 0 + && jewelBase != new ItemStack(Item.getItemById(0), + 0, 0)) + JewelryNBT.addMetal(jewelBase, ringMetal); + hasMoltenMetal = false; + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelBase = true; + cooling = -1; + quantity = 0f; + isDirty = true; + } + } + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java old mode 100644 new mode 100755 index f8efb14..405011a --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java @@ -20,13 +20,16 @@ public class TileEntityMoltenMetal extends TileEntity { metal = null; } + @Override public boolean canUpdate() { return false; } public void setMetal(ItemStack metal) { - if(metal != null) this.metal = metal.copy(); - else this.metal = null; + if (metal != null) + this.metal = metal.copy(); + else + this.metal = null; } public ItemStack getMetal() { @@ -46,19 +49,24 @@ public class TileEntityMoltenMetal extends TileEntity { @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - if (nbt.hasKey("metal")) setMetal(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("metal"))); - else metal = null; + if (nbt.hasKey("metal")) + setMetal(ItemStack + .loadItemStackFromNBT(nbt.getCompoundTag("metal"))); + else + metal = null; } @Override public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, + nbttagcompound); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { readFromNBT(packet.func_148857_g()); worldObj.func_147479_m(xCoord, yCoord, zCoord); } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java old mode 100644 new mode 100755 index cdc3ac5..234417d --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity; import java.util.ArrayList; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.block.BlockHandPedestal; @@ -25,335 +26,511 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class TileEntityShadowEye extends TileEntity -{ - public int opening, timer, t = 20, soundTimer; - public boolean active, shouldAddData; - public ArrayList pedestalItems = new ArrayList(); - ResourceLocation particleTexture = new ResourceLocation(Variables.MODID, "textures/particle/shadows.png"); - public EntityPlayer target; - public ModelShadowEye model = new ModelShadowEye(); - - public TileEntityShadowEye() - { - opening = 1; - timer = 20; - active = false; - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("opening", opening); - nbt.setInteger("timer", timer); - nbt.setBoolean("active", active); - nbt.setBoolean("shouldAddData", shouldAddData); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - opening = nbt.getInteger("opening"); - timer = nbt.getInteger("timer"); - active = nbt.getBoolean("active"); - shouldAddData = nbt.getBoolean("shouldAddData"); - } - - @Override - public void updateEntity() - { - super.updateEntity(); - boolean valid = isValidStructure(worldObj, xCoord, yCoord, zCoord, blockMetadata); - boolean canStartRitual = valid && ((TileEntityHandPedestal)worldObj.getTileEntity(xCoord, yCoord - 3, zCoord)).heldItemStack != null && getNumberOfItems(worldObj, xCoord, yCoord, zCoord) > 0; - if (active){ - timer--; - if (canStartRitual && canChangePedestals(worldObj, xCoord, yCoord, zCoord) && opening == 4) changePedestals(worldObj, xCoord, yCoord, zCoord); - } - if (active && target != null && this.getDistanceFrom(target.posX, target.posY, target.posZ) > 27D){ - active = false; - timer = -1; - shouldAddData = false; - revertPedestals(worldObj, xCoord, yCoord, zCoord); - } - if (opening == 4 && timer <= 0) active = false; - if (!active && timer <= 0 && opening != 1){ - if (t > 0) t--; - if (t <= 0){ - opening--; - t = 20; - } - } - if (opening == 2 && timer <= 0 && t == 10 && shouldAddData){ - addData(worldObj, xCoord, yCoord, zCoord); - TileEntityHandPedestal target = (TileEntityHandPedestal)worldObj.getTileEntity(xCoord, yCoord - 3, zCoord); - if (target != null && target.getHeldItemStack() != null) JewelryNBT.addModifiers(target.getHeldItemStack(), pedestalItems); - revertPedestals(worldObj, xCoord, yCoord, zCoord); - } - if (active && timer <= 0){ - if (opening < 4){ - opening++; - timer = 20; - soundTimer = 0; - } - if (canStartRitual && opening == 4) timer = ConfigHandler.RITUAL_TIME; - else if (!canStartRitual){ - shouldAddData = false; - active = false; - timer = -1; - if (!worldObj.isRemote){ - JewelrycraftUtil.addCursePoints(target, 50); - target.addChatMessage(new ChatComponentText(EnumChatFormatting.BLACK + "The Shadows don't like to be disturbed for no reason!")); - target.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + "You feel a strange aura encumbering you.")); - } - } - } - if (active && opening == 4){ - for(int l = 0; l <= 100; l++) - worldObj.spawnParticle("depthsuspend", xCoord + 6.5F - worldObj.rand.nextInt(12) - worldObj.rand.nextFloat(), yCoord - 2F + worldObj.rand.nextInt(9) - worldObj.rand.nextFloat(), zCoord + 6.5F - worldObj.rand.nextInt(12) - worldObj.rand.nextFloat(), 0, 0, 0); - if(soundTimer == 0) worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "jewelrycraft2:Ritual", 1.0F, 1.0F, false); - if(soundTimer < 20*14) soundTimer++; - else soundTimer = 0; - } - } - - public boolean isValidStructure(World world, int x, int y, int z, int metadata) - { - if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 2){ - // Layers from top to bottom - // 1st Layer - if (world.getBlock(x, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z) != 5) return false; - if (world.getBlock(x + 1, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x + 1, y + 1, z) != 5) return false; - if (world.getBlock(x - 1, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x - 1, y + 1, z) != 5) return false; - // 2nd Layer - if (world.getBlock(x + 2, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x + 2, y, z) != 1) return false; - if (world.getBlock(x + 1, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x + 1, y, z) != 4) return false; - if (world.getBlock(x - 1, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x - 1, y, z) != 5) return false; - if (world.getBlock(x - 2, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x - 2, y, z) != 0) return false; - // 3rd Layer - if (world.getBlock(x + 2, y - 1, z) != Blocks.stonebrick) return false; - if (world.getBlock(x - 2, y - 1, z) != Blocks.stonebrick) return false; - // 4th Layer - if (world.getBlock(x + 2, y - 2, z) != Blocks.stonebrick) return false; - if (world.getBlock(x - 2, y - 2, z) != Blocks.stonebrick) return false; - // 5th Layer - if (world.getBlock(x + 2, y - 3, z) != Blocks.stonebrick) return false; - if (world.getBlock(x - 2, y - 3, z) != Blocks.stonebrick) return false; - }else if (world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 3){ - // Layers from top to bottom - // 1st Layer - if (world.getBlock(x, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z) != 5) return false; - if (world.getBlock(x, y + 1, z + 1) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z + 1) != 5) return false; - if (world.getBlock(x, y + 1, z - 1) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z - 1) != 5) return false; - // 2nd Layer - if (world.getBlock(x, y, z + 2) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z + 2) != 3) return false; - if (world.getBlock(x, y, z + 1) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z + 1) != 6) return false; - if (world.getBlock(x, y, z - 1) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z - 1) != 7) return false; - if (world.getBlock(x, y, z - 2) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z - 2) != 2) return false; - // 3rd Layer - if (world.getBlock(x, y - 1, z + 2) != Blocks.stonebrick) return false; - if (world.getBlock(x, y - 1, z - 2) != Blocks.stonebrick) return false; - // 4th Layer - if (world.getBlock(x, y - 2, z + 2) != Blocks.stonebrick) return false; - if (world.getBlock(x, y - 2, z - 2) != Blocks.stonebrick) return false; - // 5th Layer - if (world.getBlock(x, y - 3, z + 2) != Blocks.stonebrick) return false; - if (world.getBlock(x, y - 3, z - 2) != Blocks.stonebrick) return false; - } - // 3rd Layer - if (world.getBlock(x - 4, y - 1, z - 4) != BlockList.shadowBlock) return false; - if (world.getBlock(x - 4, y - 1, z + 4) != BlockList.shadowBlock) return false; - if (world.getBlock(x + 4, y - 1, z - 4) != BlockList.shadowBlock) return false; - if (world.getBlock(x + 4, y - 1, z + 4) != BlockList.shadowBlock) return false; - // 4th Layer - if (world.getBlock(x - 4, y - 2, z - 4) != Blocks.stonebrick) return false; - if (world.getBlock(x - 4, y - 2, z + 4) != Blocks.stonebrick) return false; - if (world.getBlock(x + 4, y - 2, z - 4) != Blocks.stonebrick) return false; - if (world.getBlock(x + 4, y - 2, z + 4) != Blocks.stonebrick) return false; - // 5th Layer - // Pillars - if (world.getBlock(x - 4, y - 3, z - 4) != Blocks.stonebrick) return false; - if (world.getBlock(x - 4, y - 3, z + 4) != Blocks.stonebrick) return false; - if (world.getBlock(x + 4, y - 3, z - 4) != Blocks.stonebrick) return false; - if (world.getBlock(x + 4, y - 3, z + 4) != Blocks.stonebrick) return false; - // Pedestals - if (!(world.getBlock(x, y - 3, z) instanceof BlockHandPedestal)) return false; - if (world.getBlock(x - 4, y - 3, z + 2) != BlockList.handPedestal || world.getBlockMetadata(x - 4, y - 3, z + 2) != 1) return false; - if (world.getBlock(x - 5, y - 3, z) != BlockList.handPedestal || world.getBlockMetadata(x - 5, y - 3, z) != 2) return false; - if (world.getBlock(x - 4, y - 3, z - 2) != BlockList.handPedestal || world.getBlockMetadata(x - 4, y - 3, z - 2) != 3) return false; - if (world.getBlock(x - 2, y - 3, z - 4) != BlockList.handPedestal || world.getBlockMetadata(x - 2, y - 3, z - 4) != 3) return false; - if (world.getBlock(x, y - 3, z - 5) != BlockList.handPedestal || world.getBlockMetadata(x, y - 3, z - 5) != 4) return false; - if (world.getBlock(x + 2, y - 3, z - 4) != BlockList.handPedestal || world.getBlockMetadata(x + 2, y - 3, z - 4) != 5) return false; - if (world.getBlock(x + 4, y - 3, z - 2) != BlockList.handPedestal || world.getBlockMetadata(x + 4, y - 3, z - 2) != 5) return false; - if (world.getBlock(x + 5, y - 3, z) != BlockList.handPedestal || world.getBlockMetadata(x + 5, y - 3, z) != 6) return false; - if (world.getBlock(x + 4, y - 3, z + 2) != BlockList.handPedestal || world.getBlockMetadata(x + 4, y - 3, z + 2) != 7) return false; - if (world.getBlock(x + 2, y - 3, z + 4) != BlockList.handPedestal || world.getBlockMetadata(x + 2, y - 3, z + 4) != 7) return false; - if (world.getBlock(x, y - 3, z + 5) != BlockList.handPedestal || world.getBlockMetadata(x, y - 3, z + 5) != 0) return false; - if (world.getBlock(x - 2, y - 3, z + 4) != BlockList.handPedestal || world.getBlockMetadata(x - 2, y - 3, z + 4) != 1) return false; - return true; - } - - public void addData(World world, int x, int y, int z) - { - pedestalItems.clear(); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z - 4)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z + 2)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z - 5)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z - 4)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z - 2)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 5, y - 3, z)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z - 2)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 5, y - 3, z)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z + 2)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z + 4)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z + 5)); - addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z + 4)); - } - - public int getNumberOfItems(World world, int x, int y, int z) - { - int items = 0; - if (((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z - 4)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z + 2)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z - 5)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z - 4)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z - 2)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x - 5, y - 3, z)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z - 2)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x + 5, y - 3, z)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z + 2)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z + 4)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z + 5)).heldItemStack != null) items++; - if (((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z + 4)).heldItemStack != null) items++; - return items; - } - - public boolean canChangePedestals(World world, int x, int y, int z) - { - if (world.getBlock(x, y - 3, z) != BlockList.handPedestal) return false; - if (world.getBlock(x + 2, y - 3, z - 4) != BlockList.handPedestal) return false; - if (world.getBlock(x - 4, y - 3, z + 2) != BlockList.handPedestal) return false; - if (world.getBlock(x, y - 3, z - 5) != BlockList.handPedestal) return false; - if (world.getBlock(x - 2, y - 3, z - 4) != BlockList.handPedestal) return false; - if (world.getBlock(x - 4, y - 3, z - 2) != BlockList.handPedestal) return false; - if (world.getBlock(x - 5, y - 3, z) != BlockList.handPedestal) return false; - if (world.getBlock(x + 4, y - 3, z - 2) != BlockList.handPedestal) return false; - if (world.getBlock(x + 5, y - 3, z) != BlockList.handPedestal) return false; - if (world.getBlock(x + 4, y - 3, z + 2) != BlockList.handPedestal) return false; - if (world.getBlock(x + 2, y - 3, z + 4) != BlockList.handPedestal) return false; - if (world.getBlock(x, y - 3, z + 5) != BlockList.handPedestal) return false; - if (world.getBlock(x - 2, y - 3, z + 4) != BlockList.handPedestal) return false; - return true; - } - - public void changePedestals(World world, int x, int y, int z) - { - changeHand(world, x, y - 3, z); - changeHand(world, x + 2, y - 3, z - 4); - changeHand(world, x - 4, y - 3, z + 2); - changeHand(world, x, y - 3, z - 5); - changeHand(world, x - 2, y - 3, z - 4); - changeHand(world, x - 4, y - 3, z - 2); - changeHand(world, x - 5, y - 3, z); - changeHand(world, x + 4, y - 3, z - 2); - changeHand(world, x + 5, y - 3, z); - changeHand(world, x + 4, y - 3, z + 2); - changeHand(world, x + 2, y - 3, z + 4); - changeHand(world, x, y - 3, z + 5); - changeHand(world, x - 2, y - 3, z + 4); - } - - public void changeHand(World world, int x, int y, int z) - { - int l = world.getBlockMetadata(x, y, z); - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(world.getBlock(x, y, z))); - TileEntityShadowHand tile = new TileEntityShadowHand(); - if (world.getTileEntity(x, y, z) instanceof TileEntityHandPedestal){ - if (((TileEntityHandPedestal)world.getTileEntity(x, y, z)).heldItemStack != null) tile.setHeldItemStack(((TileEntityHandPedestal)world.getTileEntity(x, y, z)).heldItemStack.copy()); - if (tile.heldItemStack != null) tile.closeHand(); - ((TileEntityHandPedestal)world.getTileEntity(x, y, z)).removeHeldItemStack(); - world.setBlock(x, y, z, BlockList.shadowHand, l, 2); - world.setTileEntity(x, y, z, tile); - } - } - - public void revertPedestals(World world, int x, int y, int z) - { - revertHand(world, x, y - 3, z); - revertHand(world, x + 2, y - 3, z - 4); - revertHand(world, x - 4, y - 3, z + 2); - revertHand(world, x, y - 3, z - 5); - revertHand(world, x - 2, y - 3, z - 4); - revertHand(world, x - 4, y - 3, z - 2); - revertHand(world, x - 5, y - 3, z); - revertHand(world, x + 4, y - 3, z - 2); - revertHand(world, x + 5, y - 3, z); - revertHand(world, x + 4, y - 3, z + 2); - revertHand(world, x + 2, y - 3, z + 4); - revertHand(world, x, y - 3, z + 5); - revertHand(world, x - 2, y - 3, z + 4); - } - - public void revertHand(World world, int x, int y, int z) - { - int l = world.getBlockMetadata(x, y, z); - world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(BlockList.handPedestal)); - world.playSoundEffect(x, y + 0.5F, z, "step.wood", 1F, 1F); - TileEntityHandPedestal tile = new TileEntityHandPedestal(); - if (world.getTileEntity(x, y, z) instanceof TileEntityShadowHand){ - if (((TileEntityShadowHand)world.getTileEntity(x, y, z)).heldItemStack != null) tile.setHeldItemStack(((TileEntityShadowHand)world.getTileEntity(x, y, z)).heldItemStack.copy()); - ((TileEntityShadowHand)world.getTileEntity(x, y, z)).removeHeldItemStack(); - world.setBlock(x, y, z, BlockList.handPedestal, l, 2); - world.setTileEntity(x, y, z, tile); - } - } - - public void addPedestalInfo(TileEntityHandPedestal pedestal) - { - ItemStack heldItemStack; - if (pedestal != null && (heldItemStack = pedestal.getHeldItemStack()) != null){ - if (pedestalItems.isEmpty()) pedestalItems.add(heldItemStack.copy()); - else{ - boolean hasItem = false; - int index = 0; - for(int ind = 0; ind < pedestalItems.size() && !hasItem; ind++) - if (heldItemStack.getItem().equals(pedestalItems.get(ind).getItem()) && heldItemStack.getItemDamage() == pedestalItems.get(ind).getItemDamage()){ - index = ind; - hasItem = true; - if (heldItemStack.hasTagCompound() && pedestalItems.get(ind).hasTagCompound() && !heldItemStack.getTagCompound().equals(pedestalItems.get(ind).getTagCompound())) hasItem = false; - } - if (!hasItem) pedestalItems.add(heldItemStack.copy()); - else{ - ItemStack object = pedestalItems.get(index).copy(); - object.stackSize++; - pedestalItems.set(index, object); - } - } - pedestal.removeHeldItemStack(); - pedestal.openHand(); - }else if (pedestal != null && target != null) JewelrycraftUtil.addCursePoints(target, 20); - } - - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord - 5.5D, yCoord - 5.5D, zCoord - 5.5D, xCoord + 5.5D, yCoord + 5.5D, zCoord + 5.5D); - return bb; - } - - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntityShadowEye extends TileEntity { + public int opening, timer, t = 20, soundTimer; + public boolean active, shouldAddData; + public ArrayList pedestalItems = + new ArrayList(); + ResourceLocation particleTexture = new ResourceLocation( + Variables.MODID, "textures/particle/shadows.png"); + public EntityPlayer target; + public ModelShadowEye model = new ModelShadowEye(); + + public TileEntityShadowEye() { + opening = 1; + timer = 20; + active = false; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("opening", opening); + nbt.setInteger("timer", timer); + nbt.setBoolean("active", active); + nbt.setBoolean("shouldAddData", shouldAddData); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + opening = nbt.getInteger("opening"); + timer = nbt.getInteger("timer"); + active = nbt.getBoolean("active"); + shouldAddData = nbt.getBoolean("shouldAddData"); + } + + @Override + public void updateEntity() { + super.updateEntity(); + boolean valid = isValidStructure(worldObj, xCoord, yCoord, zCoord, + blockMetadata); + boolean canStartRitual = valid + && ((TileEntityHandPedestal) worldObj.getTileEntity(xCoord, + yCoord - 3, zCoord)).heldItemStack != null + && getNumberOfItems(worldObj, xCoord, yCoord, zCoord) > 0; + if (active) { + timer--; + if (canStartRitual + && canChangePedestals(worldObj, xCoord, yCoord, zCoord) + && opening == 4) + changePedestals(worldObj, xCoord, yCoord, zCoord); + } + if (active && target != null && this.getDistanceFrom(target.posX, + target.posY, target.posZ) > 27D) { + active = false; + timer = -1; + shouldAddData = false; + revertPedestals(worldObj, xCoord, yCoord, zCoord); + } + if (opening == 4 && timer <= 0) + active = false; + if (!active && timer <= 0 && opening != 1) { + if (t > 0) + t--; + if (t <= 0) { + opening--; + t = 20; + } + } + if (opening == 2 && timer <= 0 && t == 10 && shouldAddData) { + addData(worldObj, xCoord, yCoord, zCoord); + TileEntityHandPedestal target = + (TileEntityHandPedestal) worldObj.getTileEntity(xCoord, + yCoord - 3, zCoord); + if (target != null && target.getHeldItemStack() != null) + JewelryNBT.addModifiers(target.getHeldItemStack(), + pedestalItems); + revertPedestals(worldObj, xCoord, yCoord, zCoord); + } + if (active && timer <= 0) { + if (opening < 4) { + opening++; + timer = 20; + soundTimer = 0; + } + if (canStartRitual && opening == 4) + timer = ConfigHandler.RITUAL_TIME; + else if (!canStartRitual) { + shouldAddData = false; + active = false; + timer = -1; + if (!worldObj.isRemote) { + JewelrycraftUtil.addCursePoints(target, 50); + target.addChatMessage( + new ChatComponentText(EnumChatFormatting.BLACK + + "The Shadows don't like to be disturbed for no reason!")); + target.addChatMessage(new ChatComponentText( + EnumChatFormatting.DARK_PURPLE + + "You feel a strange aura encumbering you.")); + } + } + } + if (active && opening == 4) { + for (int l = 0; l <= 100; l++) + worldObj.spawnParticle("depthsuspend", + xCoord + 6.5F - worldObj.rand.nextInt(12) + - worldObj.rand.nextFloat(), + yCoord - 2F + worldObj.rand.nextInt(9) + - worldObj.rand.nextFloat(), + zCoord + 6.5F - worldObj.rand.nextInt(12) + - worldObj.rand.nextFloat(), + 0, 0, 0); + if (soundTimer == 0) + worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, + zCoord + 0.5D, "jewelrycraft2:Ritual", 1.0F, 1.0F, + false); + if (soundTimer < 20 * 14) + soundTimer++; + else + soundTimer = 0; + } + } + + public boolean isValidStructure(World world, int x, int y, int z, + int metadata) { + if (world.getBlockMetadata(x, y, z) == 0 + || world.getBlockMetadata(x, y, z) == 2) { + // Layers from top to bottom + // 1st Layer + if (world.getBlock(x, y + 1, z) != Blocks.stone_slab + || world.getBlockMetadata(x, y + 1, z) != 5) + return false; + if (world.getBlock(x + 1, y + 1, z) != Blocks.stone_slab + || world.getBlockMetadata(x + 1, y + 1, z) != 5) + return false; + if (world.getBlock(x - 1, y + 1, z) != Blocks.stone_slab + || world.getBlockMetadata(x - 1, y + 1, z) != 5) + return false; + // 2nd Layer + if (world.getBlock(x + 2, y, z) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x + 2, y, z) != 1) + return false; + if (world.getBlock(x + 1, y, z) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x + 1, y, z) != 4) + return false; + if (world.getBlock(x - 1, y, z) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x - 1, y, z) != 5) + return false; + if (world.getBlock(x - 2, y, z) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x - 2, y, z) != 0) + return false; + // 3rd Layer + if (world.getBlock(x + 2, y - 1, z) != Blocks.stonebrick) + return false; + if (world.getBlock(x - 2, y - 1, z) != Blocks.stonebrick) + return false; + // 4th Layer + if (world.getBlock(x + 2, y - 2, z) != Blocks.stonebrick) + return false; + if (world.getBlock(x - 2, y - 2, z) != Blocks.stonebrick) + return false; + // 5th Layer + if (world.getBlock(x + 2, y - 3, z) != Blocks.stonebrick) + return false; + if (world.getBlock(x - 2, y - 3, z) != Blocks.stonebrick) + return false; + } else if (world.getBlockMetadata(x, y, z) == 1 + || world.getBlockMetadata(x, y, z) == 3) { + // Layers from top to bottom + // 1st Layer + if (world.getBlock(x, y + 1, z) != Blocks.stone_slab + || world.getBlockMetadata(x, y + 1, z) != 5) + return false; + if (world.getBlock(x, y + 1, z + 1) != Blocks.stone_slab + || world.getBlockMetadata(x, y + 1, z + 1) != 5) + return false; + if (world.getBlock(x, y + 1, z - 1) != Blocks.stone_slab + || world.getBlockMetadata(x, y + 1, z - 1) != 5) + return false; + // 2nd Layer + if (world.getBlock(x, y, z + 2) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x, y, z + 2) != 3) + return false; + if (world.getBlock(x, y, z + 1) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x, y, z + 1) != 6) + return false; + if (world.getBlock(x, y, z - 1) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x, y, z - 1) != 7) + return false; + if (world.getBlock(x, y, z - 2) != Blocks.stone_brick_stairs + || world.getBlockMetadata(x, y, z - 2) != 2) + return false; + // 3rd Layer + if (world.getBlock(x, y - 1, z + 2) != Blocks.stonebrick) + return false; + if (world.getBlock(x, y - 1, z - 2) != Blocks.stonebrick) + return false; + // 4th Layer + if (world.getBlock(x, y - 2, z + 2) != Blocks.stonebrick) + return false; + if (world.getBlock(x, y - 2, z - 2) != Blocks.stonebrick) + return false; + // 5th Layer + if (world.getBlock(x, y - 3, z + 2) != Blocks.stonebrick) + return false; + if (world.getBlock(x, y - 3, z - 2) != Blocks.stonebrick) + return false; + } + // 3rd Layer + if (world.getBlock(x - 4, y - 1, z - 4) != BlockList.shadowBlock) + return false; + if (world.getBlock(x - 4, y - 1, z + 4) != BlockList.shadowBlock) + return false; + if (world.getBlock(x + 4, y - 1, z - 4) != BlockList.shadowBlock) + return false; + if (world.getBlock(x + 4, y - 1, z + 4) != BlockList.shadowBlock) + return false; + // 4th Layer + if (world.getBlock(x - 4, y - 2, z - 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x - 4, y - 2, z + 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x + 4, y - 2, z - 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x + 4, y - 2, z + 4) != Blocks.stonebrick) + return false; + // 5th Layer + // Pillars + if (world.getBlock(x - 4, y - 3, z - 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x - 4, y - 3, z + 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x + 4, y - 3, z - 4) != Blocks.stonebrick) + return false; + if (world.getBlock(x + 4, y - 3, z + 4) != Blocks.stonebrick) + return false; + // Pedestals + if (!(world.getBlock(x, y - 3, z) instanceof BlockHandPedestal)) + return false; + if (world.getBlock(x - 4, y - 3, z + 2) != BlockList.handPedestal + || world.getBlockMetadata(x - 4, y - 3, z + 2) != 1) + return false; + if (world.getBlock(x - 5, y - 3, z) != BlockList.handPedestal + || world.getBlockMetadata(x - 5, y - 3, z) != 2) + return false; + if (world.getBlock(x - 4, y - 3, z - 2) != BlockList.handPedestal + || world.getBlockMetadata(x - 4, y - 3, z - 2) != 3) + return false; + if (world.getBlock(x - 2, y - 3, z - 4) != BlockList.handPedestal + || world.getBlockMetadata(x - 2, y - 3, z - 4) != 3) + return false; + if (world.getBlock(x, y - 3, z - 5) != BlockList.handPedestal + || world.getBlockMetadata(x, y - 3, z - 5) != 4) + return false; + if (world.getBlock(x + 2, y - 3, z - 4) != BlockList.handPedestal + || world.getBlockMetadata(x + 2, y - 3, z - 4) != 5) + return false; + if (world.getBlock(x + 4, y - 3, z - 2) != BlockList.handPedestal + || world.getBlockMetadata(x + 4, y - 3, z - 2) != 5) + return false; + if (world.getBlock(x + 5, y - 3, z) != BlockList.handPedestal + || world.getBlockMetadata(x + 5, y - 3, z) != 6) + return false; + if (world.getBlock(x + 4, y - 3, z + 2) != BlockList.handPedestal + || world.getBlockMetadata(x + 4, y - 3, z + 2) != 7) + return false; + if (world.getBlock(x + 2, y - 3, z + 4) != BlockList.handPedestal + || world.getBlockMetadata(x + 2, y - 3, z + 4) != 7) + return false; + if (world.getBlock(x, y - 3, z + 5) != BlockList.handPedestal + || world.getBlockMetadata(x, y - 3, z + 5) != 0) + return false; + if (world.getBlock(x - 2, y - 3, z + 4) != BlockList.handPedestal + || world.getBlockMetadata(x - 2, y - 3, z + 4) != 1) + return false; + return true; + } + + public void addData(World world, int x, int y, int z) { + pedestalItems.clear(); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 2, + y - 3, z - 4)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 4, + y - 3, z + 2)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x, + y - 3, z - 5)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 2, + y - 3, z - 4)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 4, + y - 3, z - 2)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 5, + y - 3, z)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 4, + y - 3, z - 2)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 5, + y - 3, z)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 4, + y - 3, z + 2)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x + 2, + y - 3, z + 4)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x, + y - 3, z + 5)); + addPedestalInfo((TileEntityHandPedestal) world.getTileEntity(x - 2, + y - 3, z + 4)); + } + + public int getNumberOfItems(World world, int x, int y, int z) { + int items = 0; + if (((TileEntityHandPedestal) world.getTileEntity(x + 2, y - 3, + z - 4)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x - 4, y - 3, + z + 2)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x, y - 3, + z - 5)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x - 2, y - 3, + z - 4)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x - 4, y - 3, + z - 2)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x - 5, y - 3, + z)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x + 4, y - 3, + z - 2)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x + 5, y - 3, + z)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x + 4, y - 3, + z + 2)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x + 2, y - 3, + z + 4)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x, y - 3, + z + 5)).heldItemStack != null) + items++; + if (((TileEntityHandPedestal) world.getTileEntity(x - 2, y - 3, + z + 4)).heldItemStack != null) + items++; + return items; + } + + public boolean canChangePedestals(World world, int x, int y, int z) { + if (world.getBlock(x, y - 3, z) != BlockList.handPedestal) + return false; + if (world.getBlock(x + 2, y - 3, z - 4) != BlockList.handPedestal) + return false; + if (world.getBlock(x - 4, y - 3, z + 2) != BlockList.handPedestal) + return false; + if (world.getBlock(x, y - 3, z - 5) != BlockList.handPedestal) + return false; + if (world.getBlock(x - 2, y - 3, z - 4) != BlockList.handPedestal) + return false; + if (world.getBlock(x - 4, y - 3, z - 2) != BlockList.handPedestal) + return false; + if (world.getBlock(x - 5, y - 3, z) != BlockList.handPedestal) + return false; + if (world.getBlock(x + 4, y - 3, z - 2) != BlockList.handPedestal) + return false; + if (world.getBlock(x + 5, y - 3, z) != BlockList.handPedestal) + return false; + if (world.getBlock(x + 4, y - 3, z + 2) != BlockList.handPedestal) + return false; + if (world.getBlock(x + 2, y - 3, z + 4) != BlockList.handPedestal) + return false; + if (world.getBlock(x, y - 3, z + 5) != BlockList.handPedestal) + return false; + if (world.getBlock(x - 2, y - 3, z + 4) != BlockList.handPedestal) + return false; + return true; + } + + public void changePedestals(World world, int x, int y, int z) { + changeHand(world, x, y - 3, z); + changeHand(world, x + 2, y - 3, z - 4); + changeHand(world, x - 4, y - 3, z + 2); + changeHand(world, x, y - 3, z - 5); + changeHand(world, x - 2, y - 3, z - 4); + changeHand(world, x - 4, y - 3, z - 2); + changeHand(world, x - 5, y - 3, z); + changeHand(world, x + 4, y - 3, z - 2); + changeHand(world, x + 5, y - 3, z); + changeHand(world, x + 4, y - 3, z + 2); + changeHand(world, x + 2, y - 3, z + 4); + changeHand(world, x, y - 3, z + 5); + changeHand(world, x - 2, y - 3, z + 4); + } + + public void changeHand(World world, int x, int y, int z) { + int l = world.getBlockMetadata(x, y, z); + world.playAuxSFX(2001, x, y, z, + Block.getIdFromBlock(world.getBlock(x, y, z))); + TileEntityShadowHand tile = new TileEntityShadowHand(); + if (world.getTileEntity(x, y, + z) instanceof TileEntityHandPedestal) { + if (((TileEntityHandPedestal) world.getTileEntity(x, y, + z)).heldItemStack != null) + tile.setHeldItemStack(((TileEntityHandPedestal) world + .getTileEntity(x, y, z)).heldItemStack.copy()); + if (tile.heldItemStack != null) + tile.closeHand(); + ((TileEntityHandPedestal) world.getTileEntity(x, y, z)) + .removeHeldItemStack(); + world.setBlock(x, y, z, BlockList.shadowHand, l, 2); + world.setTileEntity(x, y, z, tile); + } + } + + public void revertPedestals(World world, int x, int y, int z) { + revertHand(world, x, y - 3, z); + revertHand(world, x + 2, y - 3, z - 4); + revertHand(world, x - 4, y - 3, z + 2); + revertHand(world, x, y - 3, z - 5); + revertHand(world, x - 2, y - 3, z - 4); + revertHand(world, x - 4, y - 3, z - 2); + revertHand(world, x - 5, y - 3, z); + revertHand(world, x + 4, y - 3, z - 2); + revertHand(world, x + 5, y - 3, z); + revertHand(world, x + 4, y - 3, z + 2); + revertHand(world, x + 2, y - 3, z + 4); + revertHand(world, x, y - 3, z + 5); + revertHand(world, x - 2, y - 3, z + 4); + } + + public void revertHand(World world, int x, int y, int z) { + int l = world.getBlockMetadata(x, y, z); + world.playAuxSFX(2001, x, y, z, + Block.getIdFromBlock(BlockList.handPedestal)); + world.playSoundEffect(x, y + 0.5F, z, "step.wood", 1F, 1F); + TileEntityHandPedestal tile = new TileEntityHandPedestal(); + if (world.getTileEntity(x, y, z) instanceof TileEntityShadowHand) { + if (((TileEntityShadowHand) world.getTileEntity(x, y, + z)).heldItemStack != null) + tile.setHeldItemStack(((TileEntityShadowHand) world + .getTileEntity(x, y, z)).heldItemStack.copy()); + ((TileEntityShadowHand) world.getTileEntity(x, y, z)) + .removeHeldItemStack(); + world.setBlock(x, y, z, BlockList.handPedestal, l, 2); + world.setTileEntity(x, y, z, tile); + } + } + + public void addPedestalInfo(TileEntityHandPedestal pedestal) { + ItemStack heldItemStack; + if (pedestal != null + && (heldItemStack = pedestal.getHeldItemStack()) != null) { + if (pedestalItems.isEmpty()) + pedestalItems.add(heldItemStack.copy()); + else { + boolean hasItem = false; + int index = 0; + for (int ind = 0; ind < pedestalItems.size() && !hasItem; + ind++) + if (heldItemStack.getItem() + .equals(pedestalItems.get(ind).getItem()) + && heldItemStack + .getItemDamage() == pedestalItems + .get(ind).getItemDamage()) { + index = ind; + hasItem = true; + if (heldItemStack.hasTagCompound() + && pedestalItems.get(ind).hasTagCompound() + && !heldItemStack.getTagCompound() + .equals(pedestalItems.get(ind) + .getTagCompound())) + hasItem = false; + } + if (!hasItem) + pedestalItems.add(heldItemStack.copy()); + else { + ItemStack object = pedestalItems.get(index).copy(); + object.stackSize++; + pedestalItems.set(index, object); + } + } + pedestal.removeHeldItemStack(); + pedestal.openHand(); + } else if (pedestal != null && target != null) + JewelrycraftUtil.addCursePoints(target, 20); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord - 5.5D, + yCoord - 5.5D, zCoord - 5.5D, xCoord + 5.5D, yCoord + 5.5D, + zCoord + 5.5D); + return bb; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java old mode 100644 new mode 100755 index b22602e..1b86d07 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java @@ -3,5 +3,5 @@ package darkknight.jewelrycraft.tileentity; /** * @author Paul Fulham (pau101) */ -public class TileEntityShadowHand extends TileEntityHandPedestal -{} \ No newline at end of file +public class TileEntityShadowHand extends TileEntityHandPedestal { +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java old mode 100644 new mode 100755 index c75d8f0..2f170f9 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity; import java.util.Random; + import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.util.JewelryNBT; import darkknight.jewelrycraft.util.JewelrycraftUtil; @@ -12,178 +13,215 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class TileEntitySmelter extends TileEntity -{ - public int melting, flow, n = 0, p = 0; - public boolean hasMetal, hasMoltenMetal, isDirty, pouring; - public ItemStack metal, moltenMetal; - public float quantity, pouredQuantity = 0.1f; - - /** - * - */ - public TileEntitySmelter() - { - melting = 0; - pouring = false; - flow = 0; - quantity = 0f; - hasMetal = false; - hasMoltenMetal = false; - metal = new ItemStack(Item.getItemById(0), 0, 0); - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - isDirty = false; - } - - /** - * @param nbt - */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("melting", melting); - nbt.setFloat("quantity", quantity); - nbt.setBoolean("hasMetal", hasMetal); - nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); - nbt.setBoolean("pouring", pouring); - NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound tag1 = new NBTTagCompound(); - metal.writeToNBT(tag); - nbt.setTag("metal", tag); - moltenMetal.writeToNBT(tag1); - nbt.setTag("moltenMetal", tag1); - } - - /** - * @param nbt - */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - melting = nbt.getInteger("melting"); - quantity = nbt.getFloat("quantity"); - hasMetal = nbt.getBoolean("hasMetal"); - hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); - pouring = nbt.getBoolean("pouring"); - metal = new ItemStack(Item.getItemById(0), 0, 0); - metal.readFromNBT(nbt.getCompoundTag("metal")); - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); - } - - /** - * - */ - @Override - public void updateEntity() - { - super.updateEntity(); - Random rand = new Random(); - if (isDirty){ - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = false; - } - if (p > 0) --p; - else p = 5; - if (n == 0 && p == 0){ - flow += 16; - if (flow >= 16 * 20) n = 1; - } - if (n == 1 && p == 0){ - flow -= 16; - if (flow <= 0) n = 0; - } - if (hasMetal) for(int l = 0; l < 2; ++l) - worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), (double)yCoord + 0.3F, zCoord + rand.nextFloat(), 0.0D, 0.0D, 0.0D); - if (rand.nextInt(65) == 0){ - double d5 = xCoord + rand.nextFloat(); - double d7 = yCoord; - double d6 = zCoord + rand.nextFloat(); - worldObj.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); - } - if (hasMetal && !hasMoltenMetal){ - boolean isOre = JewelrycraftUtil.isOre(metal); - if (melting > 0) melting--; - if (melting == 0){ - hasMetal = false; - if (!isOre){ - if(JewelryNBT.ingot(metal) == null) moltenMetal = metal; - else moltenMetal = JewelryNBT.ingot(metal); - } - else{ - moltenMetal = JewelrycraftUtil.getIngotFromOre(metal); - moltenMetal.stackSize *= 2; - } - hasMoltenMetal = true; - if (!isOre) quantity = 0.1f * metal.stackSize; - else quantity = 0.2f * metal.stackSize; - metal = new ItemStack(Item.getItemById(0), 0, 0); - melting = -1; - isDirty = true; - } - }else if (hasMoltenMetal){ - boolean isOre = JewelrycraftUtil.isOre(metal); - if (melting > 0) melting--; - if (melting == 0){ - hasMetal = false; - if (!isOre) moltenMetal.stackSize += metal.stackSize; - else moltenMetal.stackSize += metal.stackSize * 2; - if (!isOre) quantity += 0.1f * metal.stackSize; - else quantity += 0.2f * metal.stackSize; - metal = new ItemStack(Item.getItemById(0), 0, 0); - melting = -1; - isDirty = true; - } - } - TileEntityMolder me = null; - if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0 && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord - 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord - 1); - else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord + 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord + 1, yCoord, zCoord); - else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2 && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) != null && worldObj.getTileEntity(xCoord, yCoord, zCoord + 1) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord, yCoord, zCoord + 1); - else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 3 && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) != null && worldObj.getTileEntity(xCoord - 1, yCoord, zCoord) instanceof TileEntityMolder) me = (TileEntityMolder)worldObj.getTileEntity(xCoord - 1, yCoord, zCoord); - if (pouring && pouredQuantity > 0f){ - quantity -= 0.01f; - pouredQuantity -= 0.01f; - me.quantity += 0.01f; - if (!me.hasMoltenMetal){ - me.moltenMetal = moltenMetal; - me.hasMoltenMetal = true; - } - if (pouredQuantity <= 0f){ - pouring = false; - pouredQuantity = 0.1f; - me.cooling = ConfigHandler.INGOT_COOLING_TIME; - } - if (quantity <= 0f){ - quantity = 0f; - hasMoltenMetal = false; - moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); - me.cooling = ConfigHandler.INGOT_COOLING_TIME; - } - me.isDirty = true; - } - } - - /** - * @return - */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); - } - - /** - * @param net - * @param packet - */ - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) - { - readFromNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - } +public class TileEntitySmelter extends TileEntity { + public int melting, flow, n = 0, p = 0; + public boolean hasMetal, hasMoltenMetal, isDirty, pouring; + public ItemStack metal, moltenMetal; + public float quantity, pouredQuantity = 0.1f; + + /** + * + */ + public TileEntitySmelter() { + melting = 0; + pouring = false; + flow = 0; + quantity = 0f; + hasMetal = false; + hasMoltenMetal = false; + metal = new ItemStack(Item.getItemById(0), 0, 0); + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + isDirty = false; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("melting", melting); + nbt.setFloat("quantity", quantity); + nbt.setBoolean("hasMetal", hasMetal); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + nbt.setBoolean("pouring", pouring); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + metal.writeToNBT(tag); + nbt.setTag("metal", tag); + moltenMetal.writeToNBT(tag1); + nbt.setTag("moltenMetal", tag1); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + melting = nbt.getInteger("melting"); + quantity = nbt.getFloat("quantity"); + hasMetal = nbt.getBoolean("hasMetal"); + hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + pouring = nbt.getBoolean("pouring"); + metal = new ItemStack(Item.getItemById(0), 0, 0); + metal.readFromNBT(nbt.getCompoundTag("metal")); + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); + } + + /** + * + */ + @Override + public void updateEntity() { + super.updateEntity(); + Random rand = new Random(); + if (isDirty) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (p > 0) + --p; + else + p = 5; + if (n == 0 && p == 0) { + flow += 16; + if (flow >= 16 * 20) + n = 1; + } + if (n == 1 && p == 0) { + flow -= 16; + if (flow <= 0) + n = 0; + } + if (hasMetal) + for (int l = 0; l < 2; ++l) + worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), + (double) yCoord + 0.3F, zCoord + rand.nextFloat(), + 0.0D, 0.0D, 0.0D); + if (rand.nextInt(65) == 0) { + double d5 = xCoord + rand.nextFloat(); + double d7 = yCoord; + double d6 = zCoord + rand.nextFloat(); + worldObj.playSound(d5, d7, d6, "liquid.lavapop", + 0.2F + rand.nextFloat() * 0.2F, + 0.9F + rand.nextFloat() * 0.15F, false); + } + if (hasMetal && !hasMoltenMetal) { + boolean isOre = JewelrycraftUtil.isOre(metal); + if (melting > 0) + melting--; + if (melting == 0) { + hasMetal = false; + if (!isOre) { + if (JewelryNBT.ingot(metal) == null) + moltenMetal = metal; + else + moltenMetal = JewelryNBT.ingot(metal); + } else { + moltenMetal = JewelrycraftUtil.getIngotFromOre(metal); + moltenMetal.stackSize *= 2; + } + hasMoltenMetal = true; + if (!isOre) + quantity = 0.1f * metal.stackSize; + else + quantity = 0.2f * metal.stackSize; + metal = new ItemStack(Item.getItemById(0), 0, 0); + melting = -1; + isDirty = true; + } + } else if (hasMoltenMetal) { + boolean isOre = JewelrycraftUtil.isOre(metal); + if (melting > 0) + melting--; + if (melting == 0) { + hasMetal = false; + if (!isOre) + moltenMetal.stackSize += metal.stackSize; + else + moltenMetal.stackSize += metal.stackSize * 2; + if (!isOre) + quantity += 0.1f * metal.stackSize; + else + quantity += 0.2f * metal.stackSize; + metal = new ItemStack(Item.getItemById(0), 0, 0); + melting = -1; + isDirty = true; + } + } + TileEntityMolder me = null; + if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0 + && worldObj.getTileEntity(xCoord, yCoord, + zCoord - 1) != null + && worldObj.getTileEntity(xCoord, yCoord, + zCoord - 1) instanceof TileEntityMolder) + me = (TileEntityMolder) worldObj.getTileEntity(xCoord, yCoord, + zCoord - 1); + else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1 + && worldObj.getTileEntity(xCoord + 1, yCoord, + zCoord) != null + && worldObj.getTileEntity(xCoord + 1, yCoord, + zCoord) instanceof TileEntityMolder) + me = (TileEntityMolder) worldObj.getTileEntity(xCoord + 1, + yCoord, zCoord); + else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2 + && worldObj.getTileEntity(xCoord, yCoord, + zCoord + 1) != null + && worldObj.getTileEntity(xCoord, yCoord, + zCoord + 1) instanceof TileEntityMolder) + me = (TileEntityMolder) worldObj.getTileEntity(xCoord, yCoord, + zCoord + 1); + else if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 3 + && worldObj.getTileEntity(xCoord - 1, yCoord, + zCoord) != null + && worldObj.getTileEntity(xCoord - 1, yCoord, + zCoord) instanceof TileEntityMolder) + me = (TileEntityMolder) worldObj.getTileEntity(xCoord - 1, + yCoord, zCoord); + if (pouring && pouredQuantity > 0f) { + quantity -= 0.01f; + pouredQuantity -= 0.01f; + me.quantity += 0.01f; + if (!me.hasMoltenMetal) { + me.moltenMetal = moltenMetal; + me.hasMoltenMetal = true; + } + if (pouredQuantity <= 0f) { + pouring = false; + pouredQuantity = 0.1f; + me.cooling = ConfigHandler.INGOT_COOLING_TIME; + } + if (quantity <= 0f) { + quantity = 0f; + hasMoltenMetal = false; + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + me.cooling = ConfigHandler.INGOT_COOLING_TIME; + } + me.isDirty = true; + } + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, + nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java old mode 100644 new mode 100755 index 18f83b9..f20c853 --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java @@ -3,7 +3,9 @@ package darkknight.jewelrycraft.tileentity.renders; import java.awt.Color; import java.util.HashMap; import java.util.List; + import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.model.ModelDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import darkknight.jewelrycraft.util.Variables; @@ -23,142 +25,187 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; -public class TileEntityDisplayerRender extends TileEntitySpecialRenderer -{ - ModelDisplayer displayer = new ModelDisplayer(); - String texture = "textures/tileentities/Displayer.png"; - HashMap colors = new HashMap(){ - { - put(EnumChatFormatting.AQUA, 5636095); - put(EnumChatFormatting.BLACK, 0); - put(EnumChatFormatting.BLUE, 5592575); - put(EnumChatFormatting.DARK_AQUA, 43690); - put(EnumChatFormatting.DARK_BLUE, 170); - put(EnumChatFormatting.DARK_GRAY, 5592405); - put(EnumChatFormatting.DARK_GREEN, 43520); - put(EnumChatFormatting.DARK_PURPLE, 11141290); - put(EnumChatFormatting.DARK_RED, 11141120); - put(EnumChatFormatting.GOLD, 16755200); - put(EnumChatFormatting.GRAY, 11184810); - put(EnumChatFormatting.GREEN, 5635925); - put(EnumChatFormatting.LIGHT_PURPLE, 16733695); - put(EnumChatFormatting.RED, 16733525); - put(EnumChatFormatting.WHITE, 16777215); - put(EnumChatFormatting.YELLOW, 16777045); - } - }; - - @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); - TileEntityDisplayer disp = (TileEntityDisplayer)te; - ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture); - Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - displayer.render((Entity)null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F); - try{ - int block = disp.getBlockMetadata(); - if (disp != null && disp.hasObject && disp.object != null && disp.object.getItem() != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0)){ - int ind = -3; - GL11.glPushMatrix(); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, disp.object); - entityitem.hoverStart = 0.0F; - disp.object.stackSize = 1; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1 / 5, 0F); - GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F); - GL11.glColor4f(1F, 1F, 1F, 1F); - if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - else{ - GL11.glRotatef(180F, 0F, 1F, 0F); - RenderManager.instance.options.fancyGraphics = true; - int i = 15728880; - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderManager.instance.options.fancyGraphics = false; - } - EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 5D); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - if (player != null) renderLabel(disp.object.getDisplayName(), 0F, -0.171F * ind, 0F, block, disp, colors.get(disp.object.getRarity().rarityColor)); - GL11.glPopMatrix(); - ind++; - if (player != null && disp.quantity > 1){ - GL11.glPushMatrix(); - renderLabel("x" + Integer.toString(disp.quantity), 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); - GL11.glPopMatrix(); - ind++; - } - if (disp.object.getItem() != Items.map && player != null && disp.object.getTooltip(player, true) != null){ - List tooltips = disp.object.getTooltip(player, true); - if (disp.infoIndex + 5 > tooltips.size()) disp.infoIndex = 1; - if (tooltips.size() < 5) for(int i = 1; i < tooltips.size(); i++){ - String tooltip = tooltips.get(i).toString(); - RenderManager.instance.getFontRenderer(); - if (tooltip != ""){ - GL11.glPushMatrix(); - renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); - GL11.glPopMatrix(); - ind++; - } - } - else for(int i = disp.infoIndex; i < disp.infoIndex + 5; i++){ - String tooltip = tooltips.get(i).toString(); - RenderManager.instance.getFontRenderer(); - if (tooltip != ""){ - GL11.glPushMatrix(); - renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); - GL11.glPopMatrix(); - ind++; - } - } - } - } - } - catch(Exception e){} - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - protected void renderLabel(String text, double x, double y, double z, int metadata, TileEntity te, int color) - { - FontRenderer fontrenderer = RenderManager.instance.getFontRenderer(); - float width = 0.015F, height = 1F; - GL11.glRotatef(180F, 0F, 0F, 1F); - GL11.glRotatef(360 - metadata * 90F, 0F, 1F, 0F); - GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F); - GL11.glScalef(-0.015F, -0.019F, 0.015F); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - Tessellator tessellator = Tessellator.instance; - GL11.glDisable(GL11.GL_TEXTURE_2D); - int j = fontrenderer.getStringWidth(text) / 2; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(0.275F, 0.145F, 0.431F, 0.5F); - tessellator.addVertex(-33.333 - 0, 0D, 0.1D); - tessellator.addVertex(-33.333 - 0, 9D, 0.1D); - tessellator.addVertex(33.333 + 0, 9D, 0.1D); - tessellator.addVertex(33.333 + 0, 0D, 0.1D); - tessellator.draw(); - if (fontrenderer.getStringWidth(text) / 2 > 20){ - width = 0.9F / fontrenderer.getStringWidth(text); - height = 1F - fontrenderer.getStringWidth(text)/20*0.06F; - } - GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glScalef(width * 70F, height, 0F); - fontrenderer.drawString(text.replaceFirst("§0", "§r").replaceFirst("§1", "§r").replaceFirst("§2", "§r").replaceFirst("§3", "§r").replaceFirst("§4", "§r").replaceFirst("§5", "§r").replaceFirst("§6", "§r").replaceFirst("§7", "§r").replaceFirst("§8", "§r").replaceFirst("§9", "§r").replaceFirst("§a", "§r").replaceFirst("§b", "§r").replaceFirst("§c", "§r").replaceFirst("§d", "§r").replaceFirst("§e", "§r").replaceFirst("§f", "§r"), -j, 0, 1973790); - GL11.glPopMatrix(); - GL11.glTranslatef((float)x - 0.5f, (float)y - 0.5f, (float)z - 0.5F); - GL11.glScalef(width * 70F, height, 0F); - fontrenderer.drawString(text, -j, 0, color); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } +public class TileEntityDisplayerRender extends TileEntitySpecialRenderer { + private final class ChatColorMap + extends HashMap { + private static final long serialVersionUID = -6532830760345687407L; + { + put(EnumChatFormatting.AQUA, 5636095); + put(EnumChatFormatting.BLACK, 0); + put(EnumChatFormatting.BLUE, 5592575); + put(EnumChatFormatting.DARK_AQUA, 43690); + put(EnumChatFormatting.DARK_BLUE, 170); + put(EnumChatFormatting.DARK_GRAY, 5592405); + put(EnumChatFormatting.DARK_GREEN, 43520); + put(EnumChatFormatting.DARK_PURPLE, 11141290); + put(EnumChatFormatting.DARK_RED, 11141120); + put(EnumChatFormatting.GOLD, 16755200); + put(EnumChatFormatting.GRAY, 11184810); + put(EnumChatFormatting.GREEN, 5635925); + put(EnumChatFormatting.LIGHT_PURPLE, 16733695); + put(EnumChatFormatting.RED, 16733525); + put(EnumChatFormatting.WHITE, 16777215); + put(EnumChatFormatting.YELLOW, 16777045); + } + } + + ModelDisplayer displayer = + new ModelDisplayer(); + String texture = + "textures/tileentities/Displayer.png"; + HashMap colors = + new ChatColorMap(); + + @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); + TileEntityDisplayer disp = (TileEntityDisplayer) te; + ResourceLocation blockTexture = + new ResourceLocation(Variables.MODID, texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + displayer.render((Entity) null, disp.ringTranslation1, + disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, + 0.0625F); + try { + int block = disp.getBlockMetadata(); + if (disp != null && disp.hasObject && disp.object != null + && disp.object.getItem() != null + && disp.object != new ItemStack(Item.getItemById(0), 0, + 0)) { + int ind = -3; + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, disp.object); + entityitem.hoverStart = 0.0F; + disp.object.stackSize = 1; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1 / 5, + 0F); + GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F); + GL11.glColor4f(1F, 1F, 1F, 1F); + if (RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + int i = 15728880; + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords( + OpenGlHelper.lightmapTexUnit, j / 1.0F, + k / 1.0F); + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + EntityPlayer player = te.getWorldObj().getClosestPlayer( + te.xCoord, te.yCoord, te.zCoord, 5D); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + if (player != null) + renderLabel(disp.object.getDisplayName(), 0F, + -0.171F * ind, 0F, block, disp, colors.get( + disp.object.getRarity().rarityColor)); + GL11.glPopMatrix(); + ind++; + if (player != null && disp.quantity > 1) { + GL11.glPushMatrix(); + renderLabel("x" + Integer.toString(disp.quantity), 0F, + -0.171F * ind, 0F, block, disp, + Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + if (disp.object.getItem() != Items.map && player != null + && disp.object.getTooltip(player, true) != null) { + List tooltips = + disp.object.getTooltip(player, true); + if (disp.infoIndex + 5 > tooltips.size()) + disp.infoIndex = 1; + if (tooltips.size() < 5) + for (int i = 1; i < tooltips.size(); i++) { + String tooltip = tooltips.get(i).toString(); + RenderManager.instance.getFontRenderer(); + if (tooltip != "") { + GL11.glPushMatrix(); + renderLabel(tooltip, 0F, -0.171F * ind, 0F, + block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + } + else + for (int i = disp.infoIndex; + i < disp.infoIndex + 5; i++) { + String tooltip = tooltips.get(i).toString(); + RenderManager.instance.getFontRenderer(); + if (tooltip != "") { + GL11.glPushMatrix(); + renderLabel(tooltip, 0F, -0.171F * ind, 0F, + block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + } + } + } + } catch (Exception e) { + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + protected void renderLabel(String text, double x, double y, double z, + int metadata, TileEntity te, int color) { + FontRenderer fontrenderer = + RenderManager.instance.getFontRenderer(); + float width = 0.015F, height = 1F; + GL11.glRotatef(180F, 0F, 0F, 1F); + GL11.glRotatef(360 - metadata * 90F, 0F, 1F, 0F); + GL11.glTranslatef((float) x, (float) y, (float) z + 0.45F); + GL11.glScalef(-0.015F, -0.019F, 0.015F); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + int j = fontrenderer.getStringWidth(text) / 2; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(0.275F, 0.145F, 0.431F, 0.5F); + tessellator.addVertex(-33.333 - 0, 0D, 0.1D); + tessellator.addVertex(-33.333 - 0, 9D, 0.1D); + tessellator.addVertex(33.333 + 0, 9D, 0.1D); + tessellator.addVertex(33.333 + 0, 0D, 0.1D); + tessellator.draw(); + if (fontrenderer.getStringWidth(text) / 2 > 20) { + width = 0.9F / fontrenderer.getStringWidth(text); + height = 1F - fontrenderer.getStringWidth(text) / 20 * 0.06F; + } + GL11.glTranslatef((float) x + 1f, (float) y + 1f, (float) z); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glScalef(width * 70F, height, 0F); + fontrenderer.drawString( + text.replaceFirst("�0", "�r").replaceFirst("�1", "�r") + .replaceFirst("�2", "�r").replaceFirst("�3", "�r") + .replaceFirst("�4", "�r").replaceFirst("�5", "�r") + .replaceFirst("�6", "�r").replaceFirst("�7", "�r") + .replaceFirst("�8", "�r").replaceFirst("�9", "�r") + .replaceFirst("�a", "�r").replaceFirst("�b", "�r") + .replaceFirst("�c", "�r").replaceFirst("�d", "�r") + .replaceFirst("�e", "�r").replaceFirst("�f", "�r"), + -j, 0, 1973790); + GL11.glPopMatrix(); + GL11.glTranslatef((float) x - 0.5f, (float) y - 0.5f, + (float) z - 0.5F); + GL11.glScalef(width * 70F, height, 0F); + fontrenderer.drawString(text, -j, 0, color); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java old mode 100644 new mode 100755 index d639d93..4dcdb1e --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.model.ModelHandPedestal; import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -10,38 +11,42 @@ import net.minecraft.util.ResourceLocation; /** * @author Paul Fulham (pau101) */ -public class TileEntityHandPedestalRender extends TileEntitySpecialRenderer -{ - private ModelHandPedestal model; - private ResourceLocation texture; - - /** - * @param model - * @param texture - */ - public TileEntityHandPedestalRender(ModelHandPedestal model, ResourceLocation texture) - { - this.model = model; - this.texture = texture; - } - - /** - * @param te - * @param x - * @param y - * @param z - * @param partialRenderTicks - */ - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialRenderTicks) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - TileEntityHandPedestal pedestal = (TileEntityHandPedestal)te; - bindTexture(texture); - GL11.glRotatef(180, 0, 0, 1); - GL11.glRotatef(pedestal.getWorldObj() == null ? 180 : pedestal.getBlockMetadata() % 8 / 8F * 360, 0, 1, 0); - model.render(pedestal, partialRenderTicks, 0.0625F); - GL11.glPopMatrix(); - } +public class TileEntityHandPedestalRender + extends TileEntitySpecialRenderer { + private ModelHandPedestal model; + private ResourceLocation texture; + + /** + * @param model + * @param texture + */ + public TileEntityHandPedestalRender(ModelHandPedestal model, + ResourceLocation texture) { + this.model = model; + this.texture = texture; + } + + /** + * @param te + * @param x + * @param y + * @param z + * @param partialRenderTicks + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, + double z, float partialRenderTicks) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, + (float) z + 0.5F); + TileEntityHandPedestal pedestal = (TileEntityHandPedestal) te; + bindTexture(texture); + GL11.glRotatef(180, 0, 0, 1); + GL11.glRotatef( + pedestal.getWorldObj() == null ? 180 + : pedestal.getBlockMetadata() % 8 / 8F * 360, + 0, 1, 0); + model.render(pedestal, partialRenderTicks, 0.0625F); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java old mode 100644 new mode 100755 index 02b12aa..a62d21d --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.util.Variables; @@ -16,122 +17,144 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRenderer -{ - ModelJewlersCraftingBench modelTable = new ModelJewlersCraftingBench(); - String texture = "textures/tileentities/JewelrsCraftingBench.png"; - - /** - * @param te - * @param x - * @param y - * @param z - * @param scale - */ - @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 blockTexture = new ResourceLocation(Variables.MODID, texture); - Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - TileEntityJewelrsCraftingTable jt = (TileEntityJewelrsCraftingTable)te; - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - try{ - int block = te.getBlockMetadata(); - if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - else if (block == 2){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - }else if (block == 3){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); - } - } - catch(Exception e){} - modelTable.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - if (jt != null){ - if (jt.hasJewelry && jt.jewelry.getIconIndex() != null && jt.jewelry.getIconIndex().getIconName() != ""){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.jewelry); - entityitem.getEntityItem().stackSize = 1; - entityitem.hoverStart = 0.0F; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.55F, -1.5F, -0.45F); - GL11.glRotatef(jt.angle, 0F, 1F, 0F); - if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - else{ - GL11.glRotatef(180F, 0F, 1F, 0F); - RenderManager.instance.options.fancyGraphics = true; - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderManager.instance.options.fancyGraphics = false; - } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - if (jt.hasEndItem && jt.endItem.getIconIndex().getIconName() != ""){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.endItem); - entityitem.getEntityItem().stackSize = 1; - entityitem.hoverStart = 0.0F; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.0F, -1.6F, 0.6F); - GL11.glRotatef(jt.angle, 0F, 1F, 0F); - if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - else{ - GL11.glRotatef(180F, 0F, 1F, 0F); - RenderManager.instance.options.fancyGraphics = true; - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderManager.instance.options.fancyGraphics = false; - } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - if (jt.hasGem && jt.gem.getIconIndex().getIconName() != ""){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.gem); - entityitem.getEntityItem().stackSize = 1; - entityitem.hoverStart = 0.0F; - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(-0.55F, -1.5F, -0.45F); - GL11.glRotatef(jt.angle, 0F, 1F, 0F); - if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - else{ - GL11.glRotatef(180F, 0F, 1F, 0F); - RenderManager.instance.options.fancyGraphics = true; - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderManager.instance.options.fancyGraphics = false; - } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - } - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - */ - public void adjustLightFixture(World world, int i, int j, int k, Block block) - { - Tessellator tess = Tessellator.instance; - float brightness = block.getLightOpacity(world, i, j, k); - int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - int modulousModifier = skyLight % 65536; - int divModifier = skyLight / 65536; - tess.setColorOpaque_F(brightness, brightness, brightness); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); - } +public class TileEntityJewelrsCraftingTableRender + extends TileEntitySpecialRenderer { + ModelJewlersCraftingBench modelTable = + new ModelJewlersCraftingBench(); + String texture = + "textures/tileentities/JewelrsCraftingBench.png"; + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @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 blockTexture = + new ResourceLocation(Variables.MODID, texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + TileEntityJewelrsCraftingTable jt = + (TileEntityJewelrsCraftingTable) te; + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try { + int block = te.getBlockMetadata(); + if (block == 1) + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + } else if (block == 3) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } catch (Exception e) { + } + modelTable.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, + 0.0625F); + if (jt != null) { + if (jt.hasJewelry && jt.jewelry.getIconIndex() != null + && jt.jewelry.getIconIndex().getIconName() != "") { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, jt.jewelry); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasEndItem + && jt.endItem.getIconIndex().getIconName() != "") { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, jt.endItem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasGem && jt.gem.getIconIndex().getIconName() != "") { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, jt.gem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, + Block block) { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, + modulousModifier, divModifier); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java old mode 100644 new mode 100755 index 786568a..bf0a385 --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -8,25 +9,32 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.passive.EntityPig; import net.minecraft.tileentity.TileEntity; -public class TileEntityMidasTouchRender extends TileEntitySpecialRenderer -{ - @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) - { - GL11.glPushMatrix(); - TileEntityMidasTouch midas = (TileEntityMidasTouch)te; - if (midas.target != null){ - EntityLiving target = ((EntityLiving)midas.target); - target.hurtTime = 0; - GL11.glTranslatef(0.5F, 0.0F, 0.5F); - GL11.glColor3f(1.0F, 1.0F, 0.0F); - RenderManager.instance.renderEntityWithPosYaw(target, midas.xCoord - RenderManager.instance.renderPosX, midas.yCoord - RenderManager.instance.renderPosY, midas.zCoord - RenderManager.instance.renderPosZ, 0F, 1F); - } - else{ - GL11.glTranslatef(0.5F, 0.0F, 0.5F); - GL11.glColor3f(1.0F, 1.0F, 0.0F); - RenderManager.instance.renderEntityWithPosYaw(new EntityPig(te.getWorldObj()), midas.xCoord - RenderManager.instance.renderPosX, midas.yCoord - RenderManager.instance.renderPosY, midas.zCoord - RenderManager.instance.renderPosZ, 0F, 1F); - } - GL11.glPopMatrix(); - } +public class TileEntityMidasTouchRender extends TileEntitySpecialRenderer { + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, + double z, float scale) { + GL11.glPushMatrix(); + TileEntityMidasTouch midas = (TileEntityMidasTouch) te; + if (midas.target != null) { + EntityLiving target = ((EntityLiving) midas.target); + target.hurtTime = 0; + GL11.glTranslatef(0.5F, 0.0F, 0.5F); + GL11.glColor3f(1.0F, 1.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(target, + midas.xCoord - RenderManager.renderPosX, + midas.yCoord - RenderManager.renderPosY, + midas.zCoord - RenderManager.renderPosZ, 0F, + 1F); + } else { + GL11.glTranslatef(0.5F, 0.0F, 0.5F); + GL11.glColor3f(1.0F, 1.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw( + new EntityPig(te.getWorldObj()), + midas.xCoord - RenderManager.renderPosX, + midas.yCoord - RenderManager.renderPosY, + midas.zCoord - RenderManager.renderPosZ, 0F, + 1F); + } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java old mode 100644 new mode 100755 index 51e0677..6f55e1c --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.model.ModelMolder; @@ -23,116 +24,139 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class TileEntityMolderRender extends TileEntitySpecialRenderer -{ - ModelMolder modelMolder = new ModelMolder(); - - /** - * @param te - * @param x - * @param y - * @param z - * @param scale - */ - @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); - TileEntityMolder me = (TileEntityMolder)te; - String texture = "textures/tileentities/Molder.png"; - ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture); - Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - try{ - int block = me.getBlockMetadata(); - if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - else if (block == 2){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - }else if (block == 3){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); - } - } - catch(Exception e){} - modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics; - if (me != null){ - if (me.hasMold){ - GL11.glPushMatrix(); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.mold); - entityitem.getEntityItem().stackSize = 1; - entityitem.hoverStart = 0.0F; - GL11.glTranslatef(0F, 1.43F, -0.28F); - GL11.glScalef(1.25F, 1.0F, 1.25F); - GL11.glRotatef(90F, 1F, 0F, 0f); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - if (entityitem != null){ - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.03D, 0.0F, 0.0F); - } - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; - GL11.glPopMatrix(); - } - if (me.hasJewelBase && me.jewelBase != null && me.jewelBase.getItem() != Item.getItemFromBlock(Blocks.air) && me.jewelBase.getIconIndex() != null && me.jewelBase.getIconIndex().getIconName() != ""){ - GL11.glPushMatrix(); - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.jewelBase); - entityitem.getEntityItem().stackSize = 1; - entityitem.hoverStart = 0.0F; - GL11.glTranslatef(0F, 1.4F, -0.28F); - GL11.glScalef(1.25F, 1.0F, 1.25F); - GL11.glRotatef(90F, 1F, 0F, 0f); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - if (entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.01D, 0.0F, 0.0F); - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; - GL11.glColor4f(1, 1F, 1F, 1.0F); - GL11.glPopMatrix(); - } - if (me.hasMoltenMetal && me.moltenMetal != null && me.moltenMetal != new ItemStack(Item.getItemById(0), 0, 0)){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - if (JewelrycraftMod.fancyRender){ - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(1, 1, 0, 0); - } - ItemStack metal = new ItemStack(ItemList.metal); - ItemStack ingot = me.moltenMetal.copy(); - JewelryNBT.addMetal(metal, ingot); - EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); - moltenMetal.getEntityItem().stackSize = 1; - moltenMetal.hoverStart = 0.0F; - GL11.glTranslatef(-0F, 1.4f - 0.005f * me.quantity, -0.29F); - GL11.glScalef(1.2F, 1.0F, 1.4F); - GL11.glRotatef(90F, 1F, 0F, 0f); - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; - if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - } - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - */ - public void adjustLightFixture(World world, int i, int j, int k, Block block) - { - Tessellator tess = Tessellator.instance; - float brightness = block.getLightOpacity(world, i, j, k); - int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - int modulousModifier = skyLight % 65536; - int divModifier = skyLight / 65536; - tess.setColorOpaque_F(brightness, brightness, brightness); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); - } +public class TileEntityMolderRender extends TileEntitySpecialRenderer { + ModelMolder modelMolder = new ModelMolder(); + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @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); + TileEntityMolder me = (TileEntityMolder) te; + String texture = "textures/tileentities/Molder.png"; + ResourceLocation blockTexture = + new ResourceLocation(Variables.MODID, texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try { + int block = me.getBlockMetadata(); + if (block == 1) + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + } else if (block == 3) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } catch (Exception e) { + } + modelMolder.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, + 0.0625F); + boolean fancyGraphics = + Minecraft.getMinecraft().gameSettings.fancyGraphics; + if (me != null) { + if (me.hasMold) { + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, me.mold); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.43F, -0.28F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + if (entityitem != null) { + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.03D, 0.0F, 0.0F); + } + Minecraft.getMinecraft().gameSettings.fancyGraphics = + fancyGraphics; + GL11.glPopMatrix(); + } + if (me.hasJewelBase && me.jewelBase != null + && me.jewelBase.getItem() != Item + .getItemFromBlock(Blocks.air) + && me.jewelBase.getIconIndex() != null + && me.jewelBase.getIconIndex().getIconName() != "") { + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, me.jewelBase); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.4F, -0.28F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + if (entityitem != null) + RenderManager.instance.renderEntityWithPosYaw( + entityitem, 0.0D, 0.0D, 0.01D, 0.0F, 0.0F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = + fancyGraphics; + GL11.glColor4f(1, 1F, 1F, 1.0F); + GL11.glPopMatrix(); + } + if (me.hasMoltenMetal && me.moltenMetal != null + && me.moltenMetal != new ItemStack(Item.getItemById(0), + 0, 0)) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender) { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + ItemStack metal = new ItemStack(ItemList.metal); + ItemStack ingot = me.moltenMetal.copy(); + JewelryNBT.addMetal(metal, ingot); + EntityItem moltenMetal = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, metal); + moltenMetal.getEntityItem().stackSize = 1; + moltenMetal.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.4f - 0.005f * me.quantity, + -0.29F); + GL11.glScalef(1.2F, 1.0F, 1.4F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(moltenMetal, + 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, + Block block) { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, + modulousModifier, divModifier); + } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java old mode 100644 new mode 100755 index e347901..60277a2 --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java @@ -3,6 +3,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; import org.lwjgl.util.glu.Sphere; + import darkknight.jewelrycraft.model.ModelShadowEye; import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; import darkknight.jewelrycraft.util.Variables; @@ -17,85 +18,97 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -public class TileEntityShadowEyeRender extends TileEntitySpecialRenderer -{ - ModelShadowEye eye = new ModelShadowEye(); - Sphere shadow = new Sphere(); - - /** - * @param te - * @param x - * @param y - * @param z - * @param scale - */ - @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.6F, (float)z + 0.5F); - TileEntityShadowEye eyeS = (TileEntityShadowEye)te; - String texture = "textures/tileentities/ShadowEye" + eyeS.opening + ".png"; - ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture); - Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - try{ - int block = te.getBlockMetadata(); - if (block == 0) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - else if (block == 1) GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - else if (block == 2) GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); - } - catch(Exception e){} - if (te != null && te.getWorldObj() != null) - { - EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 16D); - if(player != null) - { - float x1 = (float) (te.xCoord - player.posX) + 0.5F; - float y1 = (float) (te.yCoord - player.posY) + 0.5F; - float z1 = (float) (te.zCoord - player.posZ) + 0.5F; - eyeS.model.render(player, 0, (float)(x1 >= 0 ? Math.atan(z1 / x1) : Math.PI + Math.atan(z1 / x1)), (float)(y1 >= 0 ? Math.atan(y1 / x1) : Math.atan(y1 / x1)), te.blockMetadata, eyeS.opening, 0.0625F); - } +public class TileEntityShadowEyeRender extends TileEntitySpecialRenderer { + ModelShadowEye eye = new ModelShadowEye(); + Sphere shadow = new Sphere(); + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @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.6F, + (float) z + 0.5F); + TileEntityShadowEye eyeS = (TileEntityShadowEye) te; + String texture = + "textures/tileentities/ShadowEye" + eyeS.opening + ".png"; + ResourceLocation blockTexture = + new ResourceLocation(Variables.MODID, texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try { + int block = te.getBlockMetadata(); + if (block == 0) + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 1) + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + else if (block == 2) + GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); + } catch (Exception e) { + } + if (te != null && te.getWorldObj() != null) { + EntityPlayer player = te.getWorldObj().getClosestPlayer( + te.xCoord, te.yCoord, te.zCoord, 16D); + if (player != null) { + float x1 = (float) (te.xCoord - player.posX) + 0.5F; + float y1 = (float) (te.yCoord - player.posY) + 0.5F; + float z1 = (float) (te.zCoord - player.posZ) + 0.5F; + eyeS.model.render(player, 0, + (float) (x1 >= 0 ? Math.atan(z1 / x1) + : Math.PI + Math.atan(z1 / x1)), + (float) (y1 >= 0 ? Math.atan(y1 / x1) + : Math.atan(y1 / x1)), + te.blockMetadata, eyeS.opening, 0.0625F); + } + + } else + eyeS.model.render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, + 0.0625F); + + if (eyeS.opening == 4) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE_MINUS_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 1F); + GL11.glRotatef(eyeS.timer * 10F, 0, 1, 0); + GL11.glRotatef(90.0F, 1, 0, 0); + shadow.setNormals(GLU.GLU_NONE); + shadow.draw(7.5F, 6, 6); + GL11.glScalef(-1, -1, -1); + shadow.draw(7.5F, 6, 6); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } - } - else eyeS.model.render((Entity)null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); - - if (eyeS.opening == 4){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(0.0F, 0.0F, 0.0F, 1F); - GL11.glRotatef(eyeS.timer*10F, 0, 1, 0); - GL11.glRotatef(90.0F, 1, 0, 0); - shadow.setNormals(GLU.GLU_NONE); - shadow.draw(7.5F, 6, 6); - GL11.glScalef(-1,-1,-1); - shadow.draw(7.5F, 6, 6); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPopMatrix(); - } - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - */ - public void adjustLightFixture(World world, int i, int j, int k, Block block) - { - Tessellator tess = Tessellator.instance; - float brightness = block.getLightOpacity(world, i, j, k); - int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); - int modulousModifier = skyLight % 65536; - int divModifier = skyLight / 65536; - tess.setColorOpaque_F(brightness, brightness, brightness); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, + Block block) { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, + modulousModifier, divModifier); } } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java old mode 100644 new mode 100755 index 85a90d2..dd960d0 --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java @@ -6,15 +6,15 @@ import net.minecraft.util.ResourceLocation; /** * @author Paul Fulham (pau101) */ -public class TileEntityShadowHandRender extends TileEntityHandPedestalRender -{ - - /** - * @param model - * @param texture - */ - public TileEntityShadowHandRender(ModelHandPedestal model, ResourceLocation texture) - { - super(model, texture); - } +public class TileEntityShadowHandRender + extends TileEntityHandPedestalRender { + + /** + * @param model + * @param texture + */ + public TileEntityShadowHandRender(ModelHandPedestal model, + ResourceLocation texture) { + super(model, texture); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java old mode 100644 new mode 100755 index fa98f2c..1cbd32c --- a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.tileentity.renders; import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.model.ModelSmelter; @@ -19,105 +20,122 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -public class TileEntitySmelterRender extends TileEntitySpecialRenderer -{ - ModelSmelter modelSmelter = new ModelSmelter(); - public static final float p = 1 / 16, p3 = 3 * p, p13 = 13 * p, p15 = 15 * p; - - /** - * @param te - * @param x - * @param y - * @param z - * @param scale - */ - @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); - String texture = "textures/tileentities/Smelter.png"; - ResourceLocation blockTexture = new ResourceLocation(Variables.MODID, texture); - Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - TileEntitySmelter st = (TileEntitySmelter)te; - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - try{ - int block = te.getBlockMetadata(); - if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - else if (block == 2){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - }else if (block == 3){ - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); - } - } - catch(Exception e){} - boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics; - modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - if (scale != 0){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - if (JewelrycraftMod.fancyRender){ - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(1, 1, 0, 0); - } - EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(Blocks.lava, 1, 1)); - entityitem.hoverStart = 0.0F; - GL11.glTranslatef(-0F, 1.25F, -0.345F); - GL11.glScalef(1.2F, 1.0F, 1.7F); - GL11.glRotatef(90F, 1F, 0F, 0f); - RenderItem.renderInFrame = true; - int i = 15728880; - int j = i % 65536; - int k = i / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); - RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; - if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - if (st != null){ - if (st.hasMetal && st.metal != null && st.metal.getItem() != null){ - GL11.glPushMatrix(); - EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, st.metal); - metal.getEntityItem().stackSize = 1; - metal.hoverStart = 0.0F; - GL11.glRotatef(-50F, 1F, 0F, 0F); - GL11.glRotatef(-50F, 0F, 0F, 1F); - GL11.glRotatef(180F, 1F, 0F, 0F); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(-0.9F, -0.9F, -1.6F); - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; - GL11.glPopMatrix(); - } - if (st.hasMoltenMetal && st.moltenMetal != null && st.moltenMetal.getItem() != null){ - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - if (JewelrycraftMod.fancyRender){ - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(1, 1, 0, 0); - } - ItemStack metal = new ItemStack(ItemList.metal); - ItemStack ingot = st.moltenMetal.copy(); - JewelryNBT.addMetal(metal, ingot); - EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); - moltenMetal.getEntityItem().stackSize = 1; - moltenMetal.hoverStart = 0.0F; - GL11.glTranslatef(-0F, 1.00f - .4F * st.quantity, -0.14F); - GL11.glScalef(0.71F, 1F, 0.84F); - GL11.glRotatef(90F, 1F, 0F, 0f); - RenderItem.renderInFrame = true; - RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); - RenderItem.renderInFrame = false; - if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - } - GL11.glPopMatrix(); - } +public class TileEntitySmelterRender extends TileEntitySpecialRenderer { + ModelSmelter modelSmelter = new ModelSmelter(); + public static final float p = 1 / 16, p3 = 3 * p, + p13 = 13 * p, p15 = 15 * p; + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @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); + String texture = "textures/tileentities/Smelter.png"; + ResourceLocation blockTexture = + new ResourceLocation(Variables.MODID, texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + TileEntitySmelter st = (TileEntitySmelter) te; + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try { + int block = te.getBlockMetadata(); + if (block == 1) + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + } else if (block == 3) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } catch (Exception e) { + } + boolean fancyGraphics = + Minecraft.getMinecraft().gameSettings.fancyGraphics; + modelSmelter.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, + 0.0625F); + if (scale != 0) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender) { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, + 0.0D, 0.0D, new ItemStack(Blocks.lava, 1, 1)); + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.25F, -0.345F); + GL11.glScalef(1.2F, 1.0F, 1.7F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + int i = 15728880; + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords( + OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, + 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (st != null) { + if (st.hasMetal && st.metal != null + && st.metal.getItem() != null) { + GL11.glPushMatrix(); + EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, + 0.0D, 0.0D, st.metal); + metal.getEntityItem().stackSize = 1; + metal.hoverStart = 0.0F; + GL11.glRotatef(-50F, 1F, 0F, 0F); + GL11.glRotatef(-50F, 0F, 0F, 1F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.9F, -0.9F, -1.6F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, + 0.0D, 0.0D, 0.0F, 0.0F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = + fancyGraphics; + GL11.glPopMatrix(); + } + if (st.hasMoltenMetal && st.moltenMetal != null + && st.moltenMetal.getItem() != null) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender) { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + ItemStack metal = new ItemStack(ItemList.metal); + ItemStack ingot = st.moltenMetal.copy(); + JewelryNBT.addMetal(metal, ingot); + EntityItem moltenMetal = new EntityItem(te.getWorldObj(), + 0.0D, 0.0D, 0.0D, metal); + moltenMetal.getEntityItem().stackSize = 1; + moltenMetal.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.00f - .4F * st.quantity, -0.14F); + GL11.glScalef(0.71F, 1F, 0.84F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(moltenMetal, + 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + } } -- cgit v1.2.3