summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/tileentity
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-02-08 03:03:22 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-02-08 03:03:22 +0200
commit4d0e0e8de72bda8543a888082a93b1e56f13856b (patch)
treeb17c62ab7119ce485d49f163e4c10dfd05ae0d57 /common/darkknight/jewelrycraft/tileentity
parent9075a22c3e303699db18062ebfc0159cace27c29 (diff)
Added a new block and implemented an on/off "switch" for the rings that give buffs, also working on balancing the rings
Diffstat (limited to 'common/darkknight/jewelrycraft/tileentity')
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java77
-rw-r--r--common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java1
2 files changed, 78 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java b/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java
new file mode 100644
index 0000000..138d0ab
--- /dev/null
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java
@@ -0,0 +1,77 @@
+package darkknight.jewelrycraft.tileentity;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+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()
+ {
+ this.metadata = -1;
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt)
+ {
+ super.writeToNBT(nbt);
+ nbt.setInteger("metadata", metadata);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt)
+ {
+ super.readFromNBT(nbt);
+ this.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((float)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.getBlockId(xCoord, yCoord, zCoord));
+ }
+
+ @Override
+ public Packet getDescriptionPacket()
+ {
+ Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket();
+ NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound();
+ writeToNBT(dataTag);
+ return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag);
+ }
+
+ @Override
+ public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
+ {
+ super.onDataPacket(net, pkt);
+ NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound();
+ readFromNBT(tag);
+ }
+}
diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
index 935d87b..69fd69a 100644
--- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
+++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java
@@ -112,6 +112,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity
if (hasModifier && modifier != new ItemStack(0, 0, 0)) JewelryNBT.addModifier(endItem, modifier);
if (hasJewel && jewel != new ItemStack(0, 0, 0)) JewelryNBT.addJewel(endItem, jewel);
if (hasJewel && hasModifier && JewelryNBT.isJewelX(endItem, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(endItem, new ItemStack(Item.book))) JewelryNBT.addMode(endItem, "Disenchant");
+ if (hasModifier && JewelryNBT.isModifierEffectType(endItem)) JewelryNBT.addMode(endItem, "Activated");
this.hasJewelry = false;
this.jewelry = new ItemStack(0, 0, 0);
this.hasModifier = false;