This commit is contained in:
SD 2021-03-29 20:58:34 +05:30
commit 4e0c63628a
11 changed files with 46 additions and 49 deletions

View file

@ -9,11 +9,8 @@ import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.mixin.accessor.GenerationSettingsAccessor;
import org.dimdev.dimdoors.world.feature.decorator.EternalFluidLakeDecorator;
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 org.dimdev.dimdoors.world.feature.gateway.schematic.*;
import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicGateway;
import net.minecraft.structure.rule.BlockMatchRuleTest;
import net.minecraft.util.Identifier;
@ -38,10 +35,10 @@ import net.fabricmc.loader.api.FabricLoader;
// Do not remove deprecated stuff
@SuppressWarnings("DeprecatedIsStillUsed")
public final class ModFeatures {
public static final Feature<SchematicV2GatewayFeatureConfig> SCHEMATIC_GATEWAY_FEATURE = new SchematicV2GatewayFeature(SchematicV2GatewayFeatureConfig.CODEC);
public static final Feature<SchematicGatewayFeatureConfig> SCHEMATIC_GATEWAY_FEATURE = new SchematicGatewayFeature(SchematicGatewayFeatureConfig.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 SchematicGateway SANDSTONE_PILLARS_GATEWAY = new SandstonePillarsGateway();
public static final SchematicGateway TWO_PILLARS_GATEWAY = new TwoPillarsGateway();
@Deprecated public static final Decorator<ChanceDecoratorConfig> ETERNAL_FLUID_LAKE_DECORATOR = new EternalFluidLakeDecorator(ChanceDecoratorConfig.CODEC);
public static final ConfiguredFeature<?, ?> SANDSTONE_PILLARS_FEATURE;
public static final ConfiguredFeature<?, ?> TWO_PILLARS_FEATURE;
@ -79,8 +76,8 @@ public final class ModFeatures {
static {
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : DimensionalDoorsInitializer.getConfig().getWorldConfig().gatewayGenChance;
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));
SANDSTONE_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicGatewayFeatureConfig(SchematicGateway.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 SchematicGatewayFeatureConfig(SchematicGateway.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));
SOLID_STATIC_ORE = Feature.ORE.configure(new OreFeatureConfig(new BlockMatchRuleTest(ModBlocks.UNRAVELLED_FABRIC), ModBlocks.SOLID_STATIC.getDefaultState(), 4)).range(new RangeDecoratorConfig(YOffset.getBottom(), YOffset.getTop())).repeat(3);
}

View file

@ -11,8 +11,8 @@ import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
public class SandstonePillarsV2Gateway extends SchematicV2Gateway {
public SandstonePillarsV2Gateway() {
public class SandstonePillarsGateway extends SchematicGateway {
public SandstonePillarsGateway() {
super("sandstone_pillars");
}

View file

@ -18,19 +18,19 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
public abstract class SchematicV2Gateway implements Gateway, BiPredicate<StructureWorldAccess, BlockPos> {
public abstract class SchematicGateway implements Gateway, BiPredicate<StructureWorldAccess, BlockPos> {
private Schematic schematic;
private final String id;
public static final BiMap<String, SchematicV2Gateway> ID_SCHEMATIC_MAP = HashBiMap.create();
public static final BiMap<String, SchematicGateway> ID_SCHEMATIC_MAP = HashBiMap.create();
private boolean replaced;
public SchematicV2Gateway(String id) {
public SchematicGateway(String id) {
ID_SCHEMATIC_MAP.putIfAbsent(id, this);
this.id = id;
}
public void init() {
String schematicJarDirectory = "/data/dimdoors/gateways/v2/";
String schematicJarDirectory = "/data/dimdoors/gateways/";
try (InputStream stream = DimensionalDoorsInitializer.class.getResourceAsStream(schematicJarDirectory + this.id + ".schem")) {
if (stream == null) {

View file

@ -6,13 +6,13 @@ import net.minecraft.block.AirBlock;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.util.FeatureContext;
public class SchematicV2GatewayFeature extends Feature<SchematicV2GatewayFeatureConfig> {
public SchematicV2GatewayFeature(Codec<SchematicV2GatewayFeatureConfig> codec) {
public class SchematicGatewayFeature extends Feature<SchematicGatewayFeatureConfig> {
public SchematicGatewayFeature(Codec<SchematicGatewayFeatureConfig> codec) {
super(codec);
}
@Override
public boolean generate(FeatureContext<SchematicV2GatewayFeatureConfig> featureContext) {
public boolean generate(FeatureContext<SchematicGatewayFeatureConfig> featureContext) {
if (featureContext.getWorld().getBlockState(featureContext.getOrigin()).getBlock() instanceof AirBlock && featureContext.getConfig().getGateway().test(featureContext.getWorld(), featureContext.getOrigin())) {
featureContext.getConfig().getGateway().generate(featureContext.getWorld(), featureContext.getOrigin());
return true;

View file

@ -0,0 +1,28 @@
package org.dimdev.dimdoors.world.feature.gateway.schematic;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.gen.feature.FeatureConfig;
public class SchematicGatewayFeatureConfig implements FeatureConfig {
public static final Codec<SchematicGatewayFeatureConfig> CODEC = RecordCodecBuilder.create((instance) -> instance.group(
Codec.STRING.fieldOf("gatewayId").forGetter(SchematicGatewayFeatureConfig::getGatewayId)
).apply(instance, SchematicGatewayFeatureConfig::new));
private final SchematicGateway gateway;
private final String gatewayId;
public SchematicGatewayFeatureConfig(String id) {
this.gatewayId = id;
this.gateway = SchematicGateway.ID_SCHEMATIC_MAP.get(id);
}
public SchematicGateway getGateway() {
return this.gateway;
}
public String getGatewayId() {
return this.gatewayId;
}
}

View file

@ -1,28 +0,0 @@
package org.dimdev.dimdoors.world.feature.gateway.schematic;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.gen.feature.FeatureConfig;
public class SchematicV2GatewayFeatureConfig implements FeatureConfig {
public static final Codec<SchematicV2GatewayFeatureConfig> CODEC = RecordCodecBuilder.create((instance) -> instance.group(
Codec.STRING.fieldOf("gatewayId").forGetter(SchematicV2GatewayFeatureConfig::getGatewayId)
).apply(instance, SchematicV2GatewayFeatureConfig::new));
private final SchematicV2Gateway gateway;
private final String gatewayId;
public SchematicV2GatewayFeatureConfig(String id) {
this.gatewayId = id;
this.gateway = SchematicV2Gateway.ID_SCHEMATIC_MAP.get(id);
}
public SchematicV2Gateway getGateway() {
return this.gateway;
}
public String getGatewayId() {
return this.gatewayId;
}
}

View file

@ -12,10 +12,10 @@ import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.biome.Biome;
public class TwoPillarsV2Gateway extends SchematicV2Gateway {
public class TwoPillarsGateway extends SchematicGateway {
private static final int GATEWAY_RADIUS = 4;
public TwoPillarsV2Gateway() {
public TwoPillarsGateway() {
super("two_pillars");
}