Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ModItem extends Item {
- public ModItem() {
- super(new Item.Properties().group(ItemGroup.TOOLS));
- }
- public ActionResultType itemInteractionForEntity(ItemStack stack, PlayerEntity playerIn, LivingEntity target, Hand hand) {
- if (!(target instanceof PlayerEntity)) {
- if (!playerIn.world.isRemote && target.isAlive()) {
- System.out.println("Mod cap before: " + target.getCapability(ModCap.MOD_CAP).orElse(new ModCapMethods()).get());
- target.getCapability(ModCap.MOD_CAP).ifPresent(IModCap::set);
- System.out.println("Mod cap after: " + target.getCapability(ModCap.MOD_CAP).orElse(new ModCapMethods()).get());
- stack.shrink(1);
- }
- return ActionResultType.func_233537_a_(playerIn.world.isRemote);
- } else {
- return ActionResultType.PASS;
- }
- }
- }
RAW Paste Data