Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Handles butterflies saving given flowers. */
- public InteractionResult mobInteract(Player player, InteractionHand hand) {
- Item item = player.getItemInHand(hand).getItem();
- ItemStack stack = item.getDefaultInstance();
- if (stack.is(ItemTags.FLOWERS)) {
- this.setSavedFlower(Block.byItem(item));
- // Success Particle
- if (this.level.isClientSide) {
- for (int i = 0; i < 7; ++i) {
- double d = this.random.nextGaussian() * 0.02D;
- this.level.addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), d, d, d);
- }
- }
- return InteractionResult.SUCCESS;
- } else {
- return InteractionResult.PASS;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement