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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, my name is Gatis. Mostly all I do is play minecraft on Hypixel server. I play Skyblock where almost every player has installed QOL mods. They are nice and work nice but recently the grind I'm on requires not wasting time on boosts and if I'm watching something I usually miss it. Let me explain better. So there is "Mining speed boost" when it's ready message appears in chat. Mod I've been using allows to copy chat message, paste it in mod and next time same message appears it flashes big notification message on screen that speed boost is ready. The thing is somehow I still miss the notification. SO, I want to create mod that can detect that message and make more noticable notification (ex. bigger) or even stop me from moving for 10 sec if I don't use it instantly. I have no knowledge about java I have prepared intellij with forge on 1.8.9 I'm just left with this:                 package com.example.examplemod;                  import net.minecraft.init.Blocks;                import net.minecraftforge.fml.common.Mod;                import net.minecraftforge.fml.common.Mod.EventHandler;                import net.minecraftforge.fml.common.event.FMLInitializationEvent;                 @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)               public class GatisMOD              {                           public static final String MODID = "GatisMOD"; \                           public static final String VERSION = "1.0";                            @EventHandler                          public void init(FMLInitializationEvent event)                          {                                      // some example code                                      System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());                          } }     I've watched many video, mostly they show how to setup everything but how to create, prepare file and later (export I guess) export to import in mods folder to use they don't I'd appreciate any help, maybe someone would explain some things to me. In future I have plans to make other feature but I guess not for now.
    • I don't think embeddium and rubidium can be used together. Try removing one of them.
    • I have been attempting to troubleshoot my personal modpack created on Curseforge for 1.18.2 Forge but I keep getting the Exit Code: 1 crash upon launching the game. When I open the debug.log I find the error for "Duplicate mods found" which simply isn't the case as there isn't a single mod with the same name. Most files are for the correct version as far as I can tell so I think there may be mods that are conflicting and the game is confusing them as "Duplicates". (Or I simply didn't check the versions correctly. Debug.log file paste: https://paste.ee/p/pQwZo#s=0 I don't normally frequent forums and don't normally ask for help online but guidance would be greatly appreciated. I can provide any other info needed  
  • Topics

×
×
  • Create New...

Important Information

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