diff --git a/src/main/java/nmd/primal/energy/block/CrankBlock.java b/src/main/java/nmd/primal/energy/block/CrankBlock.java index 6ac5ac4..ae0ef03 100644 --- a/src/main/java/nmd/primal/energy/block/CrankBlock.java +++ b/src/main/java/nmd/primal/energy/block/CrankBlock.java @@ -32,6 +32,11 @@ public class CrankBlock extends Block implements ITileEntityProvider{ //if(!world.isRemote){ System.out.println(world.getBlockMetadata(x, y, z)); + TileEntCrank tile = (TileEntCrank) world.getTileEntity(x, y, z); + if(tile.isPowered == false){ + tile.isPowered = true; + } + //} return true; diff --git a/src/main/java/nmd/primal/energy/render/block/RenderCrank.java b/src/main/java/nmd/primal/energy/render/block/RenderCrank.java index 84b63b2..b7a11b4 100644 --- a/src/main/java/nmd/primal/energy/render/block/RenderCrank.java +++ b/src/main/java/nmd/primal/energy/render/block/RenderCrank.java @@ -66,27 +66,19 @@ public class RenderCrank extends TileEntitySpecialRenderer { GL11.glScalef(scale, scale, scale); GL11.glTranslatef(1.0F, 0.48F, 1.0F); + if(tl.isPowered == true){ - if(tl.getBlockMetadata()==1){ - //System.out.println((float)6.2832*(180F / (float)Math.PI)); - //for(int a=0; a<3600; a = a+10){ - - GL11.glRotatef(i, 0.0F, 1.0F, 0.0F); - - - //} + GL11.glRotatef(i, 0.0F, 1.0F, 0.0F); + a++; + if(a==1){ + i=i+7; + a=0; + } + if(i==360){ + i=0; + } + } - //GL11.glRotatef((((180F / (float)Math.PI))), 0.0F, 1.0F, 0.0F); - //(float)Minecraft.getSystemTime() - } - a++; - if(a==5){ - i=i+2; - a=0; - } - if(i==360){ - i=0; - } // FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); diff --git a/src/main/java/nmd/primal/energy/tileents/TileBase.java b/src/main/java/nmd/primal/energy/tileents/TileBase.java index f6761a7..45df1a9 100644 --- a/src/main/java/nmd/primal/energy/tileents/TileBase.java +++ b/src/main/java/nmd/primal/energy/tileents/TileBase.java @@ -1,5 +1,6 @@ package nmd.primal.energy.tileents; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -7,13 +8,32 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public abstract class TileBase extends TileEntity { +public class TileBase extends TileEntity{ private String specName; - + public boolean isPowered; + public TileBase(String name){ specName = name; } + + /* + * + * this.hits = tagCompound.getInteger("HITS"); + this.coolTicks = tagCompound.getInteger("COOLTICK"); + this.heatTicks = tagCompound.getInteger("HEATTICKS"); + this.hot = tagCompound.getBoolean("HOT"); + } + + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + tagCompound.setInteger("HITS", this.hits); + tagCompound.setInteger("COOLTICK", this.coolTicks); + tagCompound.setInteger("HEATTICKS", this.heatTicks); + tagCompound.setBoolean("HOT", this.hot); + */ public void markForUpdate(){ worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); @@ -33,12 +53,14 @@ public abstract class TileBase extends TileEntity { public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); + this.isPowered = tagCompound.getBoolean("ISPOWERED"); } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); + tagCompound.setBoolean("ISPOWERED", this.isPowered); } @Override diff --git a/src/main/java/nmd/primal/energy/tileents/TileEntCrank.java b/src/main/java/nmd/primal/energy/tileents/TileEntCrank.java index 8857885..59673c5 100644 --- a/src/main/java/nmd/primal/energy/tileents/TileEntCrank.java +++ b/src/main/java/nmd/primal/energy/tileents/TileEntCrank.java @@ -1,13 +1,47 @@ package nmd.primal.energy.tileents; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class TileEntCrank extends TileBase { + private int i; + public TileEntCrank(String name) { super(name); } - - + + @Override + public void updateEntity() { + World world = this.getWorldObj(); + int x = this.xCoord; + int y = this.yCoord; + int z = this.zCoord; + if(this.isPowered==true){ + i++; + if(i>16){ + this.isPowered=false; + i=0; + } + } + if (worldObj.isRemote) return; + //System.out.println(this.isPowered + " " + i); + } + + /*@Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + this.isPowered = tagCompound.getBoolean("ISPOWERED"); + } + + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + tagCompound.setBoolean("ISPOWERED", this.isPowered); + } + */ }