summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 22:17:32 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 22:17:32 +0200
commitff4b3d697a65940b812d4d8e6977ed180709a3c0 (patch)
tree7dce2a4600d092ae174627a9cbe4963888d82dd0 /common
parent3e7036bf39c640b9d0dd94115f8b1f7947d26f71 (diff)
Added Mold stuff
Diffstat (limited to 'common')
-rw-r--r--common/darkknight/jewelrycraft/block/BlockMolder.java88
-rw-r--r--common/darkknight/jewelrycraft/block/BlockSmelter.java91
-rw-r--r--common/darkknight/jewelrycraft/config/ConfigHandler.java4
-rw-r--r--common/darkknight/jewelrycraft/item/ItemList.java3
-rw-r--r--common/darkknight/jewelrycraft/item/ItemMolds.java75
-rw-r--r--common/darkknight/jewelrycraft/renders/TileEntityMolderRender.java30
-rw-r--r--common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java17
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java68
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java46
9 files changed, 354 insertions, 68 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java
index 1292f2a..d982cfe 100644
--- a/common/darkknight/jewelrycraft/block/BlockMolder.java
+++ b/common/darkknight/jewelrycraft/block/BlockMolder.java
@@ -1,40 +1,120 @@
package darkknight.jewelrycraft.block;
+import java.util.Random;
+
+import darkknight.jewelrycraft.item.ItemList;
import darkknight.jewelrycraft.tileentity.TileEntityMolder;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockMolder extends BlockContainer
{
+ Random rand = new Random();
protected BlockMolder(int par1, Material par2Material)
{
super(par1, par2Material);
this.setBlockBounds(0.1F, 0F, 0.1F, 0.9F, 0.2F, 0.9F);
}
-
+
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntityMolder();
}
-
+
@Override
public boolean renderAsNormalBlock()
{
return false;
}
-
+
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
{
TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
+ ItemStack item = entityPlayer.inventory.getCurrentItem();
+ if(te != null && item != null && !te.hasMold && item.itemID == ItemList.molds.itemID)
+ {
+ te.mold = item;
+ te.hasMold = true;
+ --item.stackSize;
+ }
return true;
}
+
+ public void onBlockDestroyedByPlayer(World par1World, int i, int j, int k, int par5)
+ {
+ TileEntityMolder te = (TileEntityMolder) par1World.getBlockTileEntity(i, j, k);
+ if(te != null)
+ {
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+ if(te.hasMold)
+ {
+ EntityItem entityitem = new EntityItem(par1World, (double)((float)i + f), (double)((float)j + f1), (double)((float)k + f2), new ItemStack(te.mold.itemID, 1, te.mold.getItemDamage()));
+
+ if (te.mold.hasTagCompound())
+ {
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)te.mold.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ par1World.spawnEntityInWorld(entityitem);
+ }
+ if(te.hasJewelBase)
+ {
+ EntityItem entityitem = new EntityItem(par1World, (double)((float)i + f), (double)((float)j + f1), (double)((float)k + f2), new ItemStack(te.jewelBase.itemID, 1, te.jewelBase.getItemDamage()));
+
+ if (te.jewelBase.hasTagCompound())
+ {
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)te.jewelBase.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ par1World.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+
+ public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion)
+ {
+ onBlockDestroyedByPlayer(world, i, j, k, 0);
+ }
+
+ public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
+ {
+ TileEntityMolder me = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
+ if(me != null && me.hasJewelBase)
+ {
+ player.inventory.addItemStackToInventory(new ItemStack(me.jewelBase.itemID, 1, me.jewelBase.getItemDamage()));
+ me.jewelBase = new ItemStack(0, 0, 0);
+ me.hasJewelBase = false;
+ }
+ if(me != null && me.hasMold)
+ {
+ player.addChatMessage(me.mold.getDisplayName());
+ player.inventory.addItemStackToInventory(new ItemStack(me.mold.itemID, 1, me.mold.getItemDamage()));
+ me.mold = new ItemStack(0, 0, 0);
+ me.hasMold = false;
+ }
+ }
+
public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
{
return false;
@@ -50,7 +130,7 @@ public class BlockMolder extends BlockContainer
{
return -1;
}
-
+
public void registerIcons(IconRegister icon)
{
this.blockIcon = icon.registerIcon("jewelrycraft:molder");
diff --git a/common/darkknight/jewelrycraft/block/BlockSmelter.java b/common/darkknight/jewelrycraft/block/BlockSmelter.java
index eb22b63..03019fc 100644
--- a/common/darkknight/jewelrycraft/block/BlockSmelter.java
+++ b/common/darkknight/jewelrycraft/block/BlockSmelter.java
@@ -1,19 +1,26 @@
package darkknight.jewelrycraft.block;
+import java.util.Random;
+
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
import darkknight.jewelrycraft.tileentity.TileEntitySmelter;
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.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
+import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockSmelter extends BlockContainer
{
+ Random rand = new Random();
protected BlockSmelter(int par1, Material par2Material)
{
super(par1, par2Material);
@@ -31,6 +38,37 @@ public class BlockSmelter extends BlockContainer
return false;
}
+ public void onBlockDestroyedByPlayer(World par1World, int i, int j, int k, int par5)
+ {
+ TileEntitySmelter te = (TileEntitySmelter) par1World.getBlockTileEntity(i, j, k);
+ if(te != null)
+ {
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+ if(te.hasMetal)
+ {
+ EntityItem entityitem = new EntityItem(par1World, (double)((float)i + f), (double)((float)j + f1), (double)((float)k + f2), new ItemStack(te.metal.itemID, 1, te.metal.getItemDamage()));
+
+ if (te.metal.hasTagCompound())
+ {
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)te.metal.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ par1World.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+
+ public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion)
+ {
+ onBlockDestroyedByPlayer(world, i, j, k, 0);
+ }
+
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
{
@@ -38,31 +76,66 @@ public class BlockSmelter extends BlockContainer
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && !world.isRemote)
{
- if (!te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot"))
+ if (!te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold"))
{
- te.metalID = item.getItem().itemID;
- te.metal = item;
+ te.metal = new ItemStack(item.itemID, 1, item.getItemDamage());
te.hasMetal = true;
te.melting = 200000;
--item.stackSize;
}
- else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot"))
- entityPlayer.addChatMessage("The Smelter already contains a " + new ItemStack(te.metalID, 1, 0).getDisplayName());
+ else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold"))
+ entityPlayer.addChatMessage("The Smelter already contains a " + te.metal.getDisplayName());
else if (te.hasMoltenMetal)
- entityPlayer.addChatMessage("The Smelter contains molten " + new ItemStack(te.moltenMetalID, 1, 0).getDisplayName().toLowerCase().replace("ingot", ""));
+ entityPlayer.addChatMessage("The Smelter contains molten " + te.moltenMetal.getDisplayName().toLowerCase().replace("ingot", ""));
else if (item != null && !item.getDisplayName().contains("Ingot"))
entityPlayer.addChatMessage("The item needs to be an ingot!");
if (te.hasMetal && entityPlayer.isSneaking())
{
- entityPlayer.dropPlayerItem(new ItemStack(te.metalID, 1, 0));
+ entityPlayer.dropPlayerItem(te.metal);
te.hasMetal = false;
}
world.setBlockTileEntity(i, j, k, te);
}
return true;
}
-
+
+ public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
+ {
+ TileEntitySmelter te = (TileEntitySmelter) world.getBlockTileEntity(i, j, k);
+ TileEntityMolder me = null;
+ if(world.getBlockMetadata(i, j, k) == 0) me = (TileEntityMolder) world.getBlockTileEntity(i, j, k - 1);
+ else if(world.getBlockMetadata(i, j, k) == 1) me = (TileEntityMolder) world.getBlockTileEntity(i + 1, j, k);
+ else if(world.getBlockMetadata(i, j, k) == 2) me = (TileEntityMolder) world.getBlockTileEntity(i, j, k + 1);
+ else if(world.getBlockMetadata(i, j, k) == 3) me = (TileEntityMolder) world.getBlockTileEntity(i - 1, j, k);
+
+ if(te.hasMoltenMetal && me != null)
+ {
+ if(isConnectedToMolder(world, i, j, k) && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase)
+ {
+ me.moltenMetal = te.moltenMetal;
+ me.hasMoltenMetal = true;
+ te.moltenMetal = new ItemStack(0, 0, 0);
+ te.hasMoltenMetal = false;
+ }
+ else if(me.hasMoltenMetal) player.addChatMessage("The Molder already has molten metal in it!");
+ else if(!me.hasMold) player.addChatMessage("The Molder doesn't have a mold in it! You might as well pour this stuff on the ground, won't you?");
+ else if(me.hasJewelBase) player.addChatMessage("The Molder contains an item in it. Now you wouldn't want it to be destroyed, would you?");
+ else player.addChatMessage("You need a Molder in front of this block in order to pour the molten metal!");
+ }
+
+ }
+
+ public boolean isConnectedToMolder(World world, int i, int j, int k)
+ {
+ int blockMeta = world.getBlockMetadata(i, j, k);
+ if(blockMeta == 0 && world.getBlockId(i, j, k - 1) == BlockList.molder.blockID) return true;
+ else if(blockMeta == 1 && world.getBlockId(i + 1, j, k) == BlockList.molder.blockID) return true;
+ else if(blockMeta == 2 && world.getBlockId(i, j, k + 1) == BlockList.molder.blockID) return true;
+ else if(blockMeta == 3 && world.getBlockId(i - 1, j, k) == BlockList.molder.blockID) return true;
+ return false;
+ }
+
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack)
{
int rotation = MathHelper.floor_double((double)(entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
@@ -85,7 +158,7 @@ public class BlockSmelter extends BlockContainer
{
return -1;
}
-
+
public void registerIcons(IconRegister icon)
{
this.blockIcon = icon.registerIcon("jewelrycraft:smelter");
diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java
index be671a3..aaa0887 100644
--- a/common/darkknight/jewelrycraft/config/ConfigHandler.java
+++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java
@@ -7,7 +7,8 @@ public class ConfigHandler
{
private static Configuration config;
public static int idThiefGloves = 17493;
- public static int idShadowIngot = 17497;
+ public static int idShadowIngot = 17494;
+ public static int idMolds = 17495;
public static int idShadowOre = 1750;
public static int idSmelter = 1751;
@@ -26,6 +27,7 @@ public class ConfigHandler
idThiefGloves = config.getItem("id.ThiefGloves", idThiefGloves).getInt();
idShadowIngot = config.getItem("id.ShadowIngot", idShadowIngot).getInt();
+ idMolds = config.getItem("id.Molds", idMolds).getInt();
idShadowOre = config.getBlock("id.ShadowOre", idShadowOre).getInt();
idSmelter = config.getBlock("id.Smelter", idSmelter).getInt();
idMolder = config.getBlock("id.Molder", idMolder).getInt();
diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java
index 7bf3705..261fa9e 100644
--- a/common/darkknight/jewelrycraft/item/ItemList.java
+++ b/common/darkknight/jewelrycraft/item/ItemList.java
@@ -9,6 +9,7 @@ public class ItemList
{
public static Item thiefGloves;
public static Item shadowIngot;
+ public static Item molds;
private static boolean isInitialized = false;
@@ -18,7 +19,7 @@ public class ItemList
{
thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves).setUnlocalizedName("jewelrycraft.thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft);
shadowIngot = new ItemBase(ConfigHandler.idShadowIngot).setUnlocalizedName("jewelrycraft.ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
-
+ molds = new ItemMolds(ConfigHandler.idMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft);
}
}
}
diff --git a/common/darkknight/jewelrycraft/item/ItemMolds.java b/common/darkknight/jewelrycraft/item/ItemMolds.java
new file mode 100644
index 0000000..9beb03a
--- /dev/null
+++ b/common/darkknight/jewelrycraft/item/ItemMolds.java
@@ -0,0 +1,75 @@
+package darkknight.jewelrycraft.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.List;
+
+import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.Icon;
+import net.minecraft.util.MathHelper;
+
+public class ItemMolds extends Item
+{
+ /** List of molds color names */
+ public static final String[] moldsItemNames = new String[] {"ingot", "ring", "necklace"};
+ @SideOnly(Side.CLIENT)
+ private Icon[] moldsIcons;
+
+ public ItemMolds(int par1)
+ {
+ super(par1);
+ this.setHasSubtypes(true);
+ this.setMaxDamage(0);
+ this.setMaxStackSize(1);
+ this.setCreativeTab(CreativeTabs.tabMaterials);
+ }
+
+ @SideOnly(Side.CLIENT)
+
+ /**
+ * Gets an icon index based on an item's damage value
+ */
+ public Icon getIconFromDamage(int par1)
+ {
+ int j = MathHelper.clamp_int(par1, 0, 2);
+ return this.moldsIcons[j];
+ }
+
+ /**
+ * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
+ * different names based on their damage or NBT.
+ */
+ public String getUnlocalizedName(ItemStack par1ItemStack)
+ {
+ int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 2);
+ return super.getUnlocalizedName() + "." + moldsItemNames[i];
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SideOnly(Side.CLIENT)
+
+ /**
+ * returns a list of items with the same ID, but different meta (eg: molds returns 16 items)
+ */
+ public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
+ {
+ for (int j = 0; j < 3; ++j)
+ {
+ par3List.add(new ItemStack(par1, 1, j));
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IconRegister par1IconRegister)
+ {
+ this.moldsIcons = new Icon[moldsItemNames.length];
+
+ for (int i = 0; i < moldsItemNames.length; ++i)
+ {
+ this.moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + this.getIconString());
+ }
+ }
+}
diff --git a/common/darkknight/jewelrycraft/renders/TileEntityMolderRender.java b/common/darkknight/jewelrycraft/renders/TileEntityMolderRender.java
index 12a54a7..91cdd88 100644
--- a/common/darkknight/jewelrycraft/renders/TileEntityMolderRender.java
+++ b/common/darkknight/jewelrycraft/renders/TileEntityMolderRender.java
@@ -3,6 +3,7 @@ package darkknight.jewelrycraft.renders;
import org.lwjgl.opengl.GL11;
import darkknight.jewelrycraft.model.ModelMolder;
+import darkknight.jewelrycraft.tileentity.TileEntityMolder;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -24,13 +25,40 @@ public class TileEntityMolderRender extends TileEntitySpecialRenderer
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
+ TileEntityMolder me = (TileEntityMolder)te;
ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture);
Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture);
+ Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
- modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
+ modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
+ if(me != null && me.hasMold)
+ {
+ ResourceLocation lava = new ResourceLocation("jewelrycraft", "textures/items/ingotMold.png");
+ Minecraft.getMinecraft().renderEngine.bindTexture(lava);
+ me.mold.getIconIndex().getInterpolatedU(0);
+ double minu = me.mold.getIconIndex().getInterpolatedU(0);
+ double minv = me.mold.getIconIndex().getInterpolatedV(0);
+ double maxu = me.mold.getIconIndex().getInterpolatedU(256);
+ double maxv = me.mold.getIconIndex().getInterpolatedV(256);
+ GL11.glPushMatrix();
+ GL11.glScalef(1f/16f, 1f/16f, 1f/16f);
+ GL11.glDisable(GL11.GL_LIGHTING);
+
+ for(float f = 0; f <= 1; f+=0.05)
+ {
+ tessellator.startDrawingQuads();
+ tessellator.addVertexWithUV(5, 21+f, 5, minu, minv);
+ tessellator.addVertexWithUV(-5, 21+f, 5, maxu, minv);
+ tessellator.addVertexWithUV(-5, 21+f, -5, maxu, maxv);
+ tessellator.addVertexWithUV(5, 21+f, -5, minu, maxv);
+ tessellator.draw();
+ }
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glPopMatrix();
+ }
GL11.glPopMatrix();
GL11.glPopMatrix();
}
diff --git a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
index d3cd2ad..adee8ec 100644
--- a/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
+++ b/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java
@@ -39,21 +39,20 @@ public class TileEntitySmelterRender extends TileEntitySpecialRenderer
modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
- //Mrkol's liquid render code base - thank you man for the help :) I used only the top
Minecraft.getMinecraft().renderEngine.bindTexture(lava);
- Block.lavaStill.getIcon(3, 0).getInterpolatedU(0);
- double minu = Block.lavaStill.getIcon(0, 0).getInterpolatedU(0);
- double minv = Block.lavaStill.getIcon(0, 0).getInterpolatedV(0);
- double maxu = Block.lavaStill.getIcon(0, 0).getInterpolatedU(16);
- double maxv = Block.lavaStill.getIcon(0, 0).getInterpolatedV(16);
+ Block.lavaStill.getIcon(0, 0).getInterpolatedU(0);
+ double minu = Block.lavaStill.getIcon(2, 0).getInterpolatedU(0);
+ double minv = Block.lavaStill.getIcon(2, 0).getInterpolatedV(0);
+ double maxu = Block.lavaStill.getIcon(2, 0).getInterpolatedU(256);
+ double maxv = Block.lavaStill.getIcon(2, 0).getInterpolatedV(256);
GL11.glPushMatrix();
GL11.glScalef(1f/16f, 1f/16f, 1f/16f);
GL11.glDisable(GL11.GL_LIGHTING);
- // without F it scales it down to 0, 0, 0. That's because it is trying to make 0.0625 an integer, and 0.0625 without .0625 is 0.
+
tessellator.startDrawingQuads();
- tessellator.addVertexWithUV(5, 20, 6, maxu, maxv);
+ tessellator.addVertexWithUV(5, 20, 6, minu, minv);
tessellator.addVertexWithUV(-5, 20, 6, maxu, minv);
- tessellator.addVertexWithUV(-5, 20, -6, minu, minv);
+ tessellator.addVertexWithUV(-5, 20, -6, maxu, maxv);
tessellator.addVertexWithUV(5, 20, -6, minu, maxv);
tessellator.addVertexWithUV(4, 20, -6, maxu, maxv);
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
index e3f30cc..302a36f 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java
@@ -2,45 +2,62 @@ package darkknight.jewelrycraft.tileentity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
public class TileEntityMolder extends TileEntity
{
- public int jewelBaseID, moltenMetalID, cooling;
- public boolean hasMoltenMetal, hasJewelBase;
- public ItemStack metal;
+ public int cooling;
+ public boolean hasMoltenMetal, hasJewelBase, hasMold;
+ public ItemStack mold, jewelBase, moltenMetal;
public TileEntityMolder()
{
- this.moltenMetalID = 0;
- this.jewelBaseID = 0;
+ this.moltenMetal = new ItemStack(0, 0, 0);
+ this.jewelBase = new ItemStack(0, 0, 0);
+ this.mold = new ItemStack(0, 0, 0);
this.cooling = 0;
this.hasJewelBase = false;
- this.hasMoltenMetal= false;
+ this.hasMoltenMetal = false;
+ this.hasMold = false;
}
@Override
- public void writeToNBT(NBTTagCompound par1)
+ public void writeToNBT(NBTTagCompound nbt)
{
- super.writeToNBT(par1);
- par1.setInteger("moltenMetalID", moltenMetalID);
- par1.setInteger("jewelBaseID", jewelBaseID);
- par1.setInteger("cooling", cooling);
- par1.setBoolean("hasJewelBase", hasJewelBase);
- par1.setBoolean("hasMoltenMetal", hasMoltenMetal);
+ super.writeToNBT(nbt);
+ nbt.setInteger("cooling", cooling);
+ nbt.setBoolean("hasJewelBase", hasJewelBase);
+ nbt.setBoolean("hasMoltenMetal", hasMoltenMetal);
+ nbt.setBoolean("hasMold", hasMold);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound tag1 = new NBTTagCompound();
+ NBTTagCompound tag2 = new NBTTagCompound();
+ this.mold.writeToNBT(tag);
+ nbt.setCompoundTag("mold", tag);
+ this.jewelBase.writeToNBT(tag1);
+ nbt.setCompoundTag("jewelBase", tag1);
+ this.moltenMetal.writeToNBT(tag2);
+ nbt.setCompoundTag("moltenMetal", tag2);
}
@Override
- public void readFromNBT(NBTTagCompound par1)
+ public void readFromNBT(NBTTagCompound nbt)
{
- super.readFromNBT(par1);
- this.moltenMetalID = par1.getInteger("moltenMetalID");
- this.jewelBaseID = par1.getInteger("jewelBaseID");
- this.cooling = par1.getInteger("cooling");
- this.hasJewelBase = par1.getBoolean("hasJewelBase");
- this.hasMoltenMetal = par1.getBoolean("hasMoltenMetal");
+ super.readFromNBT(nbt);
+ this.cooling = nbt.getInteger("cooling");
+ this.hasJewelBase = nbt.getBoolean("hasJewelBase");
+ this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal");
+ this.hasMold = nbt.getBoolean("hasMold");
+ this.mold = new ItemStack(0, 0, 0);
+ this.mold.readFromNBT(nbt.getCompoundTag("mold"));
+ this.jewelBase = new ItemStack(0, 0, 0);
+ this.jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase"));
+ this.moltenMetal = new ItemStack(0, 0, 0);
+ this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal"));
}
public void updateEntity()
@@ -56,12 +73,17 @@ public class TileEntityMolder extends TileEntity
if(cooling == 0)
{
this.hasMoltenMetal = false;
- this.jewelBaseID = moltenMetalID;
- this.moltenMetalID = 0;
- this.hasMoltenMetal = true;
+ this.jewelBase = moltenMetal;
+ this.moltenMetal = new ItemStack(0, 0, 0);
+ this.hasJewelBase = true;
}
}
}
+
+ public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
+ {
+ readFromNBT(pkt.data);
+ }
public Packet getDescriptionPacket()
{
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
index f0c7918..3433945 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java
@@ -8,39 +8,45 @@ import net.minecraft.tileentity.TileEntity;
public class TileEntitySmelter extends TileEntity
{
- public int moltenMetalID, metalID, melting;
+ public int melting;
public boolean hasMetal, hasMoltenMetal;
- public ItemStack metal;
+ public ItemStack metal, moltenMetal;
public TileEntitySmelter()
{
- this.moltenMetalID = 0;
- this.metalID = 0;
this.melting = 0;
this.hasMetal = false;
this.hasMoltenMetal= false;
+ this.metal = new ItemStack(0, 0, 0);
+ this.moltenMetal = new ItemStack(0, 0, 0);
}
@Override
- public void writeToNBT(NBTTagCompound par1)
+ public void writeToNBT(NBTTagCompound nbt)
{
- super.writeToNBT(par1);
- par1.setInteger("moltenMetalID", moltenMetalID);
- par1.setInteger("metalID", metalID);
- par1.setInteger("melting", melting);
- par1.setBoolean("hasMetal", hasMetal);
- par1.setBoolean("hasMoltenMetal", hasMoltenMetal);
+ super.writeToNBT(nbt);
+ nbt.setInteger("melting", melting);
+ nbt.setBoolean("hasMetal", hasMetal);
+ nbt.setBoolean("hasMoltenMetal", hasMoltenMetal);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound tag1 = new NBTTagCompound();
+ this.metal.writeToNBT(tag);
+ nbt.setCompoundTag("metal", tag);
+ this.moltenMetal.writeToNBT(tag1);
+ nbt.setCompoundTag("moltenMetal", tag1);
}
@Override
- public void readFromNBT(NBTTagCompound par1)
+ public void readFromNBT(NBTTagCompound nbt)
{
- super.readFromNBT(par1);
- this.moltenMetalID = par1.getInteger("moltenMetalID");
- this.metalID = par1.getInteger("metalID");
- this.melting = par1.getInteger("melting");
- this.hasMetal = par1.getBoolean("hasMetal");
- this.hasMoltenMetal = par1.getBoolean("hasMoltenMetal");
+ super.readFromNBT(nbt);
+ this.melting = nbt.getInteger("melting");
+ this.hasMetal = nbt.getBoolean("hasMetal");
+ this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal");
+ this.metal = new ItemStack(0, 0, 0);
+ this.metal.readFromNBT(nbt.getCompoundTag("metal"));
+ this.moltenMetal = new ItemStack(0, 0, 0);
+ this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal"));
}
public void updateEntity()
@@ -56,8 +62,8 @@ public class TileEntitySmelter extends TileEntity
if(melting == 0)
{
this.hasMetal = false;
- this.moltenMetalID = metalID;
- this.metalID = 0;
+ this.moltenMetal = metal;
+ this.metal = new ItemStack(0, 0, 0);
this.hasMoltenMetal = true;
}
}