diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-03-23 14:51:06 +0000 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-03-23 14:51:06 +0000 |
| commit | 6312636fd9a4d0f56dc7c9ff474a99d879bcb4e9 (patch) | |
| tree | e3279753210bfb169a00cd3f146a80baf624150e /src/main/java/darkknight/jewelrycraft/tileentity | |
| parent | e86949a1ad3269ec66c9de65e2c92f5e66251411 (diff) | |
Reworked the whole repo.
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/tileentity')
18 files changed, 2159 insertions, 0 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java new file mode 100644 index 0000000..f490456 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java @@ -0,0 +1,90 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityAltar extends TileEntity +{ + public ItemStack object; + public boolean isDirty, hasObject; + public String playerName; + + /** + * + */ + public TileEntityAltar() + { + hasObject = false; + object = new ItemStack(Item.getItemById(0), 0, 0); + isDirty = false; + playerName = ""; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + NBTTagCompound tag = new NBTTagCompound(); + object.writeToNBT(tag); + nbt.setTag("object", tag); + nbt.setBoolean("hasObject", hasObject); + nbt.setString("playerName", playerName); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + object = new ItemStack(Item.getItemById(0), 0, 0); + object.readFromNBT(nbt.getCompoundTag("object")); + hasObject = nbt.getBoolean("hasObject"); + playerName = nbt.getString("playerName"); + } + + /** + * + */ + @SuppressWarnings ("rawtypes") + @Override + public void updateEntity() + { + super.updateEntity(); + if (isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java new file mode 100644 index 0000000..b16ce31 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java @@ -0,0 +1,88 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumSkyBlock; + +public class TileEntityBlockShadow extends TileEntity +{ + public int metadata; + + /** + * + */ + public TileEntityBlockShadow() + { + metadata = -1; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("metadata", metadata); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + metadata = nbt.getInteger("metadata"); + } + + /** + * + */ + @Override + public void updateEntity() + { + super.updateEntity(); + int blockLight, realLight; + int lightValue = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted; + float sunPosAngle = worldObj.getCelestialAngleRadians(1.0F); + if (sunPosAngle < (float)Math.PI) sunPosAngle += (0.0F - sunPosAngle) * 0.2F; + else sunPosAngle += ((float)Math.PI * 2F - sunPosAngle) * 0.2F; + lightValue = Math.round(lightValue * MathHelper.cos(sunPosAngle)); + if (lightValue < 0) lightValue = 0; + if (lightValue > 15) lightValue = 15; + blockLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getSavedLightValue(EnumSkyBlock.Block, xCoord & 15, yCoord, zCoord & 15); + realLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getBlockLightValue(xCoord & 15, yCoord, zCoord & 15, 0); + if (blockLight == 0 && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) || lightValue >= blockLight) metadata = 15 - lightValue; + else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) metadata = 15 - realLight; + else if (lightValue < blockLight) metadata = 15 - blockLight; + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 2); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java new file mode 100644 index 0000000..047f254 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java @@ -0,0 +1,133 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityDisplayer extends TileEntity +{ + public float ringTranslation1, ringTranslation2, ringTranslation3, rotAngle; + public boolean isDescending1, isDescending2, isDescending3, isDirty, hasObject; + public ItemStack object; + public int quantity, infoIndex, timer = 0; + + /** + * + */ + public TileEntityDisplayer() + { + ringTranslation1 = 0.6f; + ringTranslation2 = 0.3f; + ringTranslation3 = 0.0f; + rotAngle = 0; + quantity = 0; + infoIndex = 1; + isDescending1 = false; + isDescending2 = false; + isDescending3 = false; + isDirty = false; + hasObject = false; + object = new ItemStack(Item.getItemById(0), 0, 0); + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setFloat("translation1", ringTranslation1); + nbt.setFloat("translation2", ringTranslation2); + nbt.setFloat("translation3", ringTranslation3); + nbt.setFloat("angle", rotAngle); + nbt.setInteger("quantity", quantity); + nbt.setInteger("infoIndex", infoIndex); + nbt.setBoolean("descending1", isDescending1); + nbt.setBoolean("descending2", isDescending2); + nbt.setBoolean("descending3", isDescending3); + nbt.setBoolean("hasObject", hasObject); + NBTTagCompound tag = new NBTTagCompound(); + object.writeToNBT(tag); + nbt.setTag("object", tag); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + ringTranslation1 = nbt.getFloat("translation1"); + ringTranslation2 = nbt.getFloat("translation2"); + ringTranslation3 = nbt.getFloat("translation3"); + rotAngle = nbt.getFloat("angle"); + quantity = nbt.getInteger("quantity"); + infoIndex = nbt.getInteger("infoIndex"); + isDescending1 = nbt.getBoolean("descending1"); + isDescending2 = nbt.getBoolean("descending2"); + isDescending3 = nbt.getBoolean("descending3"); + hasObject = nbt.getBoolean("hasObject"); + object = new ItemStack(Item.getItemById(0), 0, 0); + object.readFromNBT(nbt.getCompoundTag("object")); + } + + /** + * + */ + @Override + public void updateEntity() + { + super.updateEntity(); + if (isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (ringTranslation1 >= 0.6) isDescending1 = true; + if (ringTranslation1 <= 0) isDescending1 = false; + if (!isDescending1) ringTranslation1 += 0.05; + if (isDescending1) ringTranslation1 -= 0.05; + if (ringTranslation2 >= 0.6) isDescending2 = true; + if (ringTranslation2 <= 0) isDescending2 = false; + if (!isDescending2) ringTranslation2 += 0.04; + if (isDescending2) ringTranslation2 -= 0.04; + if (ringTranslation3 >= 0.6) isDescending3 = true; + if (ringTranslation3 <= 0) isDescending3 = false; + if (!isDescending3) ringTranslation3 += 0.03; + if (isDescending3) ringTranslation3 -= 0.03; + if (rotAngle < 360F) rotAngle += 6F; + if (rotAngle >= 360F) rotAngle = 0F; + timer++; + if (timer >= 20){ + infoIndex++; + timer = 0; + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java new file mode 100644 index 0000000..ee48d08 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityHandPedestal.java @@ -0,0 +1,182 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +/** + * @author Paul Fulham (pau101) + */ +public class TileEntityHandPedestal extends TileEntity +{ + protected boolean isDirty; + protected ItemStack heldItemStack; + /** + * When the hand is open the grip is 0 and is 20 when closed. + */ + private float grip; + private float prevGrip; + private float gripMax; + private float gripScale; + private boolean isHandOpen; + + /** + * + */ + public TileEntityHandPedestal() + { + isDirty = false; + heldItemStack = null; + grip = 0; + gripMax = 20; + gripScale = 1; + isHandOpen = true; + } + + /** + * @param tagCompound + */ + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + if (heldItemStack != null){ + NBTTagCompound objectCompound = new NBTTagCompound(); + heldItemStack.writeToNBT(objectCompound); + tagCompound.setTag("object", objectCompound); + } + tagCompound.setBoolean("isHandOpen", isHandOpen); + } + + /** + * @param tagCompound + */ + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + if (tagCompound.hasKey("object", 10)) setHeldItemStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("object"))); + else removeHeldItemStack(); + isHandOpen = tagCompound.getBoolean("isHandOpen"); + } + + /** + * + */ + @Override + public void updateEntity() + { + super.updateEntity(); + updateGrip(); + if (isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + } + + /** + * + */ + private void updateGrip() + { + prevGrip = grip; + if (grip > 0 && isHandOpen) grip -= 1 / gripScale; + else if (grip < gripMax && !isHandOpen) grip += 1 / gripScale; + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound); + } + + /** + * @param networkManager + * @param packet + */ + @Override + public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } + + /** + * + */ + @Override + public void markDirty() + { + super.markDirty(); + isDirty = true; + } + + /** + * @return + */ + public ItemStack getHeldItemStack() + { + return heldItemStack; + } + + /** + * @param heldItemStack + */ + public void setHeldItemStack(ItemStack heldItemStack) + { + heldItemStack.stackSize = 1; + this.heldItemStack = heldItemStack; + if (heldItemStack.getItem() instanceof ItemBlock) gripScale = 0.5f; + else gripScale = 1; + } + + /** + * + */ + public void removeHeldItemStack() + { + heldItemStack = null; + } + + /** + * + */ + public void openHand() + { + isHandOpen = true; + } + + /** + * + */ + public void closeHand() + { + isHandOpen = false; + } + + /** + * @param t + * @return + */ + public float getGrip(float t) + { + return (prevGrip * (1 - t) + grip * t) / gripMax; + } + + /** + * @return + */ + public float getGripScale() + { + return gripScale; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java new file mode 100644 index 0000000..c148bd0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -0,0 +1,154 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +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.jewelryCraftingTime / (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; + } + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java new file mode 100644 index 0000000..da8cc19 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -0,0 +1,144 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntityMolder extends TileEntity +{ + public int cooling; + public boolean hasMoltenMetal, hasJewelBase, hasMold, isDirty; + public ItemStack mold, jewelBase, moltenMetal, ringMetal; + public float quantity; + + /** + * + */ + public TileEntityMolder() + { + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + mold = new ItemStack(Item.getItemById(0), 0, 0); + ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + cooling = -1; + quantity = 0f; + hasJewelBase = false; + hasMoltenMetal = false; + hasMold = false; + isDirty = false; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("cooling", cooling); + nbt.setFloat("quantity", quantity); + nbt.setBoolean("hasJewelBase", hasJewelBase); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + nbt.setBoolean("hasMold", hasMold); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + NBTTagCompound tag2 = new NBTTagCompound(); + NBTTagCompound tag3 = new NBTTagCompound(); + mold.writeToNBT(tag); + nbt.setTag("mold", tag); + jewelBase.writeToNBT(tag1); + nbt.setTag("jewelBase", tag1); + moltenMetal.writeToNBT(tag2); + nbt.setTag("moltenMetal", tag2); + ringMetal.writeToNBT(tag3); + nbt.setTag("ringMetal", tag3); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + cooling = nbt.getInteger("cooling"); + quantity = nbt.getFloat("quantity"); + hasJewelBase = nbt.getBoolean("hasJewelBase"); + hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + hasMold = nbt.getBoolean("hasMold"); + mold = new ItemStack(Item.getItemById(0), 0, 0); + mold.readFromNBT(nbt.getCompoundTag("mold")); + jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase")); + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); + ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + ringMetal.readFromNBT(nbt.getCompoundTag("ringMetal")); + } + + /** + * + */ + @Override + public void updateEntity() + { + super.updateEntity(); + if (isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (hasMoltenMetal && moltenMetal.getItem() != Item.getItemById(0) && quantity > 0f){ + if (worldObj.rand.nextInt(20) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.fizz", 0.5F, 1F); + for(int l = 0; l < 2; ++l) + worldObj.spawnParticle("reddust", xCoord + Math.random(), (double)yCoord + 0.2F, zCoord + Math.random(), 0.0D, 1.0D, 1.0D); + } + if (hasMoltenMetal && !hasJewelBase && quantity >= 0.1f){ + ringMetal = moltenMetal.copy(); + if (cooling > 0) cooling--; + if (cooling <= 0f){ + if (mold.getItemDamage() == 0) jewelBase = moltenMetal; + else if (mold.getItemDamage() == 1) jewelBase = new ItemStack(ItemList.ring); + else if (mold.getItemDamage() == 2) jewelBase = new ItemStack(ItemList.necklace); + else if (mold.getItemDamage() == 3) jewelBase = new ItemStack(ItemList.bracelet); + else if (mold.getItemDamage() == 4) jewelBase = new ItemStack(ItemList.earrings); + ringMetal.stackSize = 1; + jewelBase.stackSize = 1; + if (mold.getItemDamage() != 0 && jewelBase != new ItemStack(Item.getItemById(0), 0, 0)) JewelryNBT.addMetal(jewelBase, ringMetal); + hasMoltenMetal = false; + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelBase = true; + cooling = -1; + quantity = 0f; + isDirty = true; + } + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java new file mode 100644 index 0000000..e02cac2 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java @@ -0,0 +1,273 @@ +package darkknight.jewelrycraft.tileentity; + +import java.util.ArrayList; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import darkknight.jewelrycraft.block.BlockHandPedestal; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.particles.EntityShadowsFX; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.PlayerUtils; + +public class TileEntityShadowEye extends TileEntity +{ + public int opening, timer, t = 20; + public boolean active; + public ArrayList<ItemStack> pedestalItems = new ArrayList<ItemStack>(); + ResourceLocation particleTexture = new ResourceLocation("jewelrycraft", "textures/particle/shadows.png"); + + /** + * + */ + public TileEntityShadowEye() + { + opening = 1; + timer = 20; + active = false; + } + + /** + * @param nbt + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("opening", opening); + nbt.setInteger("timer", timer); + nbt.setBoolean("active", active); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + opening = nbt.getInteger("opening"); + timer = nbt.getInteger("timer"); + active = nbt.getBoolean("active"); + } + + /** + * + */ + @Override + public void updateEntity() + { + super.updateEntity(); + boolean valid = isValidStructure(worldObj, xCoord, yCoord, zCoord, blockMetadata); + if (active) timer--; + if (opening == 4 && timer <= 0) active = false; + if (!active && timer <= 0 && opening != 1){ + if (t > 0) t--; + if (t <= 0){ + opening--; + t = 20; + } + } + if (opening == 2 && timer <= 0 && t == 10){ + addData(worldObj, xCoord, yCoord, zCoord); + TileEntityHandPedestal target = (TileEntityHandPedestal)worldObj.getTileEntity(xCoord, yCoord - 3, zCoord); + if (target != null && target.getHeldItemStack() != null) JewelryNBT.addModifiers(target.getHeldItemStack(), pedestalItems); + } + if (active && timer <= 0){ + if (opening < 4){ + opening++; + timer = 20; + } + if (valid && opening == 4) timer = 1000; + else if (!valid){ + active = false; + timer = -1; + } + } + EntityPlayer player1 = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 7F); + if (player1 != null){ + NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player1, "Jewelrycraft"); + persistTag.setBoolean("nearStartedRitual", false); + } + if (active && opening == 4){ + float din = 6F; + int i = Minecraft.getMinecraft().gameSettings.particleSetting; + for(float x = -din; x <= din; x += 0.2F) + for(float z = -din; z <= din; z += 0.2F) + if (x * x + z * z >= din * din - 1 && x * x + z * z <= din * din + 1) Minecraft.getMinecraft().effectRenderer.addEffect(new EntityShadowsFX(worldObj, xCoord + x + 0.5F, yCoord - 0.5F, zCoord + z + 0.5F, 15F, 0.04F - 0.01F * i, particleTexture)); + for(int l = 0; l <= 2 - i; l++) + worldObj.spawnParticle("depthsuspend", xCoord + 6.5F - worldObj.rand.nextInt(9) - worldObj.rand.nextFloat(), yCoord - 2F + worldObj.rand.nextFloat(), zCoord + 6.5F - worldObj.rand.nextInt(9) - worldObj.rand.nextFloat(), 0, 0, 0); + EntityPlayer player = worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 6F); + if (player != null){ + NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + persistTag.setBoolean("nearStartedRitual", true); + } + } + } + + /** + * @param world + * @param x + * @param y + * @param z + * @param metadata + * @return + */ + public boolean isValidStructure(World world, int x, int y, int z, int metadata) + { + if (world.getBlockMetadata(x, y, z) == 0 || world.getBlockMetadata(x, y, z) == 2){ + // Layers from top to bottom + // 1st Layer + if (world.getBlock(x, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z) != 5) return false; + if (world.getBlock(x + 1, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x + 1, y + 1, z) != 5) return false; + if (world.getBlock(x - 1, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x - 1, y + 1, z) != 5) return false; + // 2nd Layer + if (world.getBlock(x + 2, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x + 2, y, z) != 1) return false; + if (world.getBlock(x + 1, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x + 1, y, z) != 4) return false; + if (world.getBlock(x - 1, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x - 1, y, z) != 5) return false; + if (world.getBlock(x - 2, y, z) != Blocks.stone_brick_stairs || world.getBlockMetadata(x - 2, y, z) != 0) return false; + // 3rd Layer + if (world.getBlock(x + 2, y - 1, z) != Blocks.stonebrick) return false; + if (world.getBlock(x - 2, y - 1, z) != Blocks.stonebrick) return false; + // 4th Layer + if (world.getBlock(x + 2, y - 2, z) != Blocks.stonebrick) return false; + if (world.getBlock(x - 2, y - 2, z) != Blocks.stonebrick) return false; + // 5th Layer + if (world.getBlock(x + 2, y - 3, z) != Blocks.stonebrick) return false; + if (world.getBlock(x - 2, y - 3, z) != Blocks.stonebrick) return false; + }else if (world.getBlockMetadata(x, y, z) == 1 || world.getBlockMetadata(x, y, z) == 3){ + // Layers from top to bottom + // 1st Layer + if (world.getBlock(x, y + 1, z) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z) != 5) return false; + if (world.getBlock(x, y + 1, z + 1) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z + 1) != 5) return false; + if (world.getBlock(x, y + 1, z - 1) != Blocks.stone_slab || world.getBlockMetadata(x, y + 1, z - 1) != 5) return false; + // 2nd Layer + if (world.getBlock(x, y, z + 2) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z + 2) != 3) return false; + if (world.getBlock(x, y, z + 1) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z + 1) != 6) return false; + if (world.getBlock(x, y, z - 1) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z - 1) != 7) return false; + if (world.getBlock(x, y, z - 2) != Blocks.stone_brick_stairs || world.getBlockMetadata(x, y, z - 2) != 2) return false; + // 3rd Layer + if (world.getBlock(x, y - 1, z + 2) != Blocks.stonebrick) return false; + if (world.getBlock(x, y - 1, z - 2) != Blocks.stonebrick) return false; + // 4th Layer + if (world.getBlock(x, y - 2, z + 2) != Blocks.stonebrick) return false; + if (world.getBlock(x, y - 2, z - 2) != Blocks.stonebrick) return false; + // 5th Layer + if (world.getBlock(x, y - 3, z + 2) != Blocks.stonebrick) return false; + if (world.getBlock(x, y - 3, z - 2) != Blocks.stonebrick) return false; + } + // 3rd Layer + if (world.getBlock(x - 4, y - 1, z - 4) != BlockList.shadowBlock) return false; + if (world.getBlock(x - 4, y - 1, z + 4) != BlockList.shadowBlock) return false; + if (world.getBlock(x + 4, y - 1, z - 4) != BlockList.shadowBlock) return false; + if (world.getBlock(x + 4, y - 1, z + 4) != BlockList.shadowBlock) return false; + // 4th Layer + if (world.getBlock(x - 4, y - 2, z - 4) != Blocks.stonebrick) return false; + if (world.getBlock(x - 4, y - 2, z + 4) != Blocks.stonebrick) return false; + if (world.getBlock(x + 4, y - 2, z - 4) != Blocks.stonebrick) return false; + if (world.getBlock(x + 4, y - 2, z + 4) != Blocks.stonebrick) return false; + // 5th Layer + // Pillars + if (world.getBlock(x - 4, y - 3, z - 4) != Blocks.stonebrick) return false; + if (world.getBlock(x - 4, y - 3, z + 4) != Blocks.stonebrick) return false; + if (world.getBlock(x + 4, y - 3, z - 4) != Blocks.stonebrick) return false; + if (world.getBlock(x + 4, y - 3, z + 4) != Blocks.stonebrick) return false; + // Pedestals + if (!(world.getBlock(x, y - 3, z) instanceof BlockHandPedestal)) return false; + if (world.getBlock(x - 4, y - 3, z + 2) != BlockList.handPedestal || world.getBlockMetadata(x - 4, y - 3, z + 2) != 1) return false; + if (world.getBlock(x - 5, y - 3, z) != BlockList.handPedestal || world.getBlockMetadata(x - 5, y - 3, z) != 2) return false; + if (world.getBlock(x - 4, y - 3, z - 2) != BlockList.handPedestal || world.getBlockMetadata(x - 4, y - 3, z - 2) != 3) return false; + if (world.getBlock(x - 2, y - 3, z - 4) != BlockList.handPedestal || world.getBlockMetadata(x - 2, y - 3, z - 4) != 3) return false; + if (world.getBlock(x, y - 3, z - 5) != BlockList.handPedestal || world.getBlockMetadata(x, y - 3, z - 5) != 4) return false; + if (world.getBlock(x + 2, y - 3, z - 4) != BlockList.handPedestal || world.getBlockMetadata(x + 2, y - 3, z - 4) != 5) return false; + if (world.getBlock(x + 4, y - 3, z - 2) != BlockList.handPedestal || world.getBlockMetadata(x + 4, y - 3, z - 2) != 5) return false; + if (world.getBlock(x + 5, y - 3, z) != BlockList.handPedestal || world.getBlockMetadata(x + 5, y - 3, z) != 6) return false; + if (world.getBlock(x + 4, y - 3, z + 2) != BlockList.handPedestal || world.getBlockMetadata(x + 4, y - 3, z + 2) != 7) return false; + if (world.getBlock(x + 2, y - 3, z + 4) != BlockList.handPedestal || world.getBlockMetadata(x + 2, y - 3, z + 4) != 7) return false; + if (world.getBlock(x, y - 3, z + 5) != BlockList.handPedestal || world.getBlockMetadata(x, y - 3, z + 5) != 0) return false; + if (world.getBlock(x - 2, y - 3, z + 4) != BlockList.handPedestal || world.getBlockMetadata(x - 2, y - 3, z + 4) != 1) return false; + return true; + } + + /** + * @param world + * @param x + * @param y + * @param z + */ + public void addData(World world, int x, int y, int z) + { + pedestalItems.clear(); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z - 4)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z + 2)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z - 5)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z - 4)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 4, y - 3, z - 2)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 5, y - 3, z)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z - 2)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 5, y - 3, z)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 4, y - 3, z + 2)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x + 2, y - 3, z + 4)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x, y - 3, z + 5)); + addPedestalInfo((TileEntityHandPedestal)world.getTileEntity(x - 2, y - 3, z + 4)); + } + + /** + * @param pedestal + */ + public void addPedestalInfo(TileEntityHandPedestal pedestal) + { + ItemStack heldItemStack; + if (pedestal != null && (heldItemStack = pedestal.getHeldItemStack()) != null){ + if (pedestalItems.isEmpty()) pedestalItems.add(heldItemStack.copy()); + else{ + boolean hasItem = false; + int index = 0; + for(int ind = 0; ind < pedestalItems.size() && !hasItem; ind++) + if (heldItemStack.getItem().equals(pedestalItems.get(ind).getItem()) && heldItemStack.getItemDamage() == pedestalItems.get(ind).getItemDamage()){ + index = ind; + hasItem = true; + if (heldItemStack.hasTagCompound() && pedestalItems.get(ind).hasTagCompound() && !heldItemStack.getTagCompound().equals(pedestalItems.get(ind).getTagCompound())) hasItem = false; + } + if (!hasItem) pedestalItems.add(heldItemStack.copy()); + else{ + ItemStack object = pedestalItems.get(index).copy(); + object.stackSize++; + pedestalItems.set(index, object); + } + } + pedestal.removeHeldItemStack(); + pedestal.openHand(); + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java new file mode 100644 index 0000000..b22602e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowHand.java @@ -0,0 +1,7 @@ +package darkknight.jewelrycraft.tileentity; + +/** + * @author Paul Fulham (pau101) + */ +public class TileEntityShadowHand extends TileEntityHandPedestal +{}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java new file mode 100644 index 0000000..83f2cb2 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -0,0 +1,186 @@ +package darkknight.jewelrycraft.tileentity; + +import java.util.Random; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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 +{ + public int melting, flow, n = 0, p = 0; + public boolean hasMetal, hasMoltenMetal, isDirty, pouring; + public ItemStack metal, moltenMetal; + public float quantity, pouredQuantity = 0.1f; + + /** + * + */ + public TileEntitySmelter() + { + 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) + { + super.writeToNBT(nbt); + nbt.setInteger("melting", melting); + nbt.setFloat("quantity", quantity); + nbt.setBoolean("hasMetal", hasMetal); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + nbt.setBoolean("pouring", pouring); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + metal.writeToNBT(tag); + nbt.setTag("metal", tag); + moltenMetal.writeToNBT(tag1); + nbt.setTag("moltenMetal", tag1); + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + 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){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (p > 0) --p; + else p = 5; + if (n == 0 && p == 0){ + flow += 16; + if (flow >= 16 * 20) n = 1; + } + if (n == 1 && p == 0){ + flow -= 16; + if (flow <= 0) n = 0; + } + 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 (hasMetal && !hasMoltenMetal){ + boolean isOre = JewelrycraftUtil.isOre(metal); + if (melting > 0) melting--; + if (melting == 0){ + hasMetal = false; + if (!isOre) moltenMetal = metal; + else{ + moltenMetal = JewelrycraftUtil.getIngotFromOre(metal.getItem()); + moltenMetal.stackSize *= 2; + } + 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; + isDirty = true; + } + }else if (hasMoltenMetal){ + boolean isOre = JewelrycraftUtil.isOre(metal); + 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; + 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){ + quantity -= 0.01f; + pouredQuantity -= 0.01f; + me.quantity += 0.01f; + if (!me.hasMoltenMetal){ + me.moltenMetal = moltenMetal; + me.hasMoltenMetal = true; + } + if (pouredQuantity <= 0f){ + pouring = false; + pouredQuantity = 0.1f; + me.cooling = ConfigHandler.ingotCoolingTime; + } + if (quantity <= 0f){ + quantity = 0f; + hasMoltenMetal = false; + moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + // pouring = false; + me.cooling = ConfigHandler.ingotCoolingTime; + } + me.isDirty = true; + } + } + + /** + * @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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/ItemRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/ItemRender.java new file mode 100644 index 0000000..31e5676 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/ItemRender.java @@ -0,0 +1,65 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +public class ItemRender implements IItemRenderer +{ + TileEntitySpecialRenderer render; + public TileEntity entity; + ModelBase model; + + /** + * @param render + * @param entity + * @param model + */ + public ItemRender(TileEntitySpecialRenderer render, TileEntity entity, ModelBase model) + { + this.entity = entity; + this.render = render; + this.model = model; + } + + /** + * @param item + * @param type + * @return + */ + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) + { + return true; + } + + /** + * @param type + * @param item + * @param helper + * @return + */ + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return true; + } + + /** + * @param type + * @param item + * @param data + */ + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object ... data) + { + if (type == IItemRenderer.ItemRenderType.ENTITY){ + GL11.glRotatef(180f, 0f, 1f, 0f); + GL11.glTranslatef(-0.5f, -0.5f, -0.4f); + } + render.renderTileEntityAt(entity, 0.0D, 0.0D, 0.0D, 0.0F); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/MaskRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/MaskRender.java new file mode 100644 index 0000000..1e26107 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/MaskRender.java @@ -0,0 +1,30 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelMask; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; + +public class MaskRender extends TileEntitySpecialRenderer +{ + ModelMask mask = new ModelMask(); + ResourceLocation texture = new ResourceLocation("jewelrycraft", "textures/entities/Mask.png"); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + } + + public void doRender(Entity entity, double x, double y, double z, float f, float g) + { + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(texture); + mask.render(entity, 0F, 0F, 0F, 0F, 0F, 0.02F); + GL11.glPopMatrix(); + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java new file mode 100644 index 0000000..8cff8bc --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityDisplayerRender.java @@ -0,0 +1,262 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import java.awt.Color; +import java.util.HashMap; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; + +public class TileEntityDisplayerRender extends TileEntitySpecialRenderer +{ + ModelDisplayer displayer = new ModelDisplayer(); + String texture = "textures/tileentities/Displayer.png"; + HashMap<EnumChatFormatting, Integer> colors = new HashMap<EnumChatFormatting, Integer>(){ + { + put(EnumChatFormatting.AQUA, 5636095); + put(EnumChatFormatting.BLACK, 0); + put(EnumChatFormatting.BLUE, 5592575); + put(EnumChatFormatting.DARK_AQUA, 43690); + put(EnumChatFormatting.DARK_BLUE, 170); + put(EnumChatFormatting.DARK_GRAY, 5592405); + put(EnumChatFormatting.DARK_GREEN, 43520); + put(EnumChatFormatting.DARK_PURPLE, 11141290); + put(EnumChatFormatting.DARK_RED, 11141120); + put(EnumChatFormatting.GOLD, 16755200); + put(EnumChatFormatting.GRAY, 11184810); + put(EnumChatFormatting.GREEN, 5635925); + put(EnumChatFormatting.LIGHT_PURPLE, 16733695); + put(EnumChatFormatting.RED, 16733525); + put(EnumChatFormatting.WHITE, 16777215); + put(EnumChatFormatting.YELLOW, 16777045); + } + }; + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + TileEntityDisplayer disp = (TileEntityDisplayer)te; + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + displayer.render((Entity)null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F); + try{ + int block = disp.getBlockMetadata(); + if (disp != null && disp.hasObject && disp.object != null && disp.object.getItem() != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0)){ + int ind = -3; + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, disp.object); + entityitem.hoverStart = 0.0F; + disp.object.stackSize = 1; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1 / 5, 0F); + GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else{ + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + int i = 15728880; + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 5D); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + if (player != null) renderLabel(disp.object.getDisplayName(), 0F, -0.171F * ind, 0F, block, disp, colors.get(disp.object.getRarity().rarityColor)); + GL11.glPopMatrix(); + ind++; + if (player != null && disp.quantity > 1){ + GL11.glPushMatrix(); + renderLabel("x" + Integer.toString(disp.quantity), 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + if (disp.object.getItem() != Items.map && player != null && disp.object.getTooltip(player, true) != null){ + List tooltips = disp.object.getTooltip(player, true); + if (disp.infoIndex + 5 > tooltips.size()) disp.infoIndex = 1; + if (tooltips.size() < 5) for(int i = 1; i < tooltips.size(); i++){ + String tooltip = tooltips.get(i).toString(); + RenderManager.instance.getFontRenderer(); + if (tooltip != ""){ + GL11.glPushMatrix(); + renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + } + else for(int i = disp.infoIndex; i < disp.infoIndex + 5; i++){ + String tooltip = tooltips.get(i).toString(); + RenderManager.instance.getFontRenderer(); + if (tooltip != ""){ + GL11.glPushMatrix(); + renderLabel(tooltip, 0F, -0.171F * ind, 0F, block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + } + } + } + } + catch(Exception e){} + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param par2Str + * @param x + * @param y + * @param z + * @param metadata + * @param te + * @param color + */ + protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te, int color) + { + FontRenderer fontrenderer = RenderManager.instance.getFontRenderer(); + float var14 = 0.01266667F * 1.5F; + float var17 = 0.015F; + GL11.glRotatef(180F, 0F, 0F, 1F); + if (metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F); + else if (metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F); + else if (metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F); + else if (metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F); + GL11.glScalef(-0.015F, -var14, 0.015F); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + int j = fontrenderer.getStringWidth(par2Str) / 2; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(0.0F, 0.2F, 0.2F, 0.9F); + tessellator.addVertex(-33.333 - 0, 0D, 0.1D); + tessellator.addVertex(-33.333 - 0, 9D, 0.1D); + tessellator.addVertex(33.333 + 0, 9D, 0.1D); + tessellator.addVertex(33.333 + 0, 0D, 0.1D); + tessellator.draw(); + if (fontrenderer.getStringWidth(par2Str) / 2 > 20) var17 = 0.9F / fontrenderer.getStringWidth(par2Str); + else var17 = var14; + int red = color >> 16 & 0xFF; + int green = color >> 8 & 0xFF; + int blue = color & 0xFF; + GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glScalef(var17 * 70F, 1F, 0F); + int i = 15728880; + int t = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, t / 1.0F, k / 1.0F); + fontrenderer.drawString(par2Str.replaceFirst("§0", "§r").replaceFirst("§1", "§r").replaceFirst("§2", "§r").replaceFirst("§3", "§r").replaceFirst("§4", "§r").replaceFirst("§5", "§r").replaceFirst("§6", "§r").replaceFirst("§7", "§r").replaceFirst("§8", "§r").replaceFirst("§9", "§r").replaceFirst("§a", "§r").replaceFirst("§b", "§r").replaceFirst("§c", "§r").replaceFirst("§d", "§r").replaceFirst("§e", "§r").replaceFirst("§f", "§r"), -j, 0, 65536 * (red > 170 ? red - 170 : 0) + 256 * (green > 170 ? green - 170 : 0) + (blue > 170 ? blue - 170 : 0)); + GL11.glPopMatrix(); + GL11.glTranslatef((float)x - 1f, (float)y - 1f, (float)z - 1F); + GL11.glScalef(var17 * 70F, 1F, 0F); + fontrenderer.drawString(par2Str, -j, 0, color); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + /** + * @param str + * @param color + */ + public void replaceEnumEnchValues(String str, int color) + { + if (str.contains("§0")){ + color = Color.BLACK.getRGB(); + str.replace("§0", ""); + } + if (str.contains("§1")){ + color = 85; + str.replace("§1", ""); + } + if (str.contains("§2")){ + color = 17920; + str.replace("§2", ""); + } + if (str.contains("§3")){ + color = 1336183; + str.replace("§3", ""); + } + if (str.contains("§4")){ + color = 4587520; + str.replace("§4", ""); + } + if (str.contains("§5")){ + color = 5701759; + str.replace("§5", ""); + } + if (str.contains("§6")){ + color = 16762880; + str.replace("§6", ""); + } + if (str.contains("§7")){ + color = Color.GRAY.getRGB(); + str.replace("§7", ""); + } + if (str.contains("§8")){ + color = Color.DARK_GRAY.getRGB(); + str.replace("§8", ""); + } + if (str.contains("§9")){ + color = Color.BLUE.getRGB(); + str.replace("§9", ""); + } + if (str.contains("§a")){ + color = Color.GREEN.getRGB(); + str.replace("§a", ""); + } + if (str.contains("§b")){ + color = Color.CYAN.getRGB(); + str.replace("§b", ""); + } + if (str.contains("§c")){ + color = Color.RED.getRGB(); + str.replace("§c", ""); + } + if (str.contains("§d")){ + color = 11665663; + str.replace("§d", ""); + } + if (str.contains("§e")){ + color = Color.YELLOW.getRGB(); + str.replace("§e", ""); + } + if (str.contains("§f")){ + color = Color.WHITE.getRGB(); + str.replace("§f", ""); + } + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java new file mode 100644 index 0000000..ac98ca6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityHandPedestalRender.java @@ -0,0 +1,47 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelHandPedestal; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; + +/** + * @author Paul Fulham (pau101) + */ +public class TileEntityHandPedestalRender extends TileEntitySpecialRenderer +{ + private ModelHandPedestal model; + private ResourceLocation texture; + + /** + * @param model + * @param texture + */ + public TileEntityHandPedestalRender(ModelHandPedestal model, ResourceLocation texture) + { + this.model = model; + this.texture = texture; + } + + /** + * @param te + * @param x + * @param y + * @param z + * @param partialRenderTicks + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialRenderTicks) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + TileEntityHandPedestal pedestal = (TileEntityHandPedestal)te; + bindTexture(texture); + GL11.glRotatef(180, 0, 0, 1); + GL11.glRotatef(pedestal.getWorldObj() == null ? 180 : pedestal.getBlockMetadata() % 8 / 8F * 360, 0, 1, 0); + model.render(pedestal, partialRenderTicks, 0.0625F); + GL11.glPopMatrix(); + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java new file mode 100644 index 0000000..7a8e35b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityJewelrsCraftingTableRender.java @@ -0,0 +1,136 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; + +public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRenderer +{ + ModelJewlersCraftingBench modelTable = new ModelJewlersCraftingBench(); + String texture = "textures/tileentities/JewelrsCraftingBench.png"; + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + TileEntityJewelrsCraftingTable jt = (TileEntityJewelrsCraftingTable)te; + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try{ + int block = te.getBlockMetadata(); + if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + }else if (block == 3){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } + catch(Exception e){} + modelTable.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + if (jt != null){ + if (jt.hasJewelry && jt.jewelry.getIconIndex() != null && jt.jewelry.getIconIndex().getIconName() != ""){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.jewelry); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else{ + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasEndItem && jt.endItem.getIconIndex().getIconName() != ""){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.endItem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else{ + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasGem && jt.gem.getIconIndex().getIconName() != ""){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.gem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if (RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else{ + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java new file mode 100644 index 0000000..9685e2e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMolderRender.java @@ -0,0 +1,138 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.model.ModelMolder; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntityMolderRender extends TileEntitySpecialRenderer +{ + ModelMolder modelMolder = new ModelMolder(); + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + TileEntityMolder me = (TileEntityMolder)te; + String texture = "textures/tileentities/Molder.png"; + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try{ + int block = me.getBlockMetadata(); + if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + }else if (block == 3){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } + catch(Exception e){} + modelMolder.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics; + if (me != null){ + if (me.hasMold){ + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.mold); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.43F, -0.28F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + if (entityitem != null){ + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.03D, 0.0F, 0.0F); + } + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; + GL11.glPopMatrix(); + } + if (me.hasJewelBase && me.jewelBase.getIconIndex() != null && me.jewelBase.getIconIndex().getIconName() != ""){ + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.jewelBase); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.4F, -0.28F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + if (entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.01D, 0.0F, 0.0F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; + GL11.glColor4f(1, 1F, 1F, 1.0F); + GL11.glPopMatrix(); + } + if (me.hasMoltenMetal && me.moltenMetal != null && me.moltenMetal != new ItemStack(Item.getItemById(0), 0, 0)){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender){ + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + ItemStack metal = new ItemStack(ItemList.metal); + ItemStack ingot = me.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metal, ingot); + EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); + moltenMetal.getEntityItem().stackSize = 1; + moltenMetal.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.38f - 0.005f * me.quantity, -0.29F); + GL11.glScalef(1.1F, 1.0F, 1.4F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java new file mode 100644 index 0000000..7bf2363 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowEyeRender.java @@ -0,0 +1,79 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.model.ModelShadowEye; +import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; + +public class TileEntityShadowEyeRender extends TileEntitySpecialRenderer +{ + ModelShadowEye eye = new ModelShadowEye(); + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.6F, (float)z + 0.5F); + TileEntityShadowEye eyeS = (TileEntityShadowEye)te; + String texture = "textures/tileentities/ShadowEye" + eyeS.opening + ".png"; + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try{ + int block = te.getBlockMetadata(); + if (block == 0) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + }else if (block == 2){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } + catch(Exception e){} + try{ + EntityPlayer player = te.getWorldObj().getClosestPlayer(te.xCoord, te.yCoord, te.zCoord, 16D); + if (player != null) eye.render(player, te.xCoord, te.yCoord, te.zCoord, te.blockMetadata, eyeS.opening, 0.0625F); + } + catch(Exception e){ + eye.render((Entity)null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + */ + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, modulousModifier, divModifier); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java new file mode 100644 index 0000000..d0e2799 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityShadowHandRender.java @@ -0,0 +1,20 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.util.ResourceLocation; +import darkknight.jewelrycraft.model.ModelHandPedestal; + +/** + * @author Paul Fulham (pau101) + */ +public class TileEntityShadowHandRender extends TileEntityHandPedestalRender +{ + + /** + * @param model + * @param texture + */ + public TileEntityShadowHandRender(ModelHandPedestal model, ResourceLocation texture) + { + super(model, texture); + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java new file mode 100644 index 0000000..e6a92a5 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntitySmelterRender.java @@ -0,0 +1,125 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.model.ModelSmelter; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntitySmelterRender extends TileEntitySpecialRenderer +{ + ModelSmelter modelSmelter = new ModelSmelter(); + public static final float p = 1 / 16, p3 = 3 * p, p13 = 13 * p, p15 = 15 * p; + + /** + * @param te + * @param x + * @param y + * @param z + * @param scale + */ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + String texture = "textures/tileentities/Smelter.png"; + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + TileEntitySmelter st = (TileEntitySmelter)te; + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + try{ + int block = te.getBlockMetadata(); + if (block == 1) GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + else if (block == 2){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + }else if (block == 3){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + } + } + catch(Exception e){} + boolean fancyGraphics = Minecraft.getMinecraft().gameSettings.fancyGraphics; + modelSmelter.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + if (scale != 0){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender){ + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(Blocks.lava, 1, 1)); + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.25F, -0.345F); + GL11.glScalef(1.2F, 1.0F, 1.7F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + int i = 15728880; + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F); + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (st != null){ + if (st.hasMetal && st.metal != null && st.metal.getItem() != null){ + GL11.glPushMatrix(); + EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, st.metal); + metal.getEntityItem().stackSize = 1; + metal.hoverStart = 0.0F; + GL11.glRotatef(-50F, 1F, 0F, 0F); + GL11.glRotatef(-50F, 0F, 0F, 1F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.9F, -0.9F, -1.6F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + Minecraft.getMinecraft().gameSettings.fancyGraphics = fancyGraphics; + GL11.glPopMatrix(); + } + if (st.hasMoltenMetal && st.moltenMetal != null && st.moltenMetal.getItem() != null){ + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + if (JewelrycraftMod.fancyRender){ + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 1, 0, 0); + } + ItemStack metal = new ItemStack(ItemList.metal); + ItemStack ingot = st.moltenMetal.copy(); + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metal, ingot); + EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, metal); + moltenMetal.getEntityItem().stackSize = 1; + moltenMetal.hoverStart = 0.0F; + GL11.glTranslatef(-0F, 1.00f - .4F * st.quantity, -0.14F); + GL11.glScalef(0.71F, 1F, 0.84F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + if (JewelrycraftMod.fancyRender) GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + } +} |
