Jump to content

Recommended Posts

Posted

Hi, I'm french so sorry for my English I'll do my best, I'v done some ExtendedEntityProperties but they aren't saved when I die or leave the game. My event work 'cause I've put some System.out in different parts and it worked. There is my code:

http://pastebin.com/LaGZ5sbb http://pastebin.com/2HLcpyQ7 http://pastebin.com/tsWihcuM Ask me if you want more class. I hope you will help me! :) PS: I've already done a post on the french forum: http://www.minecraftforgefrance.fr/showthread.php?tid=2023

I'm a Potterhead.

Posted

I don't quite have time to look super-deep in your code, but for one I can tell - you are either doing very oldschool stuff, or simply learned from old tutorial.

 

Going through all you got:

- your IEEP is cool, your nbtLoad and wirte are cool.

- remove your whole joined world, and whatever else stuff (like your storage-proxy) - this is the old school I've been talking about.

 

Now what you're gonna do:

Use:

@SubscribeEvent
public void playerClone(PlayerEvent.Clone event)
{
IEEP epNew = IEEP.get(event.entityPlayer);
IEEP epOld = IEEP.get(event.original);
//copy your data
}

Above will copy IEEP data from old dead entity to new one constructed after death.

 

This is all you need, you should NEVER EVER have to call neither load or save methods in your IEEP, just make sure they work, and leave them.

 

Note: In Clone event - don't write and read, you can transfer data directly like intFromNew = intFromOld (just saying because many do that).

 

EDIT:

To just ensure you write your stuff well - you can paste it here when you're done or have problems.

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

Posted

Thanks for your help, so I delete all my old stuff (events, stuffs in the Common Proxy ect) and i just put your code? Eclipse doesn't find the event PlayerEvent.Clone :/ May I change in PlayerEvent.PlayerRespawnEvent?

I'm a Potterhead.

Posted

net.minecraftforge.event.entity.player.PlayerEvent.Clone

 

You sure? It might have been added in 1.8. If it is the reason, there is still better workaround than what you are doing now. Just check if you didn't import FML events (there are two PlayerEvent.class)

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

Posted

Oh yeah thanks, bad PlayerEvent.class, I've done that, it's working but not when I disconnect/reconnect :/

@SubscribeEvent

  public void playerClone(PlayerEvent.Clone event)

  {

      ExtendedEntityProps epNew = ExtendedEntityProps.get(event.entityPlayer);

      ExtendedEntityProps epOld = ExtendedEntityProps.get(event.original);

      epNew.mana = epOld.mana;

      epNew.maxMana = epOld.maxMana;

      epNew.spellLeft = epOld.spellLeft;

      epNew.spellRight = epOld.spellRight;

      epNew.spellsList = epOld.spellsList;

  }

I'm a Potterhead.

Posted

Post new code. You can try making prints in write/read methods (print whole NBT).

 

 

EDIT NOTE

For future - I've noticed you are doing side-checking in events that are only server-sided (e.g LoggedOut). Remember that not all events are sided. One more important thing is some events (tick mostly) have Phases, have that in mind.

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

Posted

Well my code is the same as the code at the top, but I'd to put the PlayerEvent.Clone on an other class because I need both imports. The other class:

[embed=425,349]package fr.sosoh.hogsmod.common.event;

 

import net.minecraftforge.event.entity.player.PlayerEvent;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps;

 

public class EventHandlerMain {

 

  @SubscribeEvent

  public void playerClone(PlayerEvent.Clone event)

  {

      ExtendedEntityProps epNew = ExtendedEntityProps.get(event.entityPlayer);

      ExtendedEntityProps epOld = ExtendedEntityProps.get(event.original);

     

      epNew.maxMana = epOld.maxMana;

      epNew.spellLeft = epOld.spellLeft;

      epNew.spellRight = epOld.spellRight;

      epNew.spellsList = epOld.spellsList;

  }

   

}[/embed] And I've already put some system.out and it appeares that my saveNBTData is used when nothing happend:

 

[01:07:15] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:07:15] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:08:00] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:08:00] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:08:45] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:08:45] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:09:30] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

[01:09:30] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: saveNBT

 

 

Maybe I can send you my source folder ?

I'm a Potterhead.

Posted

When someone can't find the problem, the problem is most likely elsewhere. Post everything related to your IEEP in pastebin or <code>.

 

Nbt saving is almost "random", it happens when you stop game, every some time (in ticks) and few other ocasions (loggionOut).

 

EDIT

(print whole NBT).

Literally, you can print NBTTag, see what you get.

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

Posted

There is what I've got:

[14:14:38] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: save{spellRight:"",Mana:0.0d,spellLeft:"",Spells:[0:"Accio",1:"Repulso",2:"Protego",],MaxMana:1000.0d,}

[14:14:38] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: save{spellRight:"",Mana:0.0d,spellLeft:"",Spells:[0:"Accio",1:"Repulso",2:"Protego",],MaxMana:1000.0d,}

[14:14:38] [server thread/INFO]: Saving worlds

[14:14:38] [server thread/INFO]: Saving chunks for level 'Nouveau monde'/Overworld

[14:14:38] [server thread/INFO]: Saving chunks for level 'Nouveau monde'/Nether

[14:14:38] [server thread/INFO]: Saving chunks for level 'Nouveau monde'/The End

[14:14:38] [server thread/INFO] [FML]: Unloading dimension 0

[14:14:38] [server thread/INFO] [FML]: Unloading dimension -1

[14:14:38] [server thread/INFO] [FML]: Unloading dimension 1

[14:14:38] [server thread/INFO] [FML]: Applying holder lookups

[14:14:38] [server thread/INFO] [FML]: Holder lookups applied

[14:15:08] [server thread/INFO]: Starting integrated minecraft server version 1.7.10

[14:15:08] [server thread/INFO]: Generating keypair

[14:15:08] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance

[14:15:08] [server thread/INFO] [FML]: Applying holder lookups

[14:15:08] [server thread/INFO] [FML]: Holder lookups applied

[14:15:08] [server thread/INFO] [FML]: Loading dimension 0 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@4a85f46d)

[14:15:08] [server thread/INFO] [FML]: Loading dimension 1 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@4a85f46d)

[14:15:09] [server thread/INFO] [FML]: Loading dimension -1 (Nouveau monde) (net.minecraft.server.integrated.IntegratedServer@4a85f46d)

[14:15:09] [server thread/INFO]: Preparing start region for level 0

[14:15:10] [server thread/INFO]: Preparing spawn area: 96%

[14:15:10] [server thread/INFO]: Changing view distance to 8, from 10

[14:15:10] [Netty Client IO #1/INFO] [FML]: Server protocol version 1

[14:15:10] [Netty IO #3/INFO] [FML]: Client protocol version 1

[14:15:10] [Netty IO #3/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected]

[14:15:10] [Netty IO #3/INFO] [FML]: Attempting connection with missing mods [] at CLIENT

[14:15:10] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [] at SERVER

[14:15:10] [server thread/INFO] [FML]: [server thread] Server side modded connection established

[14:15:10] [Client thread/INFO] [FML]: [Client thread] Client side modded connection established

[14:15:11] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:loadNBTData:94]: load{spellRight:"",Mana:0.0d,spellLeft:"",Spells:[0:"Accio",1:"Repulso",2:"Protego",],MaxMana:1000.0d,}

[14:15:11] [server thread/INFO]: sosoh[local:E:7def91e3] logged in with entity id 190710 at (289.5, 4.0, 244.5)

[14:15:11] [server thread/INFO]: sosoh joined the game

[14:15:12] [server thread/INFO]: Saving and pausing game...

[14:15:12] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: save{spellRight:"",Mana:0.0d,spellLeft:"",Spells:[],MaxMana:1000.0d,}

[14:15:12] [server thread/INFO] [sTDOUT]: [fr.sosoh.hogsmod.common.entity.props.ExtendedEntityProps:saveNBTData:79]: save{spellRight:"",Mana:0.0d,spellLeft:"",Spells:[],MaxMana:1000.0d,}

I'm a Potterhead.

Posted

OH MY GOD. (note - previous shit I wrote was totally wrong):

 

NBTTagList list = compound.getTagList("Spells", Constants.NBT.TAG_STRING);

 

compound != properties

 

This is like 3rd same mistake I see this week. How could I miss it :P

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

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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