-
[1.7.10] Ticking memory connection when opening GUI after changing NBT data
I am still supporting 1.7.10 in the mod I'm writing this for, along with 1.8 and 1.8.9. 1.9.4 and 1.10.2 will be supported, too.
-
[1.7.10] Ticking memory connection when opening GUI after changing NBT data
Hi, I have a GUI which opens upon rightclicking a custom item. Basically you can add and remove players to/from the item, and in order to save the players I'm using the ItemStack's NBTTagCompound via player.getCurrentEquippedItem().getTagCompound(). Whenever the NBT data gets changed and the GUI is closed and quickly reopened, I get a serverside crash: This is the method from the item's class where the GUI is opened from: public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par2World.isRemote) { if(!par1ItemStack.hasTagCompound()) { par1ItemStack.stackTagCompound = new NBTTagCompound(); ClientUtils.syncItemNBT(par1ItemStack); } if(aBoolean) par3EntityPlayer.openGui(Main.instance, guiToOpen, par2World, (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ); } return par1ItemStack; } This is ClientUtils.syncItemNBT(): @SideOnly(Side.CLIENT) public static void syncItemNBT(ItemStack item) { Main.network.sendToServer(new PacketSUpdateNBTTag(item)); } The Packet: public class PacketSUpdateNBTTag implements IMessage { private NBTTagCompound stack; private String itemName; public PacketSUpdateNBTTag(ItemStack par1ItemStack) { if(par1ItemStack != null && par1ItemStack.hasTagCompound()) { this.stack = par1ItemStack.stackTagCompound; this.itemName = par1ItemStack.getUnlocalizedName(); } } public void fromBytes(ByteBuf buf) { this.stack = ByteBufUtils.readTag(buf); this.itemName = ByteBufUtils.readUTF8String(buf); } public void toBytes(ByteBuf buf) { ByteBufUtils.writeTag(buf, this.stack); ByteBufUtils.writeUTF8String(buf, this.itemName); } public static class Handler extends PacketHelper implements IMessageHandler<PacketSUpdateNBTTag, IMessage> { public IMessage onMessage(PacketSUpdateNBTTag message, MessageContext context) { if(context.getServerHandler().playerEntity.getCurrentEquippedItem() != null && context.getServerHandler().playerEntity.getCurrentEquippedItem().getItem().getUnlocalizedName().matches(message.itemName)) context.getServerHandler().playerEntity.getCurrentEquippedItem().stackTagCompound = message.stack; return null; } } } What causes this crash and how can I fix it? Thanks in advance for any help!
-
[1.7.2]Getting the name of the player who sent a message to the chat?
Hello! I'm using the ClientChatReceivedEvent to check for specific words in the message, then giving a sound to the player. But I don't want the sound to play, if the current Player writes that specific word. So I need to get the name of the player who sent the message. I already tried the ClientChatReceivedEvent.message.func_150260_c(); method (which returns the message just as you see it in the chat) and then extracting the players name, but that does not work on servers with custom chat formats, since I search for "<" and ">". Is there any way to get the name without searching for specific symbols in the message and extracting them? Thanks in advance ~bl4ck
-
[SOLVED] Item doesn't break!
Could you post the Handler as well please?
-
[1.6.2] Custom Music Disc
Like I already told you in the Minecraft forums, it may have something todo with the file itself. That was the solution for me. And if your preInit is missing @EventManager and it still doesn't work, try the thing with GoldWaves again. And it is missing the FMLPreInitializationEvent event in the brackets.
-
[SOLVED]Adding custom dungeon loot?
Thanks But what is the rarity of some vanilla Item, let's say a music disc? I need a number to navigate with.
-
[SOLVED]Adding custom dungeon loot?
Hi guys! What I'd like to do is adding a custom item to a dungeon/mineshaft/stronghold chest. How would I do this?
-
Error in crafting a block
Please give us the code.
-
Crafting recipe error when using custom items
The source code is very helpful on this.
-
config file
What do you mean by "you can read from them but not write"?
-
How to spawn a mob similar to the Iron Golem?
But that is for a custom Block - I'd like it for the vanilla pumpkin. And without editing the base class...
-
How to spawn a mob similar to the Iron Golem?
Exactly.
-
How to spawn a mob similar to the Iron Golem?
Thank you so far. But how can I add my Golems to the "Awake-List" without editing BlockPumpkin.java?
-
How to spawn a mob similar to the Iron Golem?
Hello guys! I'd like to make a new mob and I want it so that you have to put some blocks down in a specific shape and the mob spawns when placing the Pumpkin (Yes, my mob has a pumpkin as a head ). I already looked at several source codes and I searched the vanilla one for solutions but I couldn't find anything. Can you please help me out?
-
[solved]Music discs with 1.6.2
The sounds are loaded... I'm going to PM you my source code, maybe something is wrong in the depths of it.
IPS spam blocked by CleanTalk.