diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java index 96024254..56d9999d 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java @@ -3,16 +3,31 @@ package ru.betterend.mixin.common; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.ChorusPlantBlock; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockView; import net.minecraft.world.WorldView; import ru.betterend.registry.BlockRegistry; +import ru.betterend.registry.BlockTagRegistry; @Mixin(ChorusPlantBlock.class) public class ChorusPlantBlockMixin { + private static final BooleanProperty ROOTS = BooleanProperty.of("roots"); + + @Inject(method = "appendProperties", at = @At("TAIL")) + private void addProperties(StateManager.Builder builder, CallbackInfo info) { + builder.add(ROOTS); + } + @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) { @@ -20,4 +35,17 @@ public class ChorusPlantBlockMixin { info.cancel(); } } + + @Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true) + private void withConnectionProperties(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)) { + info.setReturnValue(plant.with(Properties.DOWN, true).with(ROOTS, true)); + } + else { + info.setReturnValue(plant.with(ROOTS, false)); + } + } + } } diff --git a/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy.png b/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy.png index bc53c4c1..cb6c8ef0 100644 Binary files a/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy.png and b/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy.png differ diff --git a/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy_2.png b/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy_2.png new file mode 100644 index 00000000..0d247e65 Binary files /dev/null and b/src/main/resources/assets/betterend/textures/block/pythadendron_log_side_mossy_2.png differ