diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java index 15aad834..e23373f0 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java @@ -44,11 +44,13 @@ public abstract class ChorusPlantBlockMixin extends Block { private void beConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable info) { BlockState plant = info.getReturnValue(); if (plant.isOf(Blocks.CHORUS_PLANT)) { - if (!plant.get(Properties.DOWN) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { + if (world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { info.setReturnValue(plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true)); + info.cancel(); } else { info.setReturnValue(plant.with(BlocksHelper.ROOTS, false)); + info.cancel(); } } } @@ -68,9 +70,11 @@ public abstract class ChorusPlantBlockMixin extends Block { if (plant.isOf(Blocks.CHORUS_PLANT)) { if (world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true); + info.cancel(); } else { plant = plant.with(BlocksHelper.ROOTS, false); + info.cancel(); } info.setReturnValue(plant); info.cancel(); @@ -81,12 +85,10 @@ public abstract class ChorusPlantBlockMixin extends Block { private void beGetPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable info) { BlockPos pos = ctx.getBlockPos(); World world = ctx.getWorld(); - if (ctx.canPlace() && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { - BlockState plant = info.getReturnValue(); - if (plant.isOf(Blocks.CHORUS_PLANT)) { - info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true)); - info.cancel(); - } + BlockState plant = info.getReturnValue(); + if (ctx.canPlace() && plant.isOf(Blocks.CHORUS_PLANT) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { + info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true)); + info.cancel(); } } } diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java index d15d44c2..5fe5fe3f 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantFeatureMixin.java @@ -7,6 +7,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.ChorusFlowerBlock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.StructureWorldAccess; @@ -14,6 +16,7 @@ import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.feature.ChorusPlantFeature; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import ru.betterend.registry.BlockRegistry; +import ru.betterend.util.BlocksHelper; import ru.betterend.util.MHelper; @Mixin(ChorusPlantFeature.class) @@ -22,6 +25,10 @@ public class ChorusPlantFeatureMixin { private void onGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable info) { if (structureWorldAccess.isAir(blockPos) && structureWorldAccess.getBlockState(blockPos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) { ChorusFlowerBlock.generate(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random)); + BlockState bottom = structureWorldAccess.getBlockState(blockPos); + if (bottom.isOf(Blocks.CHORUS_PLANT)) { + BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(BlocksHelper.ROOTS, true)); + } info.setReturnValue(true); info.cancel(); }