Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ModTagItem extends Item {
- public ModTagItem() {
- 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 tag before: " + target.getCapability(ModTagProvider.MOD_TAG).orElseThrow(
- () -> new IllegalArgumentException("LazyOptional must not be empty!")).get());
- target.getCapability(ModTagProvider.MOD_TAG).ifPresent(iModTag -> iModTag.set(1));
- System.out.println("Mod tag after: " + target.getCapability(ModTagProvider.MOD_TAG).orElseThrow(
- () -> new IllegalArgumentException("LazyOptional cannot be empty!")).get());
- stack.shrink(1);
- }
- return ActionResultType.func_233537_a_(playerIn.world.isRemote);
- } else {
- return ActionResultType.PASS;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement