Posted October 16, 201410 yr Hiya! I am trying to work out some tileentity stuff and when I place down the thing and tile entity is created, it goes for both server and client, but when I save and quit and return, only the client one is loaded public void updateEntity(){ if (!this.worldObj.isRemote){ System.out.println("Isn't remote"); }else{ System.out.println("Is remote"); } timetick--; if (timetick==0){ this.exWorld = ExtendedWorld.create(this.worldObj); if (stem != null){ this.exWorld.setBlock(this.stem, this.log); this.stem.updateNorm(); } this.timetick = RandomFunctions.Int(40, 300); } } The only message I get is "Is remote" while the "Isn't remote" never pops up after I saved and quit, what could cause this?
October 16, 201410 yr Author citrusStump = new NatureStump() .setLog(citrusLog) .setLeaf(citrusLeaves); GameRegistry.registerBlock(citrusStump,"citrus stump"); LanguageRegistry.addName(citrusStump, "Citrus stump"); GameRegistry.registerTileEntity(TileEntityTreeBase.class,"TreeStump"); this is the part htat registers it (Yet I am working on custom made trees), it registers without issues when I start up, the tile entity si created upon creation of the block but when reloaded. it's gooooneeee
October 16, 201410 yr Are you have readFromNBT and writeToNBT functions in your TileEntity? If yes, are you calling super.readFromNBT and super.writeToNBT?
October 16, 201410 yr Author Yes, here is the entire code for it. package aerosteam.tileentity.trees; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import aerosteam.blocks.nature.NatureStump; import aerosteam.functions.ExtendedWorld; import aerosteam.functions.IntPoint; import aerosteam.functions.IntVec; import aerosteam.functions.OmniDirection; import aerosteam.functions.RandomFunctions; public class TileEntityTreeBase extends TileEntity{ int Width; int height; public IntPoint[] branch = new IntPoint[20]; public IntPoint[] roots = new IntPoint[20]; int nrRoots = 0; int nrBranches = 0; public IntPoint stem; ExtendedWorld exWorld; public Block log; public Block leaf; public int leafSize=1; int timetick = RandomFunctions.Int(40, 300); public void updateEntity(){ if (!this.worldObj.isRemote){ //System.out.println("Isn't remote"); timetick--; if (timetick==0){ this.exWorld = ExtendedWorld.create(this.worldObj); if (stem != null){ growth(this.worldObj,this.stem); this.stem.updateNorm(); if (RandomFunctions.BoolInt(3, 5)){ nrBranches++; IntVec placement = IntVec.makeIntVec(OmniDirection.getLevel(RandomFunctions.Int(1, )); //this.worldObj.setBlock(this.xCoord+1, this.yCoord+3, this.zCoord+1, this.log); placement.sizeSelfTo(1); branch[nrBranches-1]=IntPoint.create(this.stem.pos.addVec(placement)); branch[nrBranches-1].setVel(placement.vecX, placement.vecY+1, placement.vecZ); } for(int i=0;i<nrBranches;i++){ growth(this.worldObj,this.branch[i]); this.branch[i].updateNorm(); } } this.timetick = RandomFunctions.Int(40, 300); } }else{ //System.out.println("Is remote"); } } public void growth(World world, IntPoint point){ removeLeaves(world,point); exWorld.setBlock(point, this.log); addLeaves(world,point); } public void addLeaves(World world, IntPoint point){ for (int i=-this.leafSize;i<=this.leafSize;i++){ for (int j=-this.leafSize;j<=this.leafSize;j++){ for (int k=-this.leafSize;k<=this.leafSize;k++){ int dist = i*i+j*j+k*k; if (dist <=this.leafSize*this.leafSize){ if (exWorld.isBlock(point.pos.vecX+i, point.pos.vecY+j, point.pos.vecZ+k, Blocks.air)){ world.setBlock(point.pos.vecX+i, point.pos.vecY+j, point.pos.vecZ+k,this.leaf); } } } } } } public void removeLeaves(World world, IntPoint point){ ExtendedWorld exWorld = ExtendedWorld.create(world); for (int i=-this.leafSize;i<=this.leafSize;i++){ for (int j=-this.leafSize;j<=this.leafSize;j++){ for (int k=-this.leafSize;k<=this.leafSize;k++){ if (exWorld.isBlock(point.pos.vecX+i, point.pos.vecY+j, point.pos.vecZ+k, this.leaf)){ world.setBlockToAir(point.pos.vecX+i, point.pos.vecY+j, point.pos.vecZ+k); } } } } } public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); //System.out.println("Read NBT"); ; //this.slots=new ItemStack[this.getSizeInventory()]; this.nrBranches = (int)nbt.getShort("NrBranches"); this.stem=IntPoint.loadIntPointFromNBT(nbt,"Stem"); for(int i=0; i<this.branch.length;i++){ this.branch[i]=IntPoint.loadIntPointFromNBT(nbt,"Branch-"+i); } if (this.log==null) this.log = ((NatureStump) this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord)).log; if (this.leaf==null)this.leaf = ((NatureStump) this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord)).leaf; } public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); //nbt.setShort("BurnTime",(short)this.burnTime); //nbt.setShort("CurrentItemBurnTime",(short)this.currentItemBurnTime); this.stem.writeToNBT(nbt, "Stem"); nbt.setShort("NrBranches",(short)this.nrBranches); for(int i=0; i<this.branch.length;i++){ if(this.branch[i] != null){ this.branch[i].writeToNBT(nbt, "Branch-" + i); }else{ break; } } } }
October 16, 201410 yr Hi So just to be clear: 1) when you place it, you get "is Remote" 2) after you save and quit and reload, you get no console messages at all. 3) you never get any "isn't Remote" at all Is that right? -TGG
October 17, 201410 yr Author When I place it I get "Is remote" and "Isn't remote", both of them, when I save and quit there are no messages, then when I reload it's only "is remote" that shows, no "isn't remote"
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.