Jump to content

Recommended Posts

Posted

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

 

Posted

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.

Posted

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

Posted

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.

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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