Posted April 13, 201510 yr Hello, so my problem is this: Entity properties registered twice, initialized twice, but loaded (readFromNbt) only once, what results in nulliffing of data; This happens like this (Checked via console); -register (EntityConstruct) -init (Propery.init) -load (Propery.readFromNbt) -register -init All the code that you may want here is EntityConstructEvent, but if you need something else - just ask: public class OnEntityConstructEvent { public OnEntityConstructEvent() { } @SubscribeEvent public void construct(EntityConstructing event){ if(event.entity instanceof EntityPlayer){ if(event.entity.getExtendedProperties("breathing") == null){ System.out.println("Registered new propreties on " + FMLCommonHandler.instance().getSide() + " old propreties: " + event.entity.getExtendedProperties("breathing")); event.entity.registerExtendedProperties("breathing", new ExtendedBreathingProperties()); } } } } Thanks for help, and again: if you need something(code/console/...) - just ask! Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 13, 201510 yr The code looks good. It literally can't be source of any problems. What happens: Server creates entity, registers IEEP, loads NBT. Then client creates same entity, registers IEEP, but never loads (NBT is server-sided). Someone here is confused - question is - is it me or you? 1.7.10 is no longer supported by forge, you are on your own.
April 13, 201510 yr Author I understand that first one is server and second one is client, but why then data is nullified on both sides after client loading??? Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 13, 201510 yr Please describle nullified. Without using packets on client side you will end up with fresh IEEP object. On server it will be the same, unless you load something from NBT - what are you loading, why do you say it's nullified? Do you mean that WHOLE IEEP object just disappears (because that's what nullified means for me)? Post readNBT maybe. 1.7.10 is no longer supported by forge, you are on your own.
April 13, 201510 yr Author Please describle nullified. Without using packets on client side you will end up with fresh IEEP object. On server it will be the same, unless you load something from NBT - what are you loading, why do you say it's nullified? Do you mean that WHOLE IEEP object just disappears (because that's what nullified means for me)? Post readNBT maybe. I mean all lists become empty, booleans defaults to false and ints to 0. This includes both slient&server!!! (why???) IEEP: public class ExtendedBreathingProperties implements IExtendedEntityProperties{ private boolean breathing; private Set<BreathEffect> effects = new HashSet<BreathEffect>(); public ExtendedBreathingProperties() { setBreathing(false); } public boolean isBreathing() { return breathing; } public void setBreathing(boolean breathing) { this.breathing = breathing; } public void addEffect(BreathEffect effect){ effects.add(effect); } public void removeEffect(BreathEffect effect){ effects.remove(effects); } public Set<BreathEffect> getEffects(){ return effects; } @Override public void saveNBTData(NBTTagCompound nbt) { NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound es = new NBTTagCompound(); int a = 0; for(BreathEffect effect : effects){ es.setTag("eN" + a, effect.writeToNBT(new NBTTagCompound())); a++; } es.setInteger("lenght", a); tag.setTag("effects", es); tag.setBoolean("breathing", breathing); nbt.setTag("breathing", tag); BreathEffectManager.logger.info("Saving propreties data to nbt: " + tag + " on " + FMLCommonHandler.instance().getSide()); } @Override public void loadNBTData(NBTTagCompound nbt) { NBTTagCompound tag = nbt.getCompoundTag("breathing"); NBTTagCompound es = tag.getCompoundTag("effects"); BreathEffectManager.logger.info("Loading propreties data from nbt: " + tag + " on " + FMLCommonHandler.instance().getSide()); for(int a = 0; a < nbt.getInteger("lenght"); a++){ try { effects.add(BreathEffect.createFromNBT(es.getCompoundTag("eN" + a))); } catch (Exception e) { BreathEffectManager.logger.warn("Caught exception while restoring effect: ", e); } } breathing = tag.getBoolean("breathing"); } @Override public void init(Entity entity, World world) { BreathEffectManager.logger.info("Initializing proprieties on " + FMLCommonHandler.instance().getSide()); } } Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 13, 201510 yr for(int a = 0; a < nbt.getInteger("lenght"); a++){ Doing this will leave you with either 0 or null therefore list will be empty/readNBT will crash (catch error). I don't remember what getInteger returns for not-found keys. You made simple typo mistake Edit: If you didn't get me - "nbt" should be "es". Edit 2: I highly recommend using TagList, which has build-in lenght. You can do effect.writeToNBT directly onlo tag in list. 1.7.10 is no longer supported by forge, you are on your own.
April 13, 201510 yr Author Facepalm... typo mistake... And i was not using list, beacause i'm a litle bit confused how to use it... Well i'll try how ever... EDIT: well, i'm still confused about them... EDIT 2: it was typo mistake... again... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 13, 201510 yr ("lenght") Never seen that word before. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
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.