diff --git a/CHANGELOG.md b/CHANGELOG.md index 63855afc8..4b244456d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Add Protea to Fragment Jungle - Hitting Fruit Blocks with a Projectile will now cause the block to break with the fruit dropping if it is fully grown - Fix Incompatibily with Organics Mod +- Clicking on Fruit Leaves with Fruit Item in creative will now place the fruit block below the leaves (Assuming there is air below) # 2.2.3 - Add Apple Fruit Decorator to Orchard Trees diff --git a/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/block/plants/tree/leaves/BWGFruitLeavesBlock.java b/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/block/plants/tree/leaves/BWGFruitLeavesBlock.java index a457200dd..97edc29d9 100644 --- a/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/block/plants/tree/leaves/BWGFruitLeavesBlock.java +++ b/Common/src/main/java/net/potionstudios/biomeswevegone/world/level/block/plants/tree/leaves/BWGFruitLeavesBlock.java @@ -3,11 +3,16 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.ItemInteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; import net.potionstudios.biomeswevegone.world.level.block.plants.tree.fruit.BWGFruitBlock; import org.jetbrains.annotations.NotNull; @@ -44,6 +49,16 @@ private void placeFruit(@NotNull Level level, @NotNull BlockPos pos) { level.setBlock(pos, fruitBlock.get().defaultBlockState().setValue(BWGFruitBlock.AGE, 0), 2); } + @Override + protected @NotNull ItemInteractionResult useItemOn(@NotNull ItemStack stack, @NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hitResult) { + if (player.isCreative() && !level.isClientSide()) + if (stack.getItem().getDefaultInstance().is(fruitBlock.get().getFruit()) && level.getBlockState(pos.below()).isAir()) { + placeFruit(level, pos.below()); + return ItemInteractionResult.SUCCESS; + } + return super.useItemOn(stack, state, level, pos, player, hand, hitResult); + } + @Override public boolean isValidBonemealTarget(@NotNull LevelReader level, @NotNull BlockPos pos, BlockState state) { return !state.getValue(PERSISTENT) && level.getBlockState(pos.below()).isAir();