summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:50:07 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:50:07 -0400
commit4f7ad220df0438b6f3382110577b53f29da46453 (patch)
tree07d5e7c812721753cdbe3df7226dad5dc3802c29 /src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
parent01c8701b68986ccfa83e902515716838d6829311 (diff)
Update of all changes
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java')
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java382
1 files changed, 197 insertions, 185 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
index 830da74..1b0ec8a 100644..100755
--- 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);
- }
}