Blackout Posted July 15, 2014 Posted July 15, 2014 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 Quote
Elyon Posted July 15, 2014 Posted July 15, 2014 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. Quote
Kwibble Posted July 15, 2014 Posted July 15, 2014 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? Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Ernio Posted July 15, 2014 Posted July 15, 2014 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. Quote 1.7.10 is no longer supported by forge, you are on your own.
Kwibble Posted July 15, 2014 Posted July 15, 2014 * 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. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
delpi Posted July 15, 2014 Posted July 15, 2014 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? Quote Long time Bukkit & Forge Programmer Happy to try and help
Blackout Posted July 15, 2014 Author Posted July 15, 2014 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 Quote
KeeperofMee Posted July 15, 2014 Posted July 15, 2014 Can't you just simply store the chests in the individual players maybe or in the entity which has to eat? Quote If I helped please press the Thank You button.
delpi Posted July 15, 2014 Posted July 15, 2014 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. Quote Long time Bukkit & Forge Programmer Happy to try and help
Blackout Posted July 15, 2014 Author Posted July 15, 2014 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 ? Quote
Elyon Posted July 15, 2014 Posted July 15, 2014 The chunk will be loaded on those two calls, yes. Quote
delpi Posted July 16, 2014 Posted July 16, 2014 Why don't you go look up a tutorial on NBT. It will answer all your questions and then you can do what I suggested. Quote Long time Bukkit & Forge Programmer Happy to try and help
Blackout Posted July 16, 2014 Author Posted July 16, 2014 I don't find any tutorial which explain how to save on a custom file NBT tags Quote
Blackout Posted July 16, 2014 Author Posted July 16, 2014 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 Quote
Recommended Posts
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.