More generator options

This commit is contained in:
paulevsGitch 2021-01-05 12:00:27 +03:00
parent 061dbac03a
commit 02d43cb670
5 changed files with 82 additions and 1 deletions

View file

@ -12,14 +12,23 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
import net.minecraft.world.gen.chunk.NoiseChunkGenerator;
import ru.betterend.world.generator.BetterEndBiomeSource;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(value = DimensionType.class, priority = 100)
public class DimensionTypeMixin {
@Inject(method = "createEndGenerator", at = @At("HEAD"), cancellable = true)
private static void replaceGenerator(Registry<Biome> biomeRegistry, Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
private static void beReplaceGenerator(Registry<Biome> biomeRegistry, Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
info.setReturnValue(new NoiseChunkGenerator(new BetterEndBiomeSource(biomeRegistry, seed), seed, () -> {
return (ChunkGeneratorSettings) chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.END);
}));
info.cancel();
}
@Inject(method = "hasEnderDragonFight", at = @At("HEAD"), cancellable = true)
private void beHasEnderDragonFight(CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasDragonFights()) {
info.setReturnValue(false);
info.cancel();
}
}
}

View file

@ -0,0 +1,26 @@
package ru.betterend.mixin.common;
import java.util.Random;
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.CallbackInfoReturnable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.EndPortalFeature;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndPortalFeature.class)
public class EndPortalFeatureMixin {
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
private void bePortalGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig, CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasPortal()) {
info.setReturnValue(false);
info.cancel();
}
}
}

View file

@ -0,0 +1,26 @@
package ru.betterend.mixin.common;
import java.util.Random;
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.CallbackInfoReturnable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.EndSpikeFeature;
import net.minecraft.world.gen.feature.EndSpikeFeatureConfig;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndSpikeFeature.class)
public class EndSpikeFeatureMixin {
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
private void beSpikeGenerate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, EndSpikeFeatureConfig endSpikeFeatureConfig, CallbackInfoReturnable<Boolean> info) {
if (!GeneratorOptions.hasPillars()) {
info.setReturnValue(false);
info.cancel();
}
}
}