theoneandonly2004 Posted December 7, 2014 Share Posted December 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
Abastro Posted December 7, 2014 Share Posted December 7, 2014 NBT Tags will not work for stacked items, So I think that will cause first problem. For second, I dont know.. Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium. Link to comment Share on other sites More sharing options...
tattyseal Posted December 7, 2014 Share Posted December 7, 2014 if(event.smelting.stackTagCompound.getString("Owner")== null) should be if(!event.smelting.stackTagCompound.hasKey("Owner")) Quote Link to comment Share on other sites More sharing options...
theoneandonly2004 Posted December 7, 2014 Author Share Posted December 7, 2014 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 Quote Link to comment Share on other sites More sharing options...
Abastro Posted December 7, 2014 Share Posted December 7, 2014 Ah, what tattyseal said is right.. You have to check if there is the key, For event.smelting.stackTagCompound.getString("Owner") will give "". Quote I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium. Link to comment Share on other sites More sharing options...
theoneandonly2004 Posted December 8, 2014 Author Share Posted December 8, 2014 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.