Jump to content

TowerMX

Members
  • Posts

    4
  • Joined

  • Last visited

TowerMX's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. That was it. It now works fine, thanks a lot!
  2. In my mod I create a new block class, which when right-clicked it should give the player an item. Well, I managed to get it working properly, but then I added more lines of code to it and it stopped working. I've tried removing everything but the required lines (as I think it was when it worked) and it is not working. I hope you can fin what I'm doing wrong in the code I attach (note that some method overrides are missing, I'm not attaching the whole code, just the needed). package com.name.modid.objects.blocks; //Imports here public class ModBlock extends Block { //Some missing methods here, don't mind. They exist in my code. @ObjectHolder("modid:moditem") public static final Item item_var = null; ItemStack item_stack = new ItemStack(item_var); @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { player.inventory.addItemStackToInventory(item_stack); return ActionResultType.SUCCESS; } }
  3. Thank you! I was messing up and couldn't understand exactly how to use it. I've managed to use the Player#getHeldItem as you said and it works fine, I can now use its id and nbt.
  4. I'm trying to make a block give you an item only when you click it with a certain item (id and nbt). I've seen this solved in previous versions but I just can't figure out how to do this in 1.15.2. Also, I'm manipulating the onBlockActivated action in this block class, is it right? Thanks for any help.
×
×
  • Create New...

Important Information

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