Jump to content

Recommended Posts

Posted

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?

Posted

	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

Posted

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

Posted

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

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

    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
    • https://paste.ee/p/h1JX9bbl
    • Add the latest.log from your logs-folder
  • Topics

×
×
  • Create New...

Important Information

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