Jump to content

1.7.10 - Extended TileEntity Properties ?


Blackout

Recommended Posts

Hi,

 

I want to know if an "Extended Entity Properties"-like system exists for TileEntities.

I don't find it :/

Or if I must implement myself this functionnality.

 

If I must implement it, do you know which events are fired when a TileEntity is created and when it's removed ?

Is all TileEntities are loaded when the world load or are there chunk-loaded ?

 

I don't use custom block, I want extend an existing TileEntity.

 

Thanks a lot :)

Link to comment
Share on other sites

You can set whatever properties you wish - as fields - in a TileEntity.

 

However, do you want to change the functionality of an existing block?

 

If so, that'll require making a coremod, which can be a daunting task if you don't have a lot of experience with Java, programming in general, and at least a decent understanding of how Forge works.

Link to comment
Share on other sites

I'm fairly certain that tile entities are subclassing an Entity class of some sort aren't they?

 

If so, what is stopping one from adding an IExtendedEntityProperties?

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

To post above:

If by "subclassing" you mean extending - then no.

Entity is a object that "lives" in world - it can move, item, mob, arrow, whatever (has to be loaded manually).

TileEntity is more of a "dead" object, like static furnace or something (they are loading a chunk on their own).

 

Overall:

Both are using other methods to save data - look into net.minecarft.tileentity.TileEntity.class and net.minecarft.entity.Entity.class,

tell us what exacly you want to save and why are you not simply using NBT rather than IExtendedEntityProperties? TE NBT is perfectly good way to save data.

 

 

 

Edit: Sorry m8, I kinda was reading few threads simultaneously and kinda took your previous post as a OP's post - oh WTH, just messed up my mind - my main point was that Entity != TileEntity and NBT can be used in both without IEEP.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

* sighs *

 

If one is to interpret the question how you have, they must be pretty one sided.

 

 

I assume that the OP is asking to add extra data to a tile entity. And I have no clue who you are ripping into about being insistent on using IExtendedEntityProperties. Seeing as I am the only one who mentioned it, I assume that was aimed at me.

 

 

Please retake your 6th grade English class. It will serve you well.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Link to comment
Share on other sites

You can't use IExtendedEntityProperties with a tile entity.  Its a wierd choice of names on minecrafts part, but it isn't doesn't extend entity and the methods are not there.

 

I can think of a few ways to add data to a TileEntity. It has NBT data and you could add to it depending what you are wanting to do.

 

That brings up the question.  What are you trying to do?

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Hi,

In fact, I have an AI wich must for example eat to survive.

This AI is a passive entity, ally with players.

 

Player can decide wich chest he wants share with the AI.

And when AI is hungry, it take food in one of the player shared chest.

 

So I need to know if a chest is shared or not in addition of it contents.

Chest will have more option in the future, for example a filter system to know what kind of block AI can store.

And I need to know the chest shared list, in order to my AI can easily get the coordinate to the chest.

 

Currently I use a Map<World, BiMap<TileEntity, ExtendedTileEntity (Class created by myself)>> named SHARED_CHESTS.

It's work fine but I don't save it on disk. So all is reset everytime.

 

I thought use these events to have persistant data :

@SubscribeEvent
public void onLoad(WorldEvent.Load event) {
	if(!event.world.isRemote) {

		BiMap<TileEntity,ExtendedTileEntity> worldSharedChests = HashBiMap.create();

		//Load tileEntities ...

		synchronized (SHARED_CHESTS) {
			SHARED_CHESTS.put(event.world, worldSharedChests);
		}
	}
}

@SubscribeEvent
public void onUnload(WorldEvent.Unload event) {
	if(!event.world.isRemote) {
		synchronized (SHARED_CHESTS) {
			SHARED_CHESTS.remove(event.world);
		}
	}
}

@SubscribeEvent
public void onSave(WorldEvent.Save event) {
	if(!event.world.isRemote) {
		synchronized (SHARED_CHESTS) {
			BiMap<TileEntity, ExtendedTileEntity> worldSharedChests = SHARED_CHESTS.get(event.world);
			if(worldSharedChests == null) return;
			//Save on disk ...
		}
	}
}

 

But I don't think all TileEntity is loaded when a world in loading.

So I probably couldn't refer it to my ExtendedTileEntity

Link to comment
Share on other sites

The suggestion to store the chest in the AI entity is probably the best.  There other ways to do this, but that is going to be the most straightforward.

 

When you 'share' a chest, put the particular chest location into the entity.  Modify its read/write NBT statements to load those varialbes.  Then you should be set.

 

Of course, you are going to have an interesting time if the chest is in an unloaded chunk and your AI is in a loaded chunk, but that might be rare. 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

The problem is how to save/load it from disk.

In fact, my mod will be a Millenaire-like mod (So I don't have only one entity :/ ) but with a different gameplay and without dependencies from Minecraft chunck loading system.

For instance, I want live continues more than 512 blocks far the player.

 

I doubt about what system I can use, is NBT more performant than JSON ?

 

If I use NBT, how to serialize it into a custom file ?

 

Is chunk need to be loaded to use world.getTileEntity(x,y,z) or world.getBlock ?

Link to comment
Share on other sites

I have already done a Map like this.

It's only on server-side, I use packet to edit and get value from my map :)

 

I will use ChunkEvent :)

 

But I need to know how to save NBT on a custom file. I don't want save it in world files or player files.

All tutorial I find about NBT is about how to create a custom TileEntity :/

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.