Chorus plant mixins config, Helix tree enhancements

This commit is contained in:
paulevsGitch 2021-01-10 16:42:31 +03:00
parent e96753eb2e
commit 614d0a58d2
6 changed files with 69 additions and 21 deletions

View file

@ -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);
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));
}
}

View file

@ -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,13 +33,17 @@ public abstract class ChorusPlantBlockMixin extends Block {
@Inject(method = "<init>*", at = @At("TAIL"))
private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) {
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) {
if (GeneratorOptions.changeChorusPlant()) {
builder.add(BlocksHelper.ROOTS);
}
}
@Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true)
private void beConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
@ -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)) {
if (GeneratorOptions.changeChorusPlant()) {
plant = plant.with(Properties.DOWN, true).with(BlocksHelper.ROOTS, true);
}
else {
plant = plant.with(Properties.DOWN, true);
}
info.cancel();
}
else {
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)) {
if (GeneratorOptions.changeChorusPlant()) {
info.setReturnValue(plant.with(BlocksHelper.ROOTS, true).with(Properties.DOWN, true));
}
else {
info.setReturnValue(plant.with(Properties.DOWN, true));
}
info.cancel();
}
}

View file

@ -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,8 +29,13 @@ public class ChorusPlantFeatureMixin {
ChorusFlowerBlock.generate(structureWorldAccess, blockPos, random, MHelper.randRange(8, 16, random));
BlockState bottom = structureWorldAccess.getBlockState(blockPos);
if (bottom.isOf(Blocks.CHORUS_PLANT)) {
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);
}
}

View file

@ -50,6 +50,7 @@ import ru.betterend.world.features.trees.MossyGlowshroomFeature;
import ru.betterend.world.features.trees.PythadendronTreeFeature;
import ru.betterend.world.features.trees.TenaneaFeature;
import ru.betterend.world.features.trees.UmbrellaTreeFeature;
import ru.betterend.world.generator.GeneratorOptions;
public class EndFeatures {
// Trees //
@ -156,6 +157,7 @@ public class EndFeatures {
public static final EndFeature CRASHED_SHIP = EndFeature.makeChansedFeature("crashed_ship", new CrashedShipFeature(), 500);
public static void registerBiomeFeatures(Identifier id, Biome biome, List<List<Supplier<ConfiguredFeature<?, ?>>>> features) {
if (GeneratorOptions.removeChorusFromVanillaBiomes()) {
if (id.getNamespace().equals("minecraft")) {
String path = id.getPath();
if (path.equals("end_highlands") || path.equals("end_midlands") || path.equals("small_end_islands")) {
@ -169,6 +171,7 @@ public class EndFeatures {
}
}
}
}
addFeature(FLAVOLITE_LAYER, features);
addFeature(ENDER_ORE, features);

View file

@ -80,14 +80,18 @@ public class HelixTreeFeature extends DefaultFeature {
});
spline.clear();
for (int i = 0; i <= 20; i++) {
float radius = 1 - i * 0.05F;
float rad = MHelper.randRange(8F, 11F, random);
int count = MHelper.randRange(20, 30, random);
float scaleM = 20F / (float) count * scale * 1.75F;
float hscale = 20F / (float) count * 0.05F;
for (int i = 0; i <= count; i++) {
float radius = 1 - i * hscale;
radius = radius * radius * 2 - 1;
radius *= radius;
radius = (1 - radius) * 8F * scale;
radius = (1 - radius) * rad * scale;
dx = (float) Math.sin(i * 0.45F + angle) * radius;
dz = (float) Math.cos(i * 0.45F + angle) * radius;
spline.add(new Vector3f(dx, i * scale * 1.75F, dz));
spline.add(new Vector3f(dx, i * scaleM, dz));
}
Vector3f start = new Vector3f();

View file

@ -9,6 +9,8 @@ public class GeneratorOptions {
private static boolean hasPillars;
private static boolean hasDragonFights;
private static boolean swapOverworldToEnd;
private static boolean changeChorusPlant;
private static boolean removeChorusFromVanillaBiomes;
public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getIntRoot("biomeSizeLand", 256);
@ -17,6 +19,8 @@ public class GeneratorOptions {
hasPillars = Configs.GENERATOR_CONFIG.getBooleanRoot("hasPillars", true);
hasDragonFights = Configs.GENERATOR_CONFIG.getBooleanRoot("hasDragonFights", true);
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
changeChorusPlant = Configs.GENERATOR_CONFIG.getBooleanRoot("changeChorusPlant", true);
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBooleanRoot("removeChorusFromVanillaBiomes", true);
}
public static int getBiomeSizeLand() {
@ -42,4 +46,12 @@ public class GeneratorOptions {
public static boolean swapOverworldToEnd() {
return swapOverworldToEnd;
}
public static boolean changeChorusPlant() {
return changeChorusPlant;
}
public static boolean removeChorusFromVanillaBiomes() {
return removeChorusFromVanillaBiomes;
}
}