Jump to content

[Solved][1.7.10] Tile entity is not loaded on server


EmperorZelos

Recommended Posts

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?

Link to comment
Share on other sites

	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 :o

Link to comment
Share on other sites

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;	
		}
	}
}
}

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.

Announcements



×
×
  • Create New...

Important Information

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