summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-26 00:50:16 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-26 00:50:16 +0200
commit1a3455b24d90b0def912c28467cbc51662d660e0 (patch)
tree90232ffe1b1a52ab43594b438cfac44ad3c0b60e /common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
parent1997f4547812121223836dcacfcb31ea63acdda6 (diff)
Major changes. Thanks domi for helping me with the chest linking ring :)
Diffstat (limited to 'common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java')
-rw-r--r--common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java101
1 files changed, 18 insertions, 83 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
index ebbae64..bf1d82f 100644
--- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
+++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
@@ -1,17 +1,12 @@
package darkknight.jewelrycraft.block;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.util.Random;
-
-import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
@@ -19,44 +14,19 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import darkknight.jewelrycraft.config.ConfigHandler;
-import darkknight.jewelrycraft.item.ItemList;
import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
public class BlockJewelrsCraftingTable extends BlockContainer
{
Random rand = new Random();
- public static ArrayList<ItemStack> modifiers = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> jewel = new ArrayList<ItemStack>();
- public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>();
-
protected BlockJewelrsCraftingTable(int par1, Material par2Material)
{
super(par1, par2Material);
this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F);
}
- public static void addStuff()
- {
- //Modifiers
- modifiers.add(new ItemStack(Item.blazePowder));
- modifiers.add(new ItemStack(Item.sugar));
- modifiers.add(new ItemStack(Block.chest));
- modifiers.add(new ItemStack(Item.pickaxeIron));
- modifiers.add(new ItemStack(Item.bed));
- modifiers.add(new ItemStack(Item.eyeOfEnder));
-
- //Jewels
- jewel.add(new ItemStack(Item.enderPearl));
- jewel.add(new ItemStack(Item.diamond));
- jewel.add(new ItemStack(Item.emerald));
- jewel.add(new ItemStack(Block.obsidian));
- jewel.add(new ItemStack(Item.netherStar));
-
- //Jewelry
- jewelry.add(new ItemStack(ItemList.ring));
- }
-
@Override
public TileEntity createNewTileEntity(World world)
{
@@ -76,14 +46,14 @@ public class BlockJewelrsCraftingTable extends BlockContainer
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && !world.isRemote)
{
- if (!te.hasEndItem && !te.hasJewelry && item != null && isJewelry(item))
+ if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item))
{
if(te.hasModifier && te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("modifier") && item.getTagCompound().hasKey("jewel"))
- entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrymodifiedfull"));
+ entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrymodifiedfull"));
else if(te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("jewel"))
- entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsjewel"));
+ entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"));
else if(te.hasModifier && item.hasTagCompound() && item.getTagCompound().hasKey("modifier"))
- entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsmodifier"));
+ entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"));
else
{
te.jewelry = item.copy();
@@ -94,10 +64,10 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.isDirty = true;
}
}
- if (!te.hasEndItem && !te.hasModifier && item != null && isModifier(item))
+ if (!te.hasEndItem && !te.hasModifier && item != null && JewelrycraftUtil.isModifier(item))
{
if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("modifier"))
- entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsmodifier"));
+ entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"));
else
{
te.modifier = item.copy();
@@ -109,10 +79,10 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.isDirty = true;
}
}
- if (!te.hasEndItem && !te.hasJewel && item != null && isJewel(item))
+ if (!te.hasEndItem && !te.hasJewel && item != null && JewelrycraftUtil.isJewel(item))
{
if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("jewel"))
- entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsjewel"));
+ entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"));
else
{
te.jewel = item.copy();
@@ -125,7 +95,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer
}
}
if (te.timer <= 0 && !te.hasEndItem && te.hasJewelry && (te.hasModifier || te.hasJewel)){ te.timer = ConfigHandler.jewelryCraftingTime; te.angle = 0;}
- if (te.hasEndItem && item != null) entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.hasenditem"));
+ if (te.hasEndItem && item != null) entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.hasenditem"));
if (te.hasModifier && entityPlayer.isSneaking())
{
@@ -134,6 +104,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasModifier = false;
te.timer = 0;
te.angle = 0F;
+ te.isDirty = true;
world.markTileEntityForDespawn(te);
world.setBlockTileEntity(i, j, k, te);
}
@@ -144,6 +115,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewelry = false;
te.timer = 0;
te.angle = 0F;
+ te.isDirty = true;
world.markTileEntityForDespawn(te);
world.setBlockTileEntity(i, j, k, te);
}
@@ -154,6 +126,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewel = false;
te.timer = 0;
te.angle = 0F;
+ te.isDirty = true;
world.markTileEntityForDespawn(te);
world.setBlockTileEntity(i, j, k, te);
}
@@ -161,45 +134,6 @@ public class BlockJewelrsCraftingTable extends BlockContainer
return true;
}
- public boolean isModifier(ItemStack item)
- {
- Iterator<ItemStack> i = modifiers.iterator();
-
- while (i.hasNext())
- {
- ItemStack temp = i.next();
- if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage())
- return true;
- }
- return false;
- }
-
- public boolean isJewel(ItemStack item)
- {
- Iterator<ItemStack> i = jewel.iterator();
-
- while (i.hasNext())
- {
- ItemStack temp = i.next();
- if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage())
- return true;
- }
- return false;
- }
-
- public boolean isJewelry(ItemStack item)
- {
- Iterator<ItemStack> i = jewelry.iterator();
-
- while (i.hasNext())
- {
- ItemStack temp = i.next();
- if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage())
- return true;
- }
- return false;
- }
-
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);
@@ -241,13 +175,14 @@ public class BlockJewelrsCraftingTable extends BlockContainer
dropItem(te.worldObj, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy());
te.endItem = new ItemStack(0, 0, 0);
te.hasEndItem = false;
+ te.isDirty = true;
world.markTileEntityForDespawn(te);
world.setBlockTileEntity(i, j, k, te);
}
- else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.table.iscrafting", te.jewelry.getDisplayName()) + " (" + ((ConfigHandler.jewelryCraftingTime - te.timer) * 100 / ConfigHandler.jewelryCraftingTime) + "%)");
- else if ((!te.hasModifier || !te.hasJewel) && !te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingjewelryandmodifierorjewel"));
- else if (!te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingjewelry"));
- else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingmodifierorjewel"));
+ else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.table.iscrafting", te.jewelry.getDisplayName()) + " (" + ((ConfigHandler.jewelryCraftingTime - te.timer) * 100 / ConfigHandler.jewelryCraftingTime) + "%)");
+ else if ((!te.hasModifier || !te.hasJewel) && !te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelryandmodifierorjewel"));
+ else if (!te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelry"));
+ else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingmodifierorjewel"));
}
}