FantaLaTone Posted July 13, 2022 Posted July 13, 2022 (edited) Hello I have an entity with mobInteraction event. When right clicked it with a specific item mob tells player to mob's gender but when I right clicked with item it tells mob's gender and also process other interactions how I can return after tells player mob's gender? Here's my code : @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); Item item = itemstack.getItem(); Level world = player.level; if (world.isClientSide) { if (item == ModItems.GRIFFIN_GENDER_TOME.get()) { player.sendMessage(new TextComponent("") .append(this.getGender() == 0 ? "§bBoy" : "§dGirl") , player.getUUID()); return InteractionResult.SUCCESS; // RETURN AFTER THIS BUT IT'S NOT WORKING } } if (item == Items.PORKCHOP || item == Items.BEEF && !isTame()) { if (this.level.isClientSide) { return InteractionResult.CONSUME; } else { if (!player.getAbilities().instabuild) { itemstack.shrink(1); } if (!ForgeEventFactory.onAnimalTame(this, player) && this.random.nextInt(8) == 0) { if (!this.level.isClientSide) { super.tame(player); this.navigation.recomputePath(); this.setTarget(null); this.level.broadcastEntityEvent(this, (byte)7); setSitting(true); } } return InteractionResult.SUCCESS; } } if(isTame() && !this.level.isClientSide && hand == InteractionHand.MAIN_HAND) { setSitting(!isSitting()); return InteractionResult.SUCCESS; } if (itemstack.getItem() == Items.PORKCHOP || itemstack.getItem() == Items.BEEF) { return InteractionResult.PASS; } return super.mobInteract(player, hand); } Edited July 13, 2022 by FantaLaTone Quote
FantaLaTone Posted July 13, 2022 Author Posted July 13, 2022 What should I return to prevent other codes to processing? Quote
FantaLaTone Posted July 13, 2022 Author Posted July 13, 2022 I solved the problem by just rearrengin if statements order if (item == ModItems.GRIFFIN_GENDER_TOME.get()) { if (world.isClientSide) { player.sendMessage(new TextComponent("") .append(this.getGender() == 0 ? "§bBoy" : "§dGirl") , player.getUUID()); } return InteractionResult.SUCCESS; } Quote
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.