Posted December 7, 201410 yr OK so I am working on a feature and I have the base of it somewhat functional. Currently whenever the player crafts an item it will display who owns it. However I am having a few problems which include 1)information will only display whenever a single item is selected it will not add if you shift click an item from the crafting slot 2)even through repeating this process similarly for smelting and EntityItemPickups they do not show the information . item pickup Event @SubscribeEvent public void ItemPickup(EntityItemPickupEvent event) { System.out.println("pick up called"); if(event.item.getEntityItem().stackTagCompound == null) { event.item.getEntityItem().stackTagCompound=new NBTTagCompound(); } if(event.item.getEntityItem().stackTagCompound.getString("Owner")== null) { event.item.getEntityItem().stackTagCompound.setString("Owner", event.entityPlayer.getDisplayName()); } } Smelting event @SubscribeEvent public void onSmelting(PlayerEvent.ItemSmeltedEvent event) { if(event.smelting.stackTagCompound==null) { event.smelting.setTagCompound(new NBTTagCompound()); } if(event.smelting.stackTagCompound.getString("Owner")== null) { event.smelting.stackTagCompound.setString("Owner",event.player.getCommandSenderName()); } } crafting handler @SubscribeEvent public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent event) { if(event.crafting.stackTagCompound==null) { event.crafting.stackTagCompound=new NBTTagCompound(); } if(event.crafting.stackTagCompound.getString("Owner")==null) { event.crafting.stackTagCompound.setString("Owner", event.player.getCommandSenderName()); } } tooltip display code @SubscribeEvent public void ToolTip(ItemTooltipEvent event) { if(event.itemStack.stackTagCompound==null) { event.itemStack.setTagCompound(new NBTTagCompound()); } event.toolTip.add("Items owner is: "+ event.itemStack.stackTagCompound.getString("Owner")) ; } not sure what the problem is so any help is appreciated. Thanks
December 7, 201410 yr NBT Tags will not work for stacked items, So I think that will cause first problem. For second, I dont know.. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
December 7, 201410 yr if(event.smelting.stackTagCompound.getString("Owner")== null) should be if(!event.smelting.stackTagCompound.hasKey("Owner"))
December 7, 201410 yr Author NBT Tags will not work for stacked items, So I think that will cause first problem. For second, I dont know.. yeah i had thought that but then when i was able to get a furnace to display its owner when crafted. Then it wouldn't stack with others(as i had expected) but would stack with anotherr one with the same name
December 7, 201410 yr Ah, what tattyseal said is right.. You have to check if there is the key, For event.smelting.stackTagCompound.getString("Owner") will give "". I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
December 8, 201410 yr Author ok I have pickups and smelting working now, just one problem of shift clicking an item from the furnace and crafting bench, since it'll set the owner if it's a single item takn at a time but not a stack although the single items can then be placed into a stack with others of the same owner. Any suggestions?
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.