summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-02-21 21:31:16 +0000
commit420faddca46e70e3a70def168fb4e452ef193b0d (patch)
tree247e334012e4bf9e4fa6d42718bf601ce6bd42d9 /java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
parent3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b (diff)
Added just a butt ton of stuff, also thanks to pau101 for helping me with the Hand Pedestal animation :)
Diffstat (limited to 'java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java')
-rw-r--r--java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java175
1 files changed, 91 insertions, 84 deletions
diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java b/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
index 7a7a7c3..e02cac2 100644
--- a/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
+++ b/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java
@@ -1,20 +1,17 @@
package darkknight.jewelrycraft.tileentity;
import java.util.ArrayList;
-import java.util.List;
-
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
-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 net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import cpw.mods.fml.common.registry.GameData;
import darkknight.jewelrycraft.block.BlockHandPedestal;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.particles.EntityShadowsFX;
@@ -25,20 +22,22 @@ public class TileEntityShadowEye extends TileEntity
{
public int opening, timer, t = 20;
public boolean active;
- public int field_145926_a;
- public float field_145933_i;
- public float field_145931_j;
- public float field_145930_m;
- public float field_145927_n;
public ArrayList<ItemStack> pedestalItems = new ArrayList<ItemStack>();
+ ResourceLocation particleTexture = new ResourceLocation("jewelrycraft", "textures/particle/shadows.png");
+ /**
+ *
+ */
public TileEntityShadowEye()
{
- this.opening = 1;
- this.timer = 20;
- this.active = false;
+ opening = 1;
+ timer = 20;
+ active = false;
}
+ /**
+ * @param nbt
+ */
@Override
public void writeToNBT(NBTTagCompound nbt)
{
@@ -48,84 +47,83 @@ public class TileEntityShadowEye extends TileEntity
nbt.setBoolean("active", active);
}
+ /**
+ * @param nbt
+ */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
- this.opening = nbt.getInteger("opening");
- this.timer = nbt.getInteger("timer");
- this.active = nbt.getBoolean("active");
+ 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 (opening == 4 && timer <= 0) active = false;
+ if (!active && timer <= 0 && opening != 1){
if (t > 0) t--;
- if (t <= 0)
- {
+ if (t <= 0){
opening--;
t = 20;
}
}
- if (opening == 4)
- {
+ 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.object != null && target.object.getItem() != null) JewelryNBT.addModifiers(target.object, pedestalItems);
+ 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)
- {
+ if (active && timer <= 0){
+ if (opening < 4){
opening++;
timer = 20;
}
- if (valid && opening == 4) timer = 200;
- else if (!valid)
- {
+ if (valid && opening == 4) timer = 1000;
+ else if (!valid){
active = false;
timer = -1;
}
}
- EntityPlayer player1 = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 7F);
- if (player1 != null)
- {
+ 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)
- {
+ 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));
-
- for (int l = 0; l <= 2 - i; l++)
+ 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 = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, 6F);
- if (player != null)
- {
+ 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)
- {
+ 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;
@@ -145,9 +143,7 @@ public class TileEntityShadowEye extends TileEntity
// 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)
- {
+ }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;
@@ -189,74 +185,85 @@ public class TileEntityShadowEye extends TileEntity
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));
+ 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)
{
- if (pedestal != null && pedestal.object != null && pedestal.object.getItem() != null)
- {
- if (pedestalItems.isEmpty()) pedestalItems.add(pedestal.object.copy());
- else
- {
+ 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 (pedestal.object.getItem().equals(pedestalItems.get(ind).getItem()) && pedestal.object.getItemDamage() == pedestalItems.get(ind).getItemDamage())
- {
+ 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 (pedestal.object.hasTagCompound() && pedestalItems.get(ind).hasTagCompound() && !pedestal.object.getTagCompound().equals(pedestalItems.get(ind).getTagCompound())) hasItem = false;
+ if (heldItemStack.hasTagCompound() && pedestalItems.get(ind).hasTagCompound() && !heldItemStack.getTagCompound().equals(pedestalItems.get(ind).getTagCompound())) hasItem = false;
}
- }
- if (!hasItem) pedestalItems.add(pedestal.object.copy());
- else
- {
+ 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();
- this.writeToNBT(nbttagcompound);
- return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound);
+ writeToNBT(nbttagcompound);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound);
}
+ /**
+ * @param net
+ * @param packet
+ */
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
{