Chorus plant mixins config, Helix tree enhancements
This commit is contained in:
parent
e96753eb2e
commit
614d0a58d2
6 changed files with 69 additions and 21 deletions
|
@ -29,6 +29,7 @@ import net.minecraft.world.WorldView;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
@Mixin(value = ChorusFlowerBlock.class, priority = 100)
|
||||
public abstract class ChorusFlowerBlockMixin extends Block {
|
||||
|
@ -59,7 +60,12 @@ public abstract class ChorusFlowerBlockMixin extends Block {
|
|||
int i = state.get(ChorusFlowerBlock.AGE);
|
||||
if (i < 5) {
|
||||
this.grow(world, up, i + 1);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true));
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true));
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +75,7 @@ public abstract class ChorusFlowerBlockMixin extends Block {
|
|||
@Inject(method = "generate", at = @At("RETURN"), cancellable = true)
|
||||
private static void beOnGenerate(WorldAccess world, BlockPos pos, Random random, int size, CallbackInfo info) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.isOf(Blocks.CHORUS_PLANT)) {
|
||||
if (GeneratorOptions.changeChorusPlant() && state.isOf(Blocks.CHORUS_PLANT)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state.with(BlocksHelper.ROOTS, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.world.WorldView;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
@Mixin(value = ChorusPlantBlock.class, priority = 100)
|
||||
public abstract class ChorusPlantBlockMixin extends Block {
|
||||
|
@ -32,12 +33,16 @@ public abstract class ChorusPlantBlockMixin extends Block {
|
|||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) {
|
||||
this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false));
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "appendProperties", at = @At("TAIL"))
|
||||
private void beAddProperties(StateManager.Builder<Block, BlockState> builder, CallbackInfo info) {
|
||||
builder.add(BlocksHelper.ROOTS);
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
builder.add(BlocksHelper.ROOTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true)
|
||||
|
@ -69,11 +74,18 @@ public abstract class ChorusPlantBlockMixin extends Block {
|
|||
BlockState plant = info.getReturnValue();
|
||||
if (plant.isOf(Blocks.CHORUS_PLANT)) {
|
||||
if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true);
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true);
|
||||
}
|
||||
else {
|
||||
plant = plant.with(Properties.DOWN, true);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
else {
|
||||
plant = plant.with(BlocksHelper.ROOTS, false);
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
plant = plant.with(BlocksHelper.ROOTS, false);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
info.setReturnValue(plant);
|
||||
|
@ -87,7 +99,12 @@ public abstract class ChorusPlantBlockMixin extends Block {
|
|||
World world = ctx.getWorld();
|
||||
BlockState plant = info.getReturnValue();
|
||||
if (ctx.canPlace() && plant.isOf(Blocks.CHORUS_PLANT) && world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
|
||||
info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true));
|
||||
if (GeneratorOptions.changeChorusPlant()) {
|
||||
info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true));
|
||||
}
|
||||
else {
|
||||
info.setReturnValue(plant.with(Properties.DOWN, true));
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
|||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
@Mixin(ChorusPlantFeature.class)
|
||||
public class ChorusPlantFeatureMixin {
|
||||
|
@ -28,7 +29,12 @@ public class ChorusPlantFeatureMixin {
|
|||
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).with(ConnectingBlock.DOWN, true));
|
||||
if ((GeneratorOptions.changeChorusPlant())) {
|
||||
BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(BlocksHelper.ROOTS, true).with(ConnectingBlock.DOWN, true));
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(structureWorldAccess, blockPos, bottom.with(ConnectingBlock.DOWN, true));
|
||||
}
|
||||
}
|
||||
info.setReturnValue(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue