Jump to content

Neuro

Members
  • Posts

    11
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Neuro's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Mind if I see your entire base mod class?
  2. I had a look through it. Never called outside of the packet.
  3. Thanks for the help again, however I have yet another minor issue. It seems to still be adding the items on the client as well, possibly more than it needs to. When I pick up an item, it will re-add the items to the inventory. For illustration: Slot 1: Has 6 items. Slot 2: Has 3 item. I take one item from slot 2 so it has 2 left. Now: Slot 1: Has 12 items. Slot 2: Has 4 items. However, the extra items are just fake duplicates which disappear once I grab 'em.
  4. In my GUI actionPerformed method: MusicboxCore.network.sendToServer(new MusicBoxMessage(this.tileEntity.xCoord,this.tileEntity.yCoord,this.tileEntity.zCoord, this.nameField.getText(), this.tileEntity.unsavedSong[0], this.tileEntity.unsavedSong[1], this.tileEntity.unsavedSong[2], this.tileEntity.unsavedSong[3])); Here is the packet to be sent: package neuro.musicbox.main; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; import neuro.musicbox.gui.TileEntityMusicDesk; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class MusicBoxMessage implements IMessage { int x, y, z; public String song1,song2,song3,song4; public String name; public MusicBoxMessage(int i, int j, int k, String name, String... song) { x = i; y = j; z = k; song1 = song[0]; song2 = song[1]; song3 = song[2]; song4 = song[3]; this.name = name; } @Override public void fromBytes(ByteBuf buf) { //Reads the data in the same order it was written. x, y, z, song1-4, then name x = buf.readInt(); y = buf.readInt(); z = buf.readInt(); song1 = ByteBufUtils.readUTF8String(buf); song2 = ByteBufUtils.readUTF8String(buf); song3 = ByteBufUtils.readUTF8String(buf); song4 = ByteBufUtils.readUTF8String(buf); name = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); ByteBufUtils.writeUTF8String(buf, song1); ByteBufUtils.writeUTF8String(buf, song2); ByteBufUtils.writeUTF8String(buf, song3); ByteBufUtils.writeUTF8String(buf, song4); ByteBufUtils.writeUTF8String(buf, name); } public static class Handler implements IMessageHandler<MusicBoxMessage, IMessage> { @Override public IMessage onMessage(MusicBoxMessage message, MessageContext ctx) { //Get the tileentity at the correct coordinates server-side: TileEntityMusicDesk te = ((TileEntityMusicDesk)ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z)); //Call the method server-side: te.createSongReel(ctx.getServerHandler().playerEntity, new String[] {message.song1,message.song2,message.song3,message.song4,message.song2,message.song3,message.song4}, message.name); } } }
  5. I thank you all for your effort and help, it now works like a charm!! Thank you again!
  6. Ok, thank you. So, this is what I have for my packet. (I followed the forge netty packet example). If I remove the "this.createSOngReel();" in the GuiMusicDesk.class, this will do it for me since I set it to do that on the client side above AND the server side? Here is the modified code: I've never used packets before. So I expect to be completely wrong.
  7. http://cdn.makeagif.com/media/9-08-2014/5wGA2P.gif The gif above illustrates my conundrum: When I click Done! An item should appear in the bottom slot, which works. But, when I grab it, it disappears an instant after being in my hand and the above stacksize increases until I pick that up and then goes back down. The item in the bottom slot is called "reel_written" and the item above is "reel_blank" (They are not the same items and so I do not place the item in the top slot as is the illusion) I suspect it is a syncing problem, but I really don't enjoy the thought of getting into packet handling (besides, people have said that this is already taken care of with guis, maybe I'm/they're wrong, idk) TileEntityMusicDesk ContainerMusicDesk CommonProxy GuiMusicBox And in my main mod class, I register the proxy as the guihandler in the initialisation method since it implements IGuiHandler. If anyone knows what is going on, please help me to understand how to fix this issue. I have been googling this problem 3 days and all the relevant links are purple'd out and not one helped. I am new on these forums, so if I have done anything incorrectly, I'd prefer you not to be harsh, just tell me calmly, thanks.
×
×
  • Create New...

Important Information

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