
AppliedOnce
Members-
Posts
104 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
Modder
AppliedOnce's Achievements

Creeper Killer (4/8)
2
Reputation
-
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
You never add any data to the NBTTagCompound, which you don't even need since you can write the int and String directly to the output stream, and read them back in. You don't need getter and setter methods because you will never be (should never be) trying to access your variables outside of this class. Thank you, I forgot I could use the NBTTagCompound to store the values (I am very stupid sometimes). Everything works as it should now, I really appreciate your help. -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
For some reason this is giving me null and 0 all the time. I even tried using lists but that doesn't work either. package com.xetosphere.pantheon.network.packet; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import com.xetosphere.pantheon.entity.ExtendedPlayer; import com.xetosphere.pantheon.network.AbstractPacket; import cpw.mods.fml.common.network.ByteBufUtils; public class UpdateReligionPacket extends AbstractPacket { private NBTTagCompound data; private String religion; private int religionId; public UpdateReligionPacket() { } public UpdateReligionPacket(String religion, int religionId) { data = new NBTTagCompound(); setReligion(religion); setReligionId(religionId); } public void setReligion(String religion) { this.religion = religion; } public void setReligionId(int religionId) { this.religionId = religionId; } public String getReligion() { return religion; } public int getReligionId() { return religionId; } @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) { } @Override public void handleServerSide(EntityPlayer player) { System.out.println(getReligion() + ", " + getReligionId()); ExtendedPlayer.get(player).setPantheon(getReligion()); ExtendedPlayer.get(player).setPantheonId(getReligionId()); if (!player.worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("You set your pantheon to: " + ExtendedPlayer.get(player).getPantheon())); System.out.println("[XETOPC] Pantheon = " + ExtendedPlayer.get(player).getPantheon()); System.out.println("[XETOPC] PantheonId = " + ExtendedPlayer.get(player).getPantheonId()); } } -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
Ok, it seems I can't work this out by myself even after the information you gave me (server/client stuff really confuses me and this is my first time handling nbttag stuff). My current bugs is, when I open a world after quiting the game, it prints out correct information in the console (I made it so that when I use the method loadNBTData in the ExtendedPlayer.class it will print the religion and culture) but when I look inside my gui everything is reset back to the standard values. Though when I open a different world without leaving the game, it still has the information from the earlier world. So I ask how I can make it save for only the world he is currently in, and that it will save and load correctly even after I restart the game. Here is my current code: Mod class: GuiReligion.class: ItemTalisman.class: ExtendedPlayer.class: CultureEventHandler.class: SyncPlayerPropsPacket.class: CommonProxy.class: AbstractPacket.class: ClientProxy.class: -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
So let me see if I got you right, you mean that I create a new packet that instead of sending from server side sends info from server to client instead? And that this new packet should be sent whenever one of the buttons are pressed? If that is correct do you know of any tutorial on sending data from server to client or the other way around? I wanna learn the new netty system in and out, so that I can use this for future projects and problems as well. -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
Is there no one who can help me with my problem? -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
No, what I meant to say is that when I have it as "!=" it crashes when I open the world. I get a nullpointer exception when using "!=". Crashlog: My real problems (I think) is that my values never really gets synced (client -> server or server -> client). This also make it so that when I open a new world, the gui says that I have the religion from the previous world (even if I create a new one) as well as when I close down minecraft and open it again it is reset to "None" instead of the religion name (where "None" is my default value in the ExtendedPlayer class). -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
No, I am pretty sure what that code does is, if the player haven't been registered yet then register it. Other than that thank you for replying and helping me out. (btw if I use != it just crashes when the player joins the world) -
[1.7.2] - Sending data from a gui to the server [Solved]
AppliedOnce replied to AppliedOnce's topic in Modder Support
Anyone knows what I am doing wrong here? -
Hi, I'm currently working on a project and got into a small problem. I try to change a value that is saved in the player using the ExtendedEntityProperties stuff, inside a gui. The only I am having is that the way I am doing it, I only change the values on the client side which makes a lot of problems. So I was wondering how I can fix this problem, is there something missing in my packet or something or do I need a new one? Here is all the classes I am using for it: Mod class: ItemTalisman class: GuiReligion class: PacketPipeline class: SyncPlayerPropsPacket class: CultureEventHandler class: CommonProxy class: ExtendedPlayer class: