Jump to content

IExtendedEntityProperties not saving after death


starwarsmace

Recommended Posts

So to find out my bug I went to Tinkers Construct source code to figure it out. What I found out was that they use the player event LivingDeathEvent where he stored the properties and he used PlayerRespawn where he used a method which he called copys the old data to the new data.

Links to the source:

 

The EventHandler: https://github.com/SlimeKnights/TinkersConstruct/blob/bd498aacb5dac71bb2658ee761a9534c24b13b04/src/main/java/tconstruct/armor/player/TPlayerHandler.java

 

Extended Player Class:

https://github.com/SlimeKnights/TinkersConstruct/blob/d0894550633f5565dbc0cf14f78a7ae6bd57c2a7/src/main/java/tconstruct/armor/player/TPlayerStats.java

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Your repo is still broken. The build.gradle is missing and the gradle wrapper as well (instead you have the .gradle folder, which should not be in there).

What TC is doing there is a workaround for the times before we had the player clone event. it is not needed anymore.

Now I fixed it!(hopefully).

 

Secondly, I realized something. In the proof I showed you here:

 

4.And I put a println statement in onLivingUpdateEvent and it reset to 0 after I respawned or reloged.

@SubscribeEvent
public void onLivingUpdateEvent(LivingUpdateEvent event){
	if(event.entity!=null && event.entity instanceof EntityPlayer){

		ExtendedPlayer player = ExtendedPlayer.get((EntityPlayer) event.entity);
		System.out.println("Gold: "+player.getResources(1));
	}
}

 

I didn't actually call the NBT load method I called my own method. Im going to go and try out my load NBT function and see if you are right about that.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Ok, your issue is that you call EntityGoldMine#collect on the client. You need to do any data-changing things only on the server. So in this case you will need a packet.

 

Edit: Oh, and your repo is still broken btw. The gradle wrapper is not complete.

ARGGGGG!!! When will my repo ever be no broken.smiley.gif

 

I guess that makes sense. But then why does it still show up on my gui.

 

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Ok, your issue is that you call EntityGoldMine#collect on the client. You need to do any data-changing things only on the server. So in this case you will need a packet.

 

Edit: Oh, and your repo is still broken btw. The gradle wrapper is not complete.

 

I already have made a packet network but then I came across your tutorial in order to learn how to send messages. You said in that tutorial, "This is the recommended way to do Packets in 1.7, it is not advised to use Netty directly, because it can cause Problems."

 

But since I had been using Cool Alias's tutorial to make a gui for the players data he had directed me to the tutorial for packets which you said not to got to. So I made that.

After I finished with that Cool Alias told us to add this for our packeting.

 

private NBTTagCompound data;
public SyncPlayerPropsPacket() {}
public SyncPlayerPropsPacket(EntityPlayer player) {
	data = new NBTTagCompound();
	// and save our player's data into it
	ExtendedPlayer.get(player).saveNBTData(data);
}
@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
	ByteBufUtils.writeTag(buffer, data);
}

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
	data = ByteBufUtils.readTag(buffer);
}

@Override
public void handleClientSide(EntityPlayer player) {
	if(data!=null){
		ExtendedPlayer.get(player).loadNBTData(data);

	}
}

@Override
public void handleServerSide(EntityPlayer player) {

}

 

My question is will this be still usable with the way you do it in your tutorial. I think so but Im just validiating before I move my code to your way.

 

Thank you in advance.

 

Also, now I understand what you mean about the client and the gui.

 

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

I never got around to updating the actual tutorial code due to the crappy editor on MinecraftForums, but I have commented on it several times and linked to updated tutorials, as well as showing full implementations on Github that use the SimpleNetworkWrapper. It's not that difficult to update if you were using the old Packet Pipeline code.

Link to comment
Share on other sites

I never got around to updating the actual tutorial code due to the crappy editor on MinecraftForums, but I have commented on it several times and linked to updated tutorials, as well as showing full implementations on Github that use the SimpleNetworkWrapper. It's not that difficult to update if you were using the old Packet Pipeline code.

Sorry. I hadn't looked at the comments you put after the original post.

So, I went and looked at your github. All of the code was well documented and understandable. So thanks for that tutorial. Heres the link for everyone who hasn't used CoolAlias's awesome tutorials:  https://github.com/coolAlias/Tutorial-1.7.10

 

Once Im done adding in the new network Ill test it out and tell everyone the results.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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.