List hacks

Changes to be committed:
	modified:   src/main/java/org/dimdev/dimdoors/ModConfig.java
	new file:   src/main/java/org/dimdev/dimdoors/mixin/GenerationSettingsAccessor.java
	modified:   src/main/java/org/dimdev/dimdoors/world/feature/ModFeatures.java
	modified:   src/main/java/org/dimdev/dimdoors/world/feature/gateway/schematic/SchematicV2Gateway.java
	modified:   src/main/resources/dimdoors.mixins.json
This commit is contained in:
SD 2020-10-06 17:18:01 +05:30
parent 889b245dd6
commit b73b7272a4
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
5 changed files with 51 additions and 6 deletions

View file

@ -149,7 +149,7 @@ public final class ModConfig {
Codecs.INT_SET.fieldOf("gatewayDimBlacklist").forGetter((world) -> world.gatewayDimBlacklist)
).apply(instance, World::create));
public double clusterGenChance = 0.0002;
public int gatewayGenChance = 80;
public int gatewayGenChance = 200;
public Set<Integer> clusterDimBlacklist = new LinkedHashSet<>();
public Set<Integer> gatewayDimBlacklist = new LinkedHashSet<>();

View file

@ -0,0 +1,18 @@
package org.dimdev.dimdoors.mixin;
import java.util.List;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.ConfiguredFeature;
@Mixin(GenerationSettings.class)
public interface GenerationSettingsAccessor {
@Mutable
@Accessor
void setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> features);
}

View file

@ -1,16 +1,24 @@
package org.dimdev.dimdoors.world.feature;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.mixin.GenerationSettingsAccessor;
import org.dimdev.dimdoors.world.feature.gateway.LimboGatewayFeature;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SandstonePillarsV2Gateway;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2Gateway;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2GatewayFeature;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2GatewayFeatureConfig;
import org.dimdev.dimdoors.world.feature.gateway.schematic.TwoPillarsV2Gateway;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
@ -25,22 +33,42 @@ public final class ModFeatures {
public static final Feature<SchematicV2GatewayFeatureConfig> SCHEMATIC_GATEWAY_FEATURE = Registry.register(Registry.FEATURE, new Identifier("dimdoors", "schematic_gateway"), new SchematicV2GatewayFeature(SchematicV2GatewayFeatureConfig.CODEC));
public static final Feature<DefaultFeatureConfig> LIMBO_GATEWAY_FEATURE = Registry.register(Registry.FEATURE, new Identifier("dimdoors", "limbo_gateway"), new LimboGatewayFeature());
public static final SchematicV2Gateway SANDSTONE_PILLARS_GATEWAY = new SandstonePillarsV2Gateway();
public static final SchematicV2Gateway TWO_PILLARS_GATEWAY = new TwoPillarsV2Gateway();
public static final ConfiguredFeature<?, ?> SANDSTONE_PILLARS_FEATURE;
public static final ConfiguredFeature<?, ?> TWO_PILLARS_FEATURE;
public static final ConfiguredFeature<?, ?> LIMBO_GATEWAY_CONFIGURED_FEATURE;
public static ConfiguredFeature<?, ?> ETERNAL_FLUID_LAKE;
public static void init() {
SANDSTONE_PILLARS_GATEWAY.init();
TWO_PILLARS_GATEWAY.init();
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "sandstone_pillars"), SANDSTONE_PILLARS_FEATURE);
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "limbo_gateway"), LIMBO_GATEWAY_CONFIGURED_FEATURE);
ETERNAL_FLUID_LAKE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "eternal_fluid_lake"), Feature.LAKE.configure(new SingleStateFeatureConfig(ModBlocks.ETERNAL_FLUID.getDefaultState())).decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(5, 70, 128)).applyChance(20)));
synchronized (BuiltinRegistries.BIOME) {
BuiltinRegistries.BIOME.stream()
.filter(biome ->
biome.getCategory() != Biome.Category.NONE &&
biome.getCategory() != Biome.Category.THEEND &&
biome.getCategory() != Biome.Category.NETHER &&
biome.getCategory() != Biome.Category.OCEAN &&
biome.getCategory() != Biome.Category.MUSHROOM
)
.forEach(biome -> {
int index = GenerationStep.Feature.SURFACE_STRUCTURES.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = new ArrayList<>(biome.getGenerationSettings().getFeatures());
List<Supplier<ConfiguredFeature<?, ?>>> surfaceStructures = new ArrayList<>(features.get(index));
surfaceStructures.add(() -> TWO_PILLARS_FEATURE);
features.set(index, surfaceStructures);
((GenerationSettingsAccessor) biome.getGenerationSettings()).setFeatures(features);
});
}
}
static {
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : ModConfig.INSTANCE.getWorldConfig().gatewayGenChance;
SANDSTONE_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.SCHEMATIC_ID_MAP.get(SANDSTONE_PILLARS_GATEWAY)))
.decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP
.applyChance(gatewayChance));
SANDSTONE_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(SANDSTONE_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
TWO_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(TWO_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
LIMBO_GATEWAY_CONFIGURED_FEATURE = LIMBO_GATEWAY_FEATURE.configure(DefaultFeatureConfig.INSTANCE).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
}
}

View file

@ -22,11 +22,9 @@ public abstract class SchematicV2Gateway implements Gateway {
private static final Logger LOGGER = LogManager.getLogger();
private Schematic schematic;
private final String id;
public static final BiMap<SchematicV2Gateway, String> SCHEMATIC_ID_MAP = HashBiMap.create();
public static final BiMap<String, SchematicV2Gateway> ID_SCHEMATIC_MAP = HashBiMap.create();
public SchematicV2Gateway(String id) {
SCHEMATIC_ID_MAP.putIfAbsent(this, id);
ID_SCHEMATIC_MAP.putIfAbsent(id, this);
this.id = id;
}

View file

@ -10,6 +10,7 @@
"DimensionTypeAccessor",
"DirectionAccessor",
"EntityMixin",
"GenerationSettingsAccessor",
"ListTagAccessor",
"PlayerEntityMixin",
"RedstoneWireBlockAccessor"