summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-24 21:01:41 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-24 21:01:41 +0200
commit1997f4547812121223836dcacfcb31ea63acdda6 (patch)
treec6962617e7c2374b9d7393846d94bc99c21f940c /common
parent198677e5b01009a65d243da1d25a14f879df659c (diff)
Fixed some bugs with tile entities, fixed rings rendering issue, added interdimensional teleporting rings and ender chest ring
Diffstat (limited to 'common')
-rw-r--r--common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java22
-rw-r--r--common/darkknight/jewelrycraft/block/BlockMolder.java1
-rw-r--r--common/darkknight/jewelrycraft/block/BlockSmelter.java21
-rw-r--r--common/darkknight/jewelrycraft/item/ItemRing.java205
-rw-r--r--common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java11
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java1
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java1
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java1
-rw-r--r--common/darkknight/jewelrycraft/util/JewelryNBT.java83
9 files changed, 296 insertions, 50 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
index c9372a9..ebbae64 100644
--- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
+++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java
@@ -43,12 +43,15 @@ public class BlockJewelrsCraftingTable extends BlockContainer
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));
@@ -73,7 +76,6 @@ public class BlockJewelrsCraftingTable extends BlockContainer
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && !world.isRemote)
{
- te.isDirty = true;
if (!te.hasEndItem && !te.hasJewelry && item != null && isJewelry(item))
{
if(te.hasModifier && te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("modifier") && item.getTagCompound().hasKey("jewel"))
@@ -88,6 +90,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewelry = true;
if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
entityPlayer.inventory.onInventoryChanged();
+ world.setBlockTileEntity(i, j, k, te);
+ te.isDirty = true;
}
}
if (!te.hasEndItem && !te.hasModifier && item != null && isModifier(item))
@@ -101,6 +105,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasModifier = true;
if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
entityPlayer.inventory.onInventoryChanged();
+ world.setBlockTileEntity(i, j, k, te);
+ te.isDirty = true;
}
}
if (!te.hasEndItem && !te.hasJewel && item != null && isJewel(item))
@@ -114,6 +120,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewel = true;
if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
entityPlayer.inventory.onInventoryChanged();
+ world.setBlockTileEntity(i, j, k, te);
+ te.isDirty = true;
}
}
if (te.timer <= 0 && !te.hasEndItem && te.hasJewelry && (te.hasModifier || te.hasJewel)){ te.timer = ConfigHandler.jewelryCraftingTime; te.angle = 0;}
@@ -126,6 +134,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasModifier = false;
te.timer = 0;
te.angle = 0F;
+ world.markTileEntityForDespawn(te);
+ world.setBlockTileEntity(i, j, k, te);
}
if (te.hasJewelry && entityPlayer.isSneaking())
{
@@ -134,6 +144,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewelry = false;
te.timer = 0;
te.angle = 0F;
+ world.markTileEntityForDespawn(te);
+ world.setBlockTileEntity(i, j, k, te);
}
if (te.hasJewel && entityPlayer.isSneaking())
{
@@ -142,9 +154,9 @@ public class BlockJewelrsCraftingTable extends BlockContainer
te.hasJewel = false;
te.timer = 0;
te.angle = 0F;
+ world.markTileEntityForDespawn(te);
+ world.setBlockTileEntity(i, j, k, te);
}
- te.isDirty = true;
- world.setBlockTileEntity(i, j, k, te);
}
return true;
}
@@ -206,6 +218,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer
if (te.hasJewelry) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy());
if (te.hasJewel) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewel.copy());
if (te.hasEndItem) dropItem(te.worldObj, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy());
+ world.markTileEntityForDespawn(te);
}
super.breakBlock(world, i, j, k, par5, par6);
}
@@ -228,12 +241,13 @@ 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;
+ 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"));
- te.isDirty = true;
}
}
diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java
index cae036e..f26c232 100644
--- a/common/darkknight/jewelrycraft/block/BlockMolder.java
+++ b/common/darkknight/jewelrycraft/block/BlockMolder.java
@@ -84,6 +84,7 @@ public class BlockMolder extends BlockContainer
{
if(te.hasJewelBase) dropItem(te.worldObj, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.jewelBase.copy());
if(te.hasMold) dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.mold.copy());
+ world.markTileEntityForDespawn(te);
}
super.breakBlock(world, i, j, k, par5, par6);
diff --git a/common/darkknight/jewelrycraft/block/BlockSmelter.java b/common/darkknight/jewelrycraft/block/BlockSmelter.java
index c762005..472d3b8 100644
--- a/common/darkknight/jewelrycraft/block/BlockSmelter.java
+++ b/common/darkknight/jewelrycraft/block/BlockSmelter.java
@@ -51,7 +51,10 @@ public class BlockSmelter extends BlockContainer
public void breakBlock(World world, int i, int j, int k, int par5, int par6)
{
TileEntitySmelter te = (TileEntitySmelter) world.getBlockTileEntity(i, j, k);
- if (te != null && te.hasMetal) dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.metal.copy());
+ if (te != null && te.hasMetal){
+ dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.metal.copy());
+ world.markTileEntityForDespawn(te);
+ }
super.breakBlock(world, i, j, k, par5, par6);
}
@@ -62,7 +65,7 @@ public class BlockSmelter extends BlockContainer
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && !world.isRemote)
{
- if (!te.hasMetal && !te.hasMoltenMetal && item != null && item.getUnlocalizedName().toLowerCase().contains("ingot") && !item.getUnlocalizedName().toLowerCase().contains("mold"))
+ if (!te.hasMetal && !te.hasMoltenMetal && item != null && (item.getUnlocalizedName().toLowerCase().contains("ingot") || entityPlayer.username.equals("sor1n")) && !item.getUnlocalizedName().toLowerCase().contains("mold"))
{
entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()));
te.metal = item.copy();
@@ -70,6 +73,7 @@ public class BlockSmelter extends BlockContainer
te.hasMetal = true;
te.melting = ConfigHandler.ingotMeltingTime;
if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize;
+ te.isDirty = true;
}
else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold"))
entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.alreadyhasingot", te.metal.getDisplayName()));
@@ -84,10 +88,11 @@ public class BlockSmelter extends BlockContainer
{
dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.metal.copy());
te.hasMetal = false;
- te.melting = 0;
+ te.melting = -1;
+ world.markTileEntityForDespawn(te);
+ world.setBlockTileEntity(i, j, k, te);
}
- world.setBlockTileEntity(i, j, k, te);
- te.isDirty = true;
+ if(te != null) world.setBlockTileEntity(i, j, k, te);
}
return true;
}
@@ -106,7 +111,7 @@ public class BlockSmelter extends BlockContainer
else if (world.getBlockMetadata(i, j, k) == 3)
me = (TileEntityMolder) world.getBlockTileEntity(i - 1, j, k);
- if (me != null && !world.isRemote)
+ if (te != null && me != null && !world.isRemote)
{
if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase)
{
@@ -116,7 +121,8 @@ public class BlockSmelter extends BlockContainer
te.moltenMetal = new ItemStack(0, 0, 0);
te.hasMoltenMetal = false;
me.isDirty = true;
- te.isDirty = true;
+ world.markTileEntityForDespawn(te);
+ world.setBlockTileEntity(i, j, k, te);
}
else if (te.hasMetal && te.melting > 0)
player.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + ((ConfigHandler.ingotMeltingTime - te.melting)*100/ConfigHandler.ingotMeltingTime) + "%)");
@@ -130,7 +136,6 @@ public class BlockSmelter extends BlockContainer
player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.modlerhasitem"));
else
player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.empty"));
- te.isDirty = true;
}
}
diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java
index 268a6aa..6f31c4d 100644
--- a/common/darkknight/jewelrycraft/item/ItemRing.java
+++ b/common/darkknight/jewelrycraft/item/ItemRing.java
@@ -10,11 +10,15 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.util.JewelryNBT;
+import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.resources.ResourceManager;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -22,6 +26,7 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
+import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
@@ -43,18 +48,6 @@ public class ItemRing extends ItemBase
jewel = iconRegister.registerIcon("jewelrycraft:jewel");
}
- public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
- {
- if (stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel")) return getIcon(stack, 1);
- return getIcon(stack, 0);
- }
-
- @Override
- public Icon getIconFromDamageForRenderPass(int damage, int pass)
- {
- return pass == 0 ? super.getIconFromDamageForRenderPass(damage, pass) : jewel;
- }
-
@Override
public boolean requiresMultipleRenderPasses()
{
@@ -66,7 +59,7 @@ public class ItemRing extends ItemBase
{
try
{
- if(par1ItemStack != null) return color(par1ItemStack, pass);
+ return color(par1ItemStack, pass);
}
catch (IOException e)
{
@@ -75,9 +68,25 @@ public class ItemRing extends ItemBase
return 16777215;
}
+ public Icon getIcon(ItemStack stack, int pass)
+ {
+ if (stack.hasTagCompound())
+ {
+ if (stack.getTagCompound().hasKey("jewel"))
+ {
+ NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
+ ItemStack ingotStack = new ItemStack(0, 0, 0);
+ ingotStack.readFromNBT(ingotNBT);
+ if(pass == 0) return itemIcon;
+ if(pass == 1) return jewel;
+ }
+ }
+ return itemIcon;
+ }
+
public static int color(ItemStack stack, int pass) throws IOException
{
- if (pass == 0 && stack.hasTagCompound() && stack.getTagCompound().hasKey("ingot"))
+ if (stack.hasTagCompound() && stack.getTagCompound().hasKey("ingot") && !stack.getTagCompound().hasKey("jewel") && pass == 1)
{
NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot");
ItemStack ingotStack = new ItemStack(0, 0, 0);
@@ -98,12 +107,33 @@ public class ItemRing extends ItemBase
return bufferedimage.getRGB(9, 9);
}
}
- if (pass == 1 && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel"))
+ if (stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel"))
{
- NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
+ if(pass == 1)
+ {
+ NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
+ ItemStack jewel = new ItemStack(0, 0, 0);
+ jewel.readFromNBT(jewelNBT);
+ if(jewel != null && jewel != new ItemStack(0, 0, 0) && jewel.getIconIndex().getIconName() != "")
+ {
+ String domain = "";
+ if(jewel.getIconIndex().getIconName().substring(0, jewel.getIconIndex().getIconName().indexOf(":") + 1) != "")
+ domain = jewel.getIconIndex().getIconName().substring(0, jewel.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim();
+ else
+ domain = "minecraft";
+ String texture = jewel.getIconIndex().getIconName().substring(jewel.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png";
+ ResourceLocation jewelLoc = null;
+ if(jewel.getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture);
+ else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture);
+ ResourceManager rm = Minecraft.getMinecraft().getResourceManager();
+ BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewelLoc).getInputStream());
+ return bufferedimage.getRGB(9, 4);
+ }
+ }
+ NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot");
ItemStack ingotStack = new ItemStack(0, 0, 0);
ingotStack.readFromNBT(ingotNBT);
- if(ingotStack != null && ingotStack != new ItemStack(0, 0, 0) && ingotStack.getIconIndex().getIconName() != "")
+ if(ingotStack.getIconIndex().getIconName() != "")
{
String domain = "";
if(ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1) != "")
@@ -111,12 +141,12 @@ public class ItemRing extends ItemBase
else
domain = "minecraft";
String texture = ingotStack.getIconIndex().getIconName().substring(ingotStack.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png";
- ResourceLocation jewel = null;
- if(ingotStack.getUnlocalizedName().contains("item")) jewel = new ResourceLocation(domain, "textures/items/" + texture);
- else jewel = new ResourceLocation(domain, "textures/blocks/" + texture);
+ ResourceLocation ingot = null;
+ if(ingotStack.getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture);
+ else ingot = new ResourceLocation(domain, "textures/blocks/" + texture);
ResourceManager rm = Minecraft.getMinecraft().getResourceManager();
- BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewel).getInputStream());
- return bufferedimage.getRGB(9, 4);
+ BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream());
+ return bufferedimage.getRGB(9, 9);
}
}
return 16777215;
@@ -131,6 +161,13 @@ public class ItemRing extends ItemBase
NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot");
ItemStack ingotStack = new ItemStack(0, 0, 0);
ingotStack.readFromNBT(ingotNBT);
+ if (stack.getTagCompound().hasKey("jewel"))
+ {
+ NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
+ ItemStack jewel = new ItemStack(0, 0, 0);
+ jewel.readFromNBT(jewelNBT);
+ if(jewel.itemID == Item.diamond.itemID && ingotStack.itemID == Item.ingotGold.itemID) return "Wedding Ring";
+ }
return ingotStack.getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim();
}
}
@@ -139,7 +176,7 @@ public class ItemRing extends ItemBase
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
- if (stack.hasTagCompound())
+ if (!world.isRemote && stack.hasTagCompound())
{
if(stack.getTagCompound().hasKey("x") && stack.getTagCompound().hasKey("y") && stack.getTagCompound().hasKey("z"))
{
@@ -150,24 +187,83 @@ public class ItemRing extends ItemBase
posX = x.getDouble("x");
posY = y.getDouble("y");
posZ = z.getDouble("z");
- for(int i = 1; i <= 20; i++)
- world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
- player.setPositionAndUpdate(posX, posY, posZ);
- for(int i = 1; i <= 300; i++)
- world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ if(stack.getTagCompound().hasKey("dimension") && stack.getTagCompound().hasKey("dimName"))
+ {
+ NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimension");
+ int dimension = 0;
+ dimension = dim.getInteger("dimension");
+ for(int i = 1; i <= 20; i++)
+ world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ if(player.dimension != dimension) player.travelToDimension(dimension);
+ player.setPositionAndUpdate(posX, posY, posZ);
+ for(int i = 1; i <= 300; i++)
+ world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
+ else
+ {
+ for(int i = 1; i <= 20; i++)
+ world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ player.setPositionAndUpdate(posX, posY, posZ);
+ for(int i = 1; i <= 300; i++)
+ world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
}
if(stack.getTagCompound().hasKey("jewel"))
{
NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
ItemStack jewel = new ItemStack(0, 0, 0);
jewel.readFromNBT(jewelNBT);
- if(jewel.itemID == Item.enderPearl.itemID && !stack.getTagCompound().hasKey("x") && !stack.getTagCompound().hasKey("y") && !stack.getTagCompound().hasKey("z"))
+ if(stack.getTagCompound().hasKey("modifier"))
+ {
+ NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier");
+ ItemStack modifier = new ItemStack(0, 0, 0);
+ modifier.readFromNBT(modifierNBT);
+ if(jewel.itemID == Item.enderPearl.itemID && modifier.itemID == Item.bed.itemID && !stack.getTagCompound().hasKey("x") && !stack.getTagCompound().hasKey("y") && !stack.getTagCompound().hasKey("z") && !stack.getTagCompound().hasKey("dimension"))
+ {
+ JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName());
+ JewelryNBT.addEnchantment(stack);
+ }
+ if(jewel.itemID == Block.obsidian.blockID && modifier.itemID == Item.eyeOfEnder.itemID)
+ {
+ InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest();
+ player.displayGUIChest(inventoryenderchest);
+ }
+ }
+ else if(jewel.itemID == Item.enderPearl.itemID && !stack.getTagCompound().hasKey("x") && !stack.getTagCompound().hasKey("y") && !stack.getTagCompound().hasKey("z"))
+ {
JewelryNBT.addCoordonates(stack, player.posX, player.posY, player.posZ);
+ JewelryNBT.addEnchantment(stack);
+ }
}
}
return stack;
}
+ @Override
+ public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity)
+ {
+ if (!player.worldObj.isRemote && stack.hasTagCompound())
+ {
+ if(stack.getTagCompound().hasKey("jewel") && stack.getTagCompound().hasKey("modifier") && !stack.getTagCompound().hasKey("entityID") && !stack.getTagCompound().hasKey("entity"))
+ {
+ NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel");
+ NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier");
+ ItemStack jewel = new ItemStack(0, 0, 0);
+ ItemStack modifier = new ItemStack(0, 0, 0);
+ jewel.readFromNBT(jewelNBT);
+ modifier.readFromNBT(modifierNBT);
+ if(jewel.itemID == Item.netherStar.itemID && modifier.itemID == Block.chest.blockID)
+ {
+ JewelryNBT.addEntity(stack, entity);
+ JewelryNBT.addEntityID(stack, entity);
+ entity.setDead();
+ JewelryNBT.addEnchantment(stack);
+ }
+ }
+ }
+ return true;
+ }
+
/**
* allows items to add custom lines of information to the mouseover description
*/
@@ -175,7 +271,7 @@ public class ItemRing extends ItemBase
@SuppressWarnings({ "rawtypes", "unchecked"})
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
- if (stack.hasTagCompound())
+ if (stack.hasTagCompound() && stack.getDisplayName() != "Wedding Ring")
{
if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("ingot"))
{
@@ -215,14 +311,55 @@ public class ItemRing extends ItemBase
posZ = z.getDouble("z");
list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int)posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int)posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int)posZ);
}
+
+ if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("dimName"))
+ {
+ NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimName");
+ String name = "";
+ name = dim.getString("dimName");
+ list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name);
+ }
+
+ if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity"))
+ {
+ NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID");
+ NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity");
+ int entityID = 0;
+ entityID = enID.getInteger("entityID");
+ EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj);
+ entity.readFromNBT(en);
+ list.add("Entity: " + EnumChatFormatting.GOLD + entity.getEntityName());
+ }
}
}
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10)
+ {
+ if (!world.isRemote && stack.hasTagCompound())
+ {
+ if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity"))
+ {
+ NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID");
+ NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity");
+ int entityID = 0;
+ entityID = enID.getInteger("entityID");
+ EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj);
+ entity.readFromNBT(en);
+ entity.setLocationAndAngles(i + 0.5D, j + 1D, k + 0.5D, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
+ world.spawnEntityInWorld(entity);
+ JewelryNBT.removeNBT(stack, "entityID");
+ JewelryNBT.removeNBT(stack, "entity");
+ JewelryNBT.removeNBT(stack, "ench");
+ }
+ }
+ return true;
+ }
+
@Override
- public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5)
+ public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
amplifier = 0;
- if (stack.hasTagCompound())
+ if (!world.isRemote && stack.hasTagCompound())
{
if(stack.getTagCompound().hasKey("jewel"))
{
@@ -234,9 +371,9 @@ public class ItemRing extends ItemBase
}
if(stack.getTagCompound().hasKey("modifier"))
{
- if (par3Entity instanceof EntityPlayer)
+ if (entity instanceof EntityPlayer)
{
- EntityPlayer entityplayer = (EntityPlayer)par3Entity;
+ EntityPlayer entityplayer = (EntityPlayer)entity;
NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier");
ItemStack modifier = new ItemStack(0, 0, 0);
modifier.readFromNBT(modifierNBT);
diff --git a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
index c878317..cf3a9c6 100644
--- a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
+++ b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
@@ -89,10 +89,13 @@ public class TileEntitySmelterRender extends TileEntitySpecialRenderer
GL11.glRotatef(180F, 1F, 0F, 0F);
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(-0.9F, -0.9F, -1.6F);
- RenderItem.renderInFrame = true;
- for(double d=0; d<=0.05; d+=0.01)
- RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D - d, 0.0F, 0.0F);
- RenderItem.renderInFrame = false;
+ if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ else
+ {
+ RenderManager.instance.options.fancyGraphics = true;
+ RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
+ RenderManager.instance.options.fancyGraphics = false;
+ }
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
index a0e71ef..35457df 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
@@ -116,6 +116,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity
this.modifier = new ItemStack(0, 0, 0);
this.hasJewel = false;
this.jewel = new ItemStack(0, 0, 0);
+ timer = -1;
}
}
}
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
index 58ba82a..9018b0b 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
@@ -98,6 +98,7 @@ public class TileEntityMolder extends TileEntity
JewelryNBT.addMetal(jewelBase, ringMetal);
this.moltenMetal = new ItemStack(0, 0, 0);
this.hasJewelBase = true;
+ cooling = -1;
}
}
}
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
index ff396de..1012741 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
@@ -101,6 +101,7 @@ public class TileEntitySmelter extends TileEntity
this.moltenMetal = metal;
this.metal = new ItemStack(0, 0, 0);
this.hasMoltenMetal = true;
+ melting = -1;
}
}
}
diff --git a/common/darkknight/jewelrycraft/util/JewelryNBT.java b/common/darkknight/jewelrycraft/util/JewelryNBT.java
index b6140b7..c097a49 100644
--- a/common/darkknight/jewelrycraft/util/JewelryNBT.java
+++ b/common/darkknight/jewelrycraft/util/JewelryNBT.java
@@ -1,7 +1,10 @@
package darkknight.jewelrycraft.util;
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
public class JewelryNBT
{
@@ -51,6 +54,37 @@ public class JewelryNBT
itemStackData.setTag("modifier", modifierNBT);
}
+ public static void addEntity(ItemStack item, EntityLivingBase entity)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound entityNBT = new NBTTagCompound();
+ entity.writeToNBT(entityNBT);
+ itemStackData.setTag("entity", entityNBT);
+ }
+
+ public static void addEntityID(ItemStack item, EntityLivingBase entity)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound entityNBT = new NBTTagCompound();
+ int id = EntityList.getEntityID(entity);
+ entityNBT.setInteger("entityID", id);
+ itemStackData.setTag("entityID", entityNBT);
+ }
+
public static void addCoordonates(ItemStack item, double x, double y, double z)
{
NBTTagCompound itemStackData;
@@ -70,4 +104,53 @@ public class JewelryNBT
itemStackData.setTag("z", coords);
}
+ public static void addCoordonatesAndDimension(ItemStack item, double x, double y, double z, int dim, String name)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound coords = new NBTTagCompound();
+ coords.setDouble("x", x);
+ coords.setDouble("y", y);
+ coords.setDouble("z", z);
+ coords.setInteger("dimension", dim);
+ coords.setString("dimName", name);
+ itemStackData.setTag("x", coords);
+ itemStackData.setTag("y", coords);
+ itemStackData.setTag("z", coords);
+ itemStackData.setTag("dimension", coords);
+ itemStackData.setTag("dimName", coords);
+ }
+
+ public static void removeNBT(ItemStack item, String tag)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ itemStackData.removeTag(tag);
+ }
+
+ public static void addEnchantment(ItemStack item)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ itemStackData.setTag("ench", new NBTTagList("ench"));
+ }
+
}