summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
commit420faddca46e70e3a70def168fb4e452ef193b0d (patch)
tree247e334012e4bf9e4fa6d42718bf601ce6bd42d9 /java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
parent3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b (diff)
Added just a butt ton of stuff, also thanks to pau101 for helping me with the Hand Pedestal animation :)
Diffstat (limited to 'java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java')
-rw-r--r--java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java167
1 files changed, 84 insertions, 83 deletions
diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
index 22d0465..83f2cb2 100644
--- a/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
+++ b/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
@@ -1,10 +1,6 @@
package darkknight.jewelrycraft.tileentity;
import java.util.Random;
-
-import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
-
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -12,6 +8,8 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
public class TileEntitySmelter extends TileEntity
{
@@ -20,19 +18,25 @@ public class TileEntitySmelter extends TileEntity
public ItemStack metal, moltenMetal;
public float quantity, pouredQuantity = 0.1f;
+ /**
+ *
+ */
public TileEntitySmelter()
{
- this.melting = 0;
- this.pouring = false;
- this.flow = 0;
- this.quantity = 0f;
- this.hasMetal = false;
- this.hasMoltenMetal = false;
- this.metal = new ItemStack(Item.getItemById(0), 0, 0);
- this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
- this.isDirty = false;
+ 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)
{
@@ -44,121 +48,110 @@ public class TileEntitySmelter extends TileEntity
nbt.setBoolean("pouring", pouring);
NBTTagCompound tag = new NBTTagCompound();
NBTTagCompound tag1 = new NBTTagCompound();
- this.metal.writeToNBT(tag);
+ metal.writeToNBT(tag);
nbt.setTag("metal", tag);
- this.moltenMetal.writeToNBT(tag1);
+ moltenMetal.writeToNBT(tag1);
nbt.setTag("moltenMetal", tag1);
}
+ /**
+ * @param nbt
+ */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
- this.melting = nbt.getInteger("melting");
- this.quantity = nbt.getFloat("quantity");
- this.hasMetal = nbt.getBoolean("hasMetal");
- this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal");
- this.pouring = nbt.getBoolean("pouring");
- this.metal = new ItemStack(Item.getItemById(0), 0, 0);
- this.metal.readFromNBT(nbt.getCompoundTag("metal"));
- this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
- this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal"));
+ 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)
- {
+ if (isDirty){
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
isDirty = false;
}
if (p > 0) --p;
else p = 5;
- if (n == 0 && p == 0)
- {
+ if (n == 0 && p == 0){
flow += 16;
if (flow >= 16 * 20) n = 1;
}
- if (n == 1 && p == 0)
- {
+ if (n == 1 && p == 0){
flow -= 16;
if (flow <= 0) n = 0;
}
- if (this.hasMetal)
- {
- for (int l = 0; l < 2; ++l)
- this.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 = this.xCoord + rand.nextFloat();
- double d7 = this.yCoord;
- double d6 = this.zCoord + rand.nextFloat();
- this.worldObj.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
+ 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 (this.hasMetal && !this.hasMoltenMetal)
- {
+ if (hasMetal && !hasMoltenMetal){
boolean isOre = JewelrycraftUtil.isOre(metal);
- if (melting > 0) this.melting--;
- if (melting == 0)
- {
- this.hasMetal = false;
- if (!isOre) this.moltenMetal = metal;
- else
- {
- this.moltenMetal = JewelrycraftUtil.getIngotFromOre(metal.getItem());
+ if (melting > 0) melting--;
+ if (melting == 0){
+ hasMetal = false;
+ if (!isOre) moltenMetal = metal;
+ else{
+ moltenMetal = JewelrycraftUtil.getIngotFromOre(metal.getItem());
moltenMetal.stackSize *= 2;
}
- this.hasMoltenMetal = true;
- if (!isOre) this.quantity = 0.1f * metal.stackSize;
- else this.quantity = 0.2f * metal.stackSize;
- this.metal = new ItemStack(Item.getItemById(0), 0, 0);
+ 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;
- this.isDirty = true;
+ isDirty = true;
}
- }
- else if (this.hasMoltenMetal)
- {
+ }else if (hasMoltenMetal){
boolean isOre = JewelrycraftUtil.isOre(metal);
- if (melting > 0) this.melting--;
- if (melting == 0)
- {
- this.hasMetal = false;
- if (!isOre) this.moltenMetal.stackSize += this.metal.stackSize;
- else this.moltenMetal.stackSize += this.metal.stackSize * 2;
- if (!isOre) this.quantity += 0.1f * metal.stackSize;
- else this.quantity += 0.2f * metal.stackSize;
- this.metal = new ItemStack(Item.getItemById(0), 0, 0);
+ 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;
- this.isDirty = true;
+ 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)
- {
+ 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)
- {
+ if (!me.hasMoltenMetal){
me.moltenMetal = moltenMetal;
me.hasMoltenMetal = true;
}
- if (pouredQuantity <= 0f)
- {
+ if (pouredQuantity <= 0f){
pouring = false;
pouredQuantity = 0.1f;
me.cooling = ConfigHandler.ingotCoolingTime;
}
- if (quantity <= 0f)
- {
+ if (quantity <= 0f){
quantity = 0f;
hasMoltenMetal = false;
moltenMetal = new ItemStack(Item.getItemById(0), 0, 0);
@@ -169,13 +162,21 @@ public class TileEntitySmelter extends TileEntity
}
}
+ /**
+ * @return
+ */
+ @Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
- this.writeToNBT(nbttagcompound);
- return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound);
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
}
+ /**
+ * @param net
+ * @param packet
+ */
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
{