Jump to content

Recommended Posts

Posted

EDIT(SOLUTION): The problem was I used x, y, and z when I set my NBT data, and the TileEntity class uses those to get information about where the block is in the readFromNBT method. Moral of the story is always check the super to make sure you don't use variables they were already using...

To be 100% safe just use your modID as a prefix to all your NBT keys, as said by Draco.

 

So basically I had this problem before and fixed it, using the setDirty().

Now that I have added some more variables, it will not save at all, ever.(And by "save" I mean when I exit the world and come back the data persist)

 

My TE class has a lot of stuff, but the read/write to NBT are both a few up from the very bottom. The reason there is so many setDirty()'s everywhere is because it was my last ditch attempt to try and get data to save.

 

My TE class

 

package com.theundertaker11.kitchensink.tileentity;

import java.util.UUID;

import com.mojang.authlib.GameProfile;
import com.theundertaker11.kitchensink.KitchenSink;
import com.theundertaker11.kitchensink.ModUtils;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;

public class KSTileEntityQuarryBlock extends TileEntity implements ITickable{
public static int ticksNeeded = KitchenSink.QuarryTicksBetweenOperations;
public static int radius = KitchenSink.QuarryRadius;

public static final int SIZE = 1;
//TODO Add the ability to replace the blocks broken with cobblestone or stone
//private boolean replaceBlocks;
private boolean quarryFinished;
private int Energy;
private int x;
private int y;
private int z;
private int blocksToMine;
//Vars below this don't need to be saved
private int tickTimer;
private boolean isOff;

//TODO Implement a fake player to break the blocks the quarry breaks.
//private static GameProfile KitchenSinkProfile = new GameProfile(UUID.fromString("a7d50290-b3f6-4dd9-afa1-d1de51ce3355"),"[KitchenSink]");
//private FakePlayer KitchenSinkPlayer = new FakePlayer(this.getWorld().getMinecraftServer().worldServerForDimension(this.getWorld().provider.getDimension()),KitchenSinkProfile);

public KSTileEntityQuarryBlock(){
	super();
}

private ItemStackHandler itemStackHandler = 
    		new ItemStackHandler(SIZE){
        @Override
        protected void onContentsChanged(int slot){
            KSTileEntityQuarryBlock.this.markDirty();
        }
    };
    
@Override
public void update()
{ 
	if(this.getWorld().isRemote) return;
	//Makes sure the tick timer can go as high as it needs but still has a limit.
	if(this.tickTimer<(this.ticksNeeded+200))
	{
		++this.tickTimer;
	}

	World world = this.getWorld();
	IItemHandler quarry = world.getTileEntity(this.getPos()).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);

	//Pretty much all quarry mining code called here.
	if(this.tickTimer>=this.ticksNeeded&&this.blocksToMine!=0&&this.Energy>0&&!this.quarryFinished&&!this.isOff)
	{	
		tryToMineBlock(new BlockPos(x,y,z), world);
	}

	//This auto-exports items out the top of the quarry to any inventory that is there.
	if(quarry.getStackInSlot(0)!=null && ModUtils.getIItemHandlerAtPos(world, this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ(), EnumFacing.DOWN)!=null)
	{
		IItemHandler upInventory = ModUtils.getIItemHandlerAtPos(world, this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ(), EnumFacing.DOWN);
		if(quarry.getStackInSlot(0)!=null) // Hey can't hurt to check twice right? Make extra sure??
		{
			ItemStack quarrysItem = quarry.getStackInSlot(0).copy();
			for(int i=0;i<upInventory.getSlots();i++)
			{
				if(upInventory.insertItem(i, quarrysItem, false)==null)
				{
					quarry.extractItem(0, quarry.getStackInSlot(0).stackSize, false);
					break;
				}
			}
		}

	} 
}
//TODO Make it so the quarry actually gets the blocks it breaks and puts them in its inventory(Silk touch way)
public void tryToMineBlock(BlockPos blockPos, World world)
{
	if(world.isRemote) return;
	int localx;
	int localy;
	int localz;
	if(this.y==0)
	{
		localx=(this.getPos().getX()-this.radius);
		localy=(this.getPos().getY()-1);
		localz=(this.getPos().getZ()-this.radius);
		this.markDirty();
	}
	//The logic here is I do all Y's down then move across the X axis, then after I hit a side scoot the Z over 1 and start the 
	//x and y mining again.
	else
	{
		//Big stuff will only happen after it tried to mine the last Y yea?
			if(this.y==1)
			{
				localy=(this.getPos().getY()-1);
				//If x is at max then reset it back to the lowest value.
				if(this.x==(this.getPos().getX()+this.radius))
				{
					localx=(this.getPos().getX()-this.radius);
					//If Z is max then the quarry is done.
					if(this.z==(this.getPos().getZ()+this.radius))
					{
						//This is so it won't even try to mine if its finished the X Y and Z at the same time.
						setQuarryFinished(true);
						localz=this.z;
					}
					//If X is finished, add 1 to Z(given its not already at max, checked above)
					else localz = (this.z+1);
				}
				//If Y is finished, add 1 to X(given its not already at max, checked above)
				else
				{
					localx=(this.x+1);
					localz=this.z;
				}

			}
			else{
				localy=(this.y-1);
				localx=this.x;
				localz=this.z;
			}
			this.markDirty();
	}
	if(this.quarryFinished) return;

	Block blockToMine = world.getBlockState(blockPos).getBlock();

	if(blockToMine!=Blocks.AIR)
	{
		if(blockToMine==Blocks.WATER)
		{
			world.setBlockToAir(blockPos);
		}
		else
		{
			this.tickTimer=0;
			this.removeEnergy(1);
			world.destroyBlock(blockPos, true);
		}
	}
	this.x = localx;
	this.y = localy;
	this.z = localz;
	this.blocksToMine=(this.blocksToMine-1);
	this.markDirty();
}
/**
 * Finds how many blocks there are to mine(including air) and sets that to the blocksToMine variable.
 */
public void setTotalBlocksToMine()
{
	int blockcount = 0;
	for(int x = this.pos.getX() - this.radius; x < this.pos.getX() + this.radius; x++ )
	{
  			for(int y = 1; y < this.pos.getY()-1; y++ )
  			{
      			for(int z = this.pos.getZ() - this.radius; z < this.pos.getZ() + this.radius; z++ )
      			{
      				++blockcount;
      			}
  			}
	}
	this.blocksToMine=blockcount;
	this.markDirty();
}

public void addEnergy(int amount)
{
	this.Energy = (this.Energy+amount);
	this.markDirty();
}

//public void setReplaceBlocks(boolean bool)
//{
//	this.replaceBlocks = bool;
//}

public int getEnergy()
{
	return this.Energy;
}

public void removeEnergy(int amount)
{
	if(this.Energy>=amount) this.Energy = (this.Energy-amount);
	else this.Energy=0;
	this.markDirty();
}

public int getBlocksToMine()
{
	return this.blocksToMine;
}

public void setQuarryFinished(boolean bool)
{
	this.quarryFinished = bool;
	this.markDirty();
}

public void setIsOff(boolean bool)
{
	this.isOff = bool;
}

@Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
        super.writeToNBT(compound);
        compound.setTag("items", itemStackHandler.serializeNBT());
        //compound.setBoolean("replaceBlocks", this.replaceBlocks);
        compound.setInteger("Energy", this.Energy);
        compound.setInteger("blocksToMine", this.blocksToMine);
        compound.setInteger("x", this.x);
        compound.setInteger("y", this.y);
        compound.setInteger("z", this.z);
        compound.setBoolean("quarryFinished", this.quarryFinished);
        return compound;
        
    }
@Override
public void readFromNBT(NBTTagCompound compound)
{
	super.readFromNBT(compound);
	if (compound.hasKey("items")) {
            itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("items"));
        }
	//this.replaceBlocks = compound.getBoolean("replaceBlocks");
	this.Energy = compound.getInteger("Energy");
	this.blocksToMine = compound.getInteger("blocksToMine");
	this.x = compound.getInteger("x");
	this.y = compound.getInteger("y");
	this.z = compound.getInteger("z");
	this.quarryFinished = compound.getBoolean("quarryFinished");
}

@Override
    public boolean shouldRefresh(final World world, final BlockPos pos, final IBlockState oldState, final IBlockState newState) {
        return oldState.getBlock() != newState.getBlock();
    }

@Override
    public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
            return true;
        }
        return super.hasCapability(capability, facing);
    }

    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
        if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
            return (T) itemStackHandler;
        }
        return super.getCapability(capability, facing);
    }

}

 

My Block class(Since this gives me some of the numbers I've been using it to check if they save)

 

package com.theundertaker11.kitchensink.ksblocks;

import java.util.Random;

import javax.annotation.Nullable;

import com.theundertaker11.kitchensink.tileentity.KSTileEntityHealingBlock;
import com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;

public class Quarryblock extends BlockBase {

public Quarryblock(String name) {
	super(name);
	this.isBlockContainer=true;
}

@Override
public boolean hasTileEntity(IBlockState state)
    {
        return true;
    }
@Override
public TileEntity createTileEntity(World world, IBlockState state)
    {
	return new KSTileEntityQuarryBlock();
    }

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
    {
	TileEntity tEntity = worldIn.getTileEntity(pos);

	if(!worldIn.isRemote&&tEntity!=null&&tEntity instanceof KSTileEntityQuarryBlock&&hand==EnumHand.MAIN_HAND)
	{
		KSTileEntityQuarryBlock quarry  = (KSTileEntityQuarryBlock)tEntity;
		if(heldItem!=null)
		{
			if(heldItem.getItem()==Items.COAL||Block.getBlockFromItem(heldItem.getItem())==Blocks.COAL_BLOCK)
			{
			int num = heldItem.stackSize;
			int energyMultiple = 0;
			if(heldItem.getItem()==Items.COAL)
			{
				energyMultiple = 8;
			}
			if(heldItem.getItem() instanceof ItemBlock&&Block.getBlockFromItem(heldItem.getItem())==Blocks.COAL_BLOCK)
			{
				energyMultiple = 72;
			}
			quarry.addEnergy(num*energyMultiple);
			playerIn.addChatMessage(new TextComponentString("Added "+(num*energyMultiple)+" SE"));
			heldItem.stackSize -= num;
			quarry.markDirty();
			}
		}
		else
		{
			if(quarry.getEnergy()==0)
			{
				int diam = ((KSTileEntityQuarryBlock.radius*2)+1);
				playerIn.addChatMessage(new TextComponentString("Right click with coal/charcoal or pipe items in to charge it(Blocks also work), be warned, it will use the whole stack you are holding."));
				playerIn.addChatMessage(new TextComponentString("The Quarry will mine a square with a diameter of "+diam+" with the quarry at the center."));
			}
		}
		if(quarry.getBlocksToMine()==0)
		{
			quarry.setTotalBlocksToMine();
		}
		playerIn.addChatMessage(new TextComponentString("Charge is "+quarry.getEnergy()+" SE"));
		playerIn.addChatMessage(new TextComponentString("There is "+quarry.getBlocksToMine()+" blocks left to mine."));
	}

        return true;
    }

@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
    {

	TileEntity tEntity = worldIn.getTileEntity(pos);
	if (!worldIn.isRemote&&tEntity!=null&&tEntity instanceof KSTileEntityQuarryBlock)
        {
		KSTileEntityQuarryBlock quarry  = (KSTileEntityQuarryBlock)tEntity;
            if (worldIn.isBlockPowered(pos))
            {
            	quarry.setIsOff(true);
            }
            else{
            	if (!worldIn.isBlockPowered(quarry.getPos()))
                {
                    quarry.setIsOff(false);
                }
            }
        }
    }
}

 

Any idea why nothing is being saved?

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

Yes it is calling both read and write to NBT. I put the print statement after the super() lines on both, shown below.

 

@Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
        super.writeToNBT(compound);
        System.out.println("Written to NBT");
        compound.setTag("items", itemStackHandler.serializeNBT());
        //compound.setBoolean("replaceBlocks", this.replaceBlocks);
        compound.setInteger("Energy", this.Energy);
        compound.setInteger("blocksToMine", this.blocksToMine);
        compound.setInteger("x", this.x);
        compound.setInteger("y", this.y);
        compound.setInteger("z", this.z);
        compound.setBoolean("quarryFinished", this.quarryFinished);
        return compound;
        
    }
@Override
public void readFromNBT(NBTTagCompound compound)
{
	super.readFromNBT(compound);
	System.out.println("It tried to read from NBT");
	if (compound.hasKey("items")) {
            itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("items"));
        }
	//this.replaceBlocks = compound.getBoolean("replaceBlocks");
	this.Energy = compound.getInteger("Energy");
	this.blocksToMine = compound.getInteger("blocksToMine");
	this.x = compound.getInteger("x");
	this.y = compound.getInteger("y");
	this.z = compound.getInteger("z");
	this.quarryFinished = compound.getBoolean("quarryFinished");
}

 

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

I thought the block code I put explained that well enough, but I'll type out the two reasons.(The second not being in the block code)

Reason 1: When I right click the block after loading back the world, it told me there was 0 energy and it had reset the number that told the amount of blocks it needed to mine.

Reason 2: If the quarry had mined some blocks before I saved and exited, after loading back in the world and giving the quarry more energy(Since it reset to 0), it will start back at the first block, meaning the X, Y, and Z int's are not saving.

 

I could do screen prints but I really see no point given the information I have already.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

So question:

The values that got reset.  Were those client side values or server side?

 

Have you tried printing out the results of the readFromNBT?  That is:

System.out.println("It tried to read from NBT");
System.out.println("NBT Energy: "+ compound.getInteger("Energy"));

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well since you point that out now its weird. So when I put a printscreen here

@Override
public void readFromNBT(NBTTagCompound compound)
{
	super.readFromNBT(compound);
	System.out.println("NBT Energy: "+ compound.getInteger("Energy"));
	if (compound.hasKey("items")) {
            itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("items"));
        }
	//this.replaceBlocks = compound.getBoolean("replaceBlocks");
	this.Energy = compound.getInteger("Energy");
	this.x = compound.getInteger("x");
	this.y = compound.getInteger("y");
	this.z = compound.getInteger("z");
	System.out.println("Class Energy: "+ this.Energy);
}

Both come out with the number that should of been saved. But when I put a print screen here

public int getEnergy()
{
	System.out.println("Tile Entity Energy: "+ this.Energy);
	return this.Energy;
}

It comes out as 0.

Spoiler below has the console logs of what was printed for each

 

 

Part from the read NBT prints

[14:35:26] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:readFromNBT:221]: NBT Energy: 60
[14:35:26] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:readFromNBT:222]: NBT x: -1891
[14:35:26] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:readFromNBT:231]: Class Energy: 60
[14:35:26] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:readFromNBT:232]: Class x: -1891

 

Part from the getEnergy() print

[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0
[14:36:31] [Client thread/INFO]: [CHAT] Right click with coal/charcoal or pipe items in to charge it(Blocks also work), be warned, it will use the whole stack you are holding.
[14:36:31] [Client thread/INFO]: [CHAT] The Quarry will mine a square with a diameter of 17 with the quarry at the center.
[14:36:31] [Client thread/INFO]: [CHAT] Charge is 0 SE

 

And the weirdest part of all... What gets called during my write to NBT

[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:208]: Class Energy before actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:209]: Class x before actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:210]: Written to NBT
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:217]: NBT Energy after actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:218]: NBT x after actually writing: 0

 

 

So the weirdest part is the write to NBT says everything comes out as 0, yet EVERY time I load the world, the read from NBT values stay at the 60 and -1891.

NOTE: I haven't tried to add more energy since the initial 60 that it was, since I feel that would confuse things. But I can tell you from past trials it will set the energy to however much I put in, and dig until it runs out of that new energy.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

Were those client side values or server side?

 

[14:35:26] [Server thread/INFO] [sTDOUT]: NBT Energy: 60

[14:36:31] [Client thread/INFO]: [CHAT] Charge is 0 SE

 

:|

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Did you not see all the other console logs I showed that it was 0 outside of the read from NBT part, even serverside? the code that outputs the chat message is called serverside, but I use playerIn.addChatMessage() to send the result to the player in chat, so not everyone in chat will see when a player right clicks the block.

[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0
[14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0

 

[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:208]: Class Energy before actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:209]: Class x before actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:210]: Written to NBT
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:217]: NBT Energy after actually writing: 0
[14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:218]: NBT x after actually writing: 0

 

All that is serverside, the few clientside ones in there just either say text or reflect what the serverside variable is.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

I THINK I JUST FIGURED OUT SOMETHING HUGE

Okay so I talked with another programmer about this and he said that it might be making 2 instances of the tile entity.

 

To test this, I put something that printed out the current energy every 5 seconds in the update() method. What I found out was that nothing happened until I interacted with the block. After that it seemed to make a new tile entity(Or something) and finally the current energy was printing every 5 seconds.

So I had to go further before I made this post. I commented out all my onBlockActivated code and made the return to false again. On right clicking the block it made it start printing energy still. Then I left and came back and tried just placing a block next to it, and again that made it start printing the energy.

 

My only conclusion is that it's not even making a tile entity until the block itself updates, and by then it doesn't even care about what the NBT data was the time before.

I hope that helps, I'm going to keep fiddling around and changing things to try and get more info.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

That makes no sense.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I FOUND OUT THE PROBLEM OH MY GOD I AM SO HAPPY.

So I decided to look through all of the TileEntity class out of desperation, and I came upon that actual readFromNBT method.

LITTLE DID I ****ING KNOW, they use x, y, and z int's saved to the NBT to get the location of the tile entity and do stuff with it... The more you know right?

 

Lesson learned, kids, never use x, y, or z as NBT int keys or else it will screw up everything.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

Lesson learned, kids, never use x, y, or z as NBT int keys or else it will screw up everything.

 

Better idea: prefix all your NBT keys with your mod ID

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Announcements



×
×
  • Create New...

Important Information

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