Jump to content

[1.7.10] Can't change int variable in Tile Entity


jackmano

Recommended Posts

K, so i have a tile that I want to have different effects, but it wont change the variable that selects which effect! I'm using

TileHydroTorch htorch = (TileHydroTorch)icommandsender.getEntityWorld().getTileEntity(x,y,z);
			  if(Integer.parseInt(commands[3]) > 2 || Integer.parseInt(commands[3]) < 0 || Integer.parseInt(commands[3]) != (int)Integer.parseInt(commands[3]))
			  htorch.state = (Integer.parseInt(commands[3]));

to grab the tile from the world and set the variable, but it does nothing. I tried some

System.out.println("did such and such");

's and they say that htorch.state was called. But whenever I check the tile, it isnt changed! HELP!

tile code

package com.rabidfox.syntheticgems;

import java.util.Random;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileHydroTorch extends TileEntity {
public int state;
public int ticksleft;
Random rdm = new Random();
public int getFacing() {
	return 0;

}
public TileHydroTorch(){
	ticksleft = 10;
	state = 0;
}
@Override
public void writeToNBT(NBTTagCompound nbt){
	super.writeToNBT(nbt);
	nbt.setInteger("state", state);
}
@Override
public void readFromNBT(NBTTagCompound nbt){
	super.readFromNBT(nbt);
	state = nbt.getInteger("state");
}

@Override
public void updateEntity(){
	ticksleft--;
	if(state > 2 || state < 0 || state != (int)state){
		System.err.println("The Hydrogen Torch at " + this.xCoord + this.yCoord + this.zCoord +" has an invalid state value of " + state + "! Must be 0(off), 1(spraying hydrogen), 2(spraying fire)! Use the setHydroTorchState command to fix it!");
	}
	if(state == 2){
		worldObj.spawnParticle("flame", xCoord +(rdm.nextFloat()/5) + (0.25F * 1.5), yCoord +0.5F, zCoord +(rdm.nextFloat()/5) + (0.25F * 1.5), 0.0D, -0.5D, 0.0D);
	}
	if(state == 1){
		if(ticksleft == 0){
		worldObj.spawnParticle("cloud", xCoord +(rdm.nextFloat()/2) + (0.25F * 1.5), yCoord +0.5F, zCoord +(rdm.nextFloat()/2) + (0.25F * 1.5), 0.0D, 0.03D, 0.0D);
		ticksleft = 10;

		}
	}

}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.