Merge pull request #173 from BoogieMonster1O1/1.16-fabric
Limbo gateways
This commit is contained in:
commit
fe3df79771
39 changed files with 205 additions and 323 deletions
|
@ -19,9 +19,4 @@ public class LimboSkyProperties extends SkyProperties {
|
|||
public boolean useThickFog(int camX, int camY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getSkyColor(float skyAngle, float tickDelta) {
|
||||
return new float[]{0, 0, 0, 0};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ public class LimboSkyProvider extends CustomSkyProvider {
|
|||
private static final Identifier SUN_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_sun.png");
|
||||
|
||||
public LimboSkyProvider() {
|
||||
super(MOON_RENDER_PATH, SUN_RENDER_PATH, new Vec3i(255, 255, 255));
|
||||
super(MOON_RENDER_PATH, SUN_RENDER_PATH, new Vec3i(25, 25, 25));
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ public class ModRendering {
|
|||
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE_KEY, new LimboSkyProvider());
|
||||
OpenWorlds.registerCloudRenderer(ModDimensions.LIMBO_TYPE_KEY, (minecraftClient, matrixStack, v, v1, v2, v3) -> {
|
||||
});
|
||||
|
||||
OpenWorlds.registerSkyProperty(ModDimensions.LIMBO_TYPE_KEY, LimboSkyProperties.INSTANCE);
|
||||
setupFluidRendering(ModFluids.ETERNAL_FLUID, ModFluids.FLOWING_ETERNAL_FLUID, new Identifier("dimdoors:eternal_fluid"));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.dimdev.dimcore.schematic.Schematic;
|
||||
import org.dimdev.dimcore.schematic.SchematicConverter;
|
||||
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
|
@ -19,28 +20,30 @@ public class SchematicCommand {
|
|||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
dispatcher.register(literal("schematicold")
|
||||
.then(literal("place")
|
||||
.then(argument("schematic_name", StringArgumentType.string())
|
||||
.executes(ctx -> {
|
||||
SchematicConverter.reloadConversions();
|
||||
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||
String id = StringArgumentType.getString(ctx, "schematic_name");
|
||||
.then(argument("namespace", new SchematicNamespaceArgumentType())
|
||||
.then(argument("schematic_name", StringArgumentType.string())
|
||||
.executes(ctx -> {
|
||||
SchematicConverter.reloadConversions();
|
||||
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||
String id = StringArgumentType.getString(ctx, "schematic_name");
|
||||
String ns = SchematicNamespaceArgumentType.getValue(ctx, "namespace");
|
||||
try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/" + ns + "/" + id + ".schem")) {
|
||||
Schematic.fromTag(NbtIo.readCompressed(in))
|
||||
.place(
|
||||
player.world,
|
||||
(int) player.getPos().x,
|
||||
(int) player.getPos().y,
|
||||
(int) player.getPos().z
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/ruins/" + id + ".schem")) {
|
||||
Schematic.fromTag(NbtIo.readCompressed(in))
|
||||
.place(
|
||||
player.world,
|
||||
(int) player.getPos().x,
|
||||
(int) player.getPos().y,
|
||||
(int) player.getPos().z
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(id + " placed");
|
||||
|
||||
System.out.println(id + " placed");
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -9,6 +9,6 @@ public class ModFluids {
|
|||
public static final FlowableFluid FLOWING_ETERNAL_FLUID = register("dimdoors:flowing_eternal_fluid", new EternalFluid.Flowing());
|
||||
|
||||
private static <T extends Fluid> T register(String string, T fluid) {
|
||||
return (T) Registry.register(Registry.FLUID, string, fluid);
|
||||
return Registry.register(Registry.FLUID, string, fluid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
|
|||
public class DefaultBiomeFeaturesMixin {
|
||||
@Inject(method = "addDesertLakes", at = @At("RETURN"))
|
||||
private static void addGateway(GenerationSettings.Builder builder, CallbackInfo ci) {
|
||||
builder.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, ModFeatures.SANDSTONE_PILLARS_FEATURE_V2);
|
||||
builder.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, ModFeatures.SANDSTONE_PILLARS_FEATURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.dimdev.dimdoors.block.ModBlocks;
|
|||
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
||||
import org.dimdev.dimdoors.mixin.BuiltinBiomesAccessor;
|
||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||
import org.dimdev.dimdoors.world.feature.ModFeatures;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
|
@ -16,6 +17,7 @@ import net.minecraft.world.biome.Biome;
|
|||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
|
||||
|
||||
|
@ -34,10 +36,10 @@ public final class ModBiomes {
|
|||
Registry.register(BuiltinRegistries.BIOME, PERSONAL_WHITE_VOID_KEY.getValue(), PERSONAL_WHITE_VOID_BIOME);
|
||||
Registry.register(BuiltinRegistries.BIOME, PUBLIC_BLACK_VOID_KEY.getValue(), PUBLIC_BLACK_VOID_BIOME);
|
||||
Registry.register(BuiltinRegistries.BIOME, DUNGEON_DANGEROUS_BLACK_VOID_KEY.getValue(), DUNGEON_DANGEROUS_BLACK_VOID_BIOME);
|
||||
// BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(LIMBO_BIOME), LIMBO_KEY);
|
||||
// BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(PERSONAL_WHITE_VOID_BIOME), PERSONAL_WHITE_VOID_KEY);
|
||||
// BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(PUBLIC_BLACK_VOID_BIOME), PUBLIC_BLACK_VOID_KEY);
|
||||
// BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(DUNGEON_DANGEROUS_BLACK_VOID_BIOME), DUNGEON_DANGEROUS_BLACK_VOID_KEY);
|
||||
BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(LIMBO_BIOME), LIMBO_KEY);
|
||||
BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(PERSONAL_WHITE_VOID_BIOME), PERSONAL_WHITE_VOID_KEY);
|
||||
BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(PUBLIC_BLACK_VOID_BIOME), PUBLIC_BLACK_VOID_KEY);
|
||||
BuiltinBiomesAccessor.getIdMap().put(BuiltinRegistries.BIOME.getRawId(DUNGEON_DANGEROUS_BLACK_VOID_BIOME), DUNGEON_DANGEROUS_BLACK_VOID_KEY);
|
||||
}
|
||||
|
||||
private static BiomeEffects createEffect(boolean white) {
|
||||
|
@ -67,15 +69,16 @@ public final class ModBiomes {
|
|||
.depth(0.1f)
|
||||
.downfall(0.0f)
|
||||
.effects(new BiomeEffects.Builder()
|
||||
.fogColor(0x000000)
|
||||
.waterColor(0)
|
||||
.fogColor(0x404040)
|
||||
.waterColor(0x101010)
|
||||
.foliageColor(0)
|
||||
.waterFogColor(0)
|
||||
.moodSound(new BiomeMoodSound(ModSoundEvents.CREEPY, 6000, 8, 2.0))
|
||||
.skyColor(0x000000)
|
||||
.skyColor(0x404040)
|
||||
.grassColor(0)
|
||||
.build())
|
||||
.generationSettings(new GenerationSettings.Builder()
|
||||
.feature(GenerationStep.Feature.SURFACE_STRUCTURES, ModFeatures.LIMBO_GATEWAY_CONFIGURED_FEATURE)
|
||||
.surfaceBuilder(SurfaceBuilder.NETHER.method_30478(new TernarySurfaceConfig(ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.ETERNAL_FLUID.getDefaultState())))
|
||||
.build())
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.tag.BlockTags;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.biome.source.FixedBiomeSource;
|
||||
|
@ -60,6 +61,10 @@ public final class ModDimensions {
|
|||
return type == PERSONAL || type == PUBLIC || type == DUNGEON;
|
||||
}
|
||||
|
||||
public static boolean isLimbo(StructureWorldAccess world) {
|
||||
return world.getDimension() == LIMBO_TYPE || world == LIMBO_DIMENSION;
|
||||
}
|
||||
|
||||
public static boolean isLimboDimension(World world) {
|
||||
return world.getRegistryKey() == LIMBO || world.getDimension() == LIMBO_TYPE || world == LIMBO_DIMENSION;
|
||||
}
|
||||
|
@ -83,39 +88,38 @@ public final class ModDimensions {
|
|||
Optional.of(StructuresConfig.DEFAULT_STRONGHOLD),
|
||||
ImmutableMap.of()
|
||||
);
|
||||
// GenerationShapeConfig limboShapeConfig = new GenerationShapeConfig(
|
||||
// 178,
|
||||
// new NoiseSamplingConfig(
|
||||
// 1.000009876543,
|
||||
// 2.9999876545678,
|
||||
// 60,
|
||||
// 240
|
||||
// ),
|
||||
// new SlideConfig(
|
||||
// -10,
|
||||
// 3,
|
||||
// 0
|
||||
// ),
|
||||
// new SlideConfig(
|
||||
// -30,
|
||||
// 0,
|
||||
// 0
|
||||
// ),
|
||||
// 1,
|
||||
// 4,
|
||||
// 1,
|
||||
// -0.26875,
|
||||
// false,
|
||||
// true,
|
||||
// false,
|
||||
// false
|
||||
// );
|
||||
GenerationShapeConfig limboShapeConfig = new GenerationShapeConfig(256, new NoiseSamplingConfig(0.9999999814507745D, 0.9999999814507745D, 80.0D, 160.0D), new SlideConfig(-10, 3, 0), new SlideConfig(-30, 0, 0), 1, 2, 1.0D, -0.46875D, true, true, false, true);
|
||||
GenerationShapeConfig limboShapeConfig = new GenerationShapeConfig(
|
||||
178,
|
||||
new NoiseSamplingConfig(
|
||||
1.000009876543,
|
||||
2.9999876545678,
|
||||
60,
|
||||
240
|
||||
),
|
||||
new SlideConfig(
|
||||
-10,
|
||||
3,
|
||||
0
|
||||
),
|
||||
new SlideConfig(
|
||||
-30,
|
||||
0,
|
||||
0
|
||||
),
|
||||
1,
|
||||
4,
|
||||
1,
|
||||
-0.26875,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
);
|
||||
LIMBO_CHUNK_GENERATOR_SETTINGS = ChunkGeneratorSettingsAccessor.invokeInit(
|
||||
limboStructuresConfig,
|
||||
limboShapeConfig,
|
||||
ModBlocks.UNRAVELLED_FABRIC.getDefaultState(),
|
||||
ModBlocks.ETERNAL_FLUID.getDefaultState(),
|
||||
ModBlocks.BLACK_ANCIENT_FABRIC.getDefaultState(),
|
||||
-10,
|
||||
5,
|
||||
8,
|
||||
|
|
|
@ -1,36 +1,40 @@
|
|||
package org.dimdev.dimdoors.world.feature;
|
||||
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.v2.SandstonePillarsV2Gateway;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.v2.SchematicV2Gateway;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.v2.SchematicV2GatewayFeature;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.v2.SchematicV2GatewayFeatureConfig;
|
||||
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 net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public final class ModFeatures {
|
||||
public static final Feature<SchematicV2GatewayFeatureConfig> GATEWAY_FEATURE_V2 = Registry.register(Registry.FEATURE, new Identifier("dimdoors", "gateway_v2"), new SchematicV2GatewayFeature(SchematicV2GatewayFeatureConfig.CODEC));
|
||||
public static final SchematicV2Gateway SANDSTONE_PILLARS_GATEWAY_V2;
|
||||
public static final ConfiguredFeature<?, ?> SANDSTONE_PILLARS_FEATURE_V2;
|
||||
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 ConfiguredFeature<?, ?> SANDSTONE_PILLARS_FEATURE;
|
||||
public static final ConfiguredFeature<?, ?> LIMBO_GATEWAY_CONFIGURED_FEATURE;
|
||||
|
||||
public static void init() {
|
||||
SANDSTONE_PILLARS_GATEWAY_V2.init();
|
||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "sandstone_pillars_v2"), SANDSTONE_PILLARS_FEATURE_V2);
|
||||
SANDSTONE_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);
|
||||
}
|
||||
|
||||
static {
|
||||
SANDSTONE_PILLARS_GATEWAY_V2 = new SandstonePillarsV2Gateway();
|
||||
|
||||
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : ModConfig.INSTANCE.getWorldConfig().gatewayGenChance;
|
||||
SANDSTONE_PILLARS_FEATURE_V2 = GATEWAY_FEATURE_V2.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.SCHEMATIC_ID_MAP.get(SANDSTONE_PILLARS_GATEWAY_V2)))
|
||||
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));
|
||||
LIMBO_GATEWAY_CONFIGURED_FEATURE = LIMBO_GATEWAY_FEATURE.configure(DefaultFeatureConfig.INSTANCE).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public abstract class BaseGateway {
|
||||
public void generate(StructureWorldAccess world, int x, int y, int z) {
|
||||
}
|
||||
|
||||
protected boolean isBiomeValid(RegistryKey<Biome> biome) {
|
||||
return this.getBiomes().contains(biome);
|
||||
}
|
||||
|
||||
public boolean isLocationValid(World world, int x, int y, int z) {
|
||||
return this.isBiomeValid(BuiltinRegistries.BIOME.getKey(world.getBiome(new BlockPos(x, y, z))).orElseThrow(NullPointerException::new));
|
||||
}
|
||||
|
||||
public Set<RegistryKey<Biome>> getBiomes() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public interface Gateway {
|
||||
void generate(StructureWorldAccess world, BlockPos pos);
|
||||
|
||||
default boolean isBiomeValid(RegistryKey<Biome> biome) {
|
||||
return this.getBiomes().contains(biome);
|
||||
}
|
||||
|
||||
default boolean isLocationValid(StructureWorldAccess world, BlockPos pos) {
|
||||
return this.isBiomeValid(BuiltinRegistries.BIOME.getKey(world.getBiome(pos)).orElseThrow(NullPointerException::new));
|
||||
}
|
||||
|
||||
Set<RegistryKey<Biome>> getBiomes();
|
||||
}
|
|
@ -1,38 +1,53 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.world.ModBiomes;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public enum LimboGateway implements Gateway {
|
||||
INSTANCE;
|
||||
|
||||
public class LimboGateway extends BaseGateway {
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, int x, int y, int z) {
|
||||
public void generate(StructureWorldAccess world, BlockPos pos) {
|
||||
if (!this.isLocationValid(world, pos)) {
|
||||
return;
|
||||
}
|
||||
BlockState unravelledFabric = ModBlocks.UNRAVELLED_FABRIC.getDefaultState();
|
||||
// Build the gateway out of Unraveled Fabric. Since nearly all the blocks in Limbo are of
|
||||
// that type, there is no point replacing the ground.
|
||||
world.setBlockState(new BlockPos(x, y + 3, z + 1), unravelledFabric, 2);
|
||||
world.setBlockState(new BlockPos(x, y + 3, z - 1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 3, 1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 3, -1), unravelledFabric, 2);
|
||||
|
||||
// Build the columns around the door
|
||||
world.setBlockState(new BlockPos(x, y + 2, z - 1), unravelledFabric, 2);
|
||||
world.setBlockState(new BlockPos(x, y + 2, z + 1), unravelledFabric, 2);
|
||||
world.setBlockState(new BlockPos(x, y + 1, z - 1), unravelledFabric, 2);
|
||||
world.setBlockState(new BlockPos(x, y + 1, z + 1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 2, -1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 2, 1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 1, 1), unravelledFabric, 2);
|
||||
world.setBlockState(pos.add(0, 1, 1), unravelledFabric, 2);
|
||||
|
||||
this.placePortal(world, new BlockPos(x, y + 1, z), Direction.NORTH);
|
||||
}
|
||||
|
||||
private void placePortal(StructureWorldAccess world, BlockPos pos, Direction facing) {
|
||||
// todo
|
||||
this.placePortal(world, pos.add(0, 1, 0), Direction.NORTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocationValid(World world, int x, int y, int z) {
|
||||
return ModDimensions.isLimboDimension(world);
|
||||
public boolean isLocationValid(StructureWorldAccess world, BlockPos pos) {
|
||||
return ModDimensions.isLimbo(world);
|
||||
}
|
||||
|
||||
private void placePortal(StructureWorldAccess world, BlockPos pos, Direction facing) {
|
||||
world.setBlockState(pos, ModBlocks.DIMENSIONAL_PORTAL.getDefaultState(), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RegistryKey<Biome>> getBiomes() {
|
||||
return ImmutableSet.of(ModBiomes.LIMBO_KEY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.Feature;
|
||||
|
||||
public class LimboGatewayFeature extends Feature<DefaultFeatureConfig> {
|
||||
public LimboGatewayFeature() {
|
||||
super(DefaultFeatureConfig.CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig featureConfig) {
|
||||
LimboGateway.INSTANCE.generate(world, pos);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
|
||||
public class SandstonePillarsGateway extends SchematicGateway {
|
||||
public SandstonePillarsGateway() {
|
||||
super("sandstone_pillars");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RegistryKey<Biome>> getBiomes() {
|
||||
return ImmutableSet.of( BiomeKeys.DESERT, BiomeKeys.DESERT_LAKES, BiomeKeys.DESERT_HILLS);
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimcore.schematic.Schematic;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
|
||||
public abstract class SchematicGateway extends BaseGateway {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private Schematic schematic;
|
||||
public static final BiMap<SchematicGateway, String> SCHEMATIC_ID_MAP = HashBiMap.create();
|
||||
public static final BiMap<String, SchematicGateway> ID_SCHEMATIC_MAP = HashBiMap.create();
|
||||
|
||||
public SchematicGateway(String id) {
|
||||
String schematicJarDirectory = "/data/dimdoors/gateways/";
|
||||
SCHEMATIC_ID_MAP.putIfAbsent(this, id);
|
||||
ID_SCHEMATIC_MAP.putIfAbsent(id, this);
|
||||
|
||||
//Initialising the possible locations/formats for the schematic file
|
||||
InputStream schematicStream = DimensionalDoorsInitializer.class.getResourceAsStream(schematicJarDirectory + id + ".schem");
|
||||
|
||||
//determine which location to load the schematic file from (and what format)
|
||||
DataInputStream schematicDataStream = null;
|
||||
boolean streamOpened = false;
|
||||
if (schematicStream != null) {
|
||||
schematicDataStream = new DataInputStream(schematicStream);
|
||||
streamOpened = true;
|
||||
} else {
|
||||
LOGGER.warn("Schematic '" + id + "' was not found in the jar or config directory, neither with the .schem extension, nor with the .schematic extension.");
|
||||
}
|
||||
|
||||
CompoundTag schematicNBT;
|
||||
this.schematic = null;
|
||||
if (streamOpened) {
|
||||
try {
|
||||
schematicNBT = NbtIo.readCompressed(schematicDataStream);
|
||||
this.schematic = Schematic.fromTag(schematicNBT);
|
||||
//PocketTemplate.replacePlaceholders(schematic);
|
||||
schematicDataStream.close();
|
||||
} catch (IOException ex) {
|
||||
LOGGER.error("Schematic file for " + id + " could not be read as a valid schematic NBT file.", ex);
|
||||
} finally {
|
||||
try {
|
||||
schematicDataStream.close();
|
||||
} catch (IOException ex) {
|
||||
LOGGER.error("Error occured while closing schematicDataStream", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, int x, int y, int z) {
|
||||
this.schematic.place(world, x, y, z);
|
||||
this.generateRandomBits(world, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates randomized portions of the gateway structure (e.g. rubble, foliage)
|
||||
*
|
||||
* @param world - the world in which to generate the gateway
|
||||
* @param x - the x-coordinate at which to center the gateway; usually where the door is placed
|
||||
* @param y - the y-coordinate of the block on which the gateway may be built
|
||||
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
|
||||
*/
|
||||
protected void generateRandomBits(StructureWorldAccess world, int x, int y, int z) {
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.block.AirBlock;
|
||||
import net.minecraft.block.FallingBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
|
||||
public class SchematicGatewayFeature extends Feature<SchematicGatewayFeatureConfig> {
|
||||
public SchematicGatewayFeature(Codec<SchematicGatewayFeatureConfig> codec) {
|
||||
super(codec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, SchematicGatewayFeatureConfig config) {
|
||||
if (world.getBlockState(blockPos).getBlock() instanceof AirBlock && world.getBlockState(blockPos.down()).getBlock() instanceof FallingBlock) {
|
||||
config.getGateway().generate(world, blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
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) -> {
|
||||
return instance.group(Codec.STRING.fieldOf("id").forGetter((config) -> {
|
||||
return config.gatewayId;
|
||||
})).apply(instance, SchematicGatewayFeatureConfig::new);
|
||||
});
|
||||
private final SchematicGateway gateway;
|
||||
private final String gatewayId;
|
||||
|
||||
public SchematicGateway getGateway() {
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
public SchematicGatewayFeatureConfig(String gatewayId) {
|
||||
this.gatewayId = gatewayId;
|
||||
this.gateway = SchematicGateway.ID_SCHEMATIC_MAP.get(gatewayId);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
|
||||
public class TwoPillarsGateway extends SchematicGateway {
|
||||
private static final int GATEWAY_RADIUS = 4;
|
||||
|
||||
public TwoPillarsGateway() {
|
||||
super("two_pillars");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generateRandomBits(StructureWorldAccess world, int x, int y, int z) {
|
||||
//Replace some of the ground around the gateway with bricks
|
||||
for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++) {
|
||||
for (int zc = -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++) {
|
||||
//Check that the block is supported by an opaque block.
|
||||
//This prevents us from building over a cliff, on the peak of a mountain,
|
||||
//or the surface of the ocean or a frozen lake.
|
||||
if (world.getBlockState(new BlockPos(x + xc, y - 1, z + zc)).getMaterial().isSolid()) {
|
||||
//Randomly choose whether to place bricks or not. The math is designed so that the
|
||||
//chances of placing a block decrease as we get farther from the gateway's center.
|
||||
int i = Math.abs(xc) + Math.abs(zc);
|
||||
if (i < world.getRandom().nextInt(2) + 3) {
|
||||
//Place Stone Bricks
|
||||
world.setBlockState(new BlockPos(x + xc, y, z + zc), Blocks.STONE_BRICKS.getDefaultState(), 2);
|
||||
} else if (i < world.getRandom().nextInt(3) + 3) {
|
||||
//Place Cracked Stone Bricks
|
||||
world.setBlockState(new BlockPos(x + xc, y, z + zc), Blocks.CRACKED_STONE_BRICKS.getDefaultState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway.v2;
|
||||
package org.dimdev.dimdoors.world.feature.gateway.schematic;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway.v2;
|
||||
package org.dimdev.dimdoors.world.feature.gateway.schematic;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger;
|
|||
import org.dimdev.dimcore.schematic.v2.Schematic;
|
||||
import org.dimdev.dimcore.schematic.v2.SchematicPlacer;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.BaseGateway;
|
||||
import org.dimdev.dimdoors.world.feature.gateway.Gateway;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.nbt.NbtIo;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
|
||||
public class SchematicV2Gateway extends BaseGateway {
|
||||
public abstract class SchematicV2Gateway implements Gateway {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private Schematic schematic;
|
||||
private final String id;
|
||||
|
@ -63,11 +63,6 @@ public class SchematicV2Gateway extends BaseGateway {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(StructureWorldAccess world, int x, int y, int z) {
|
||||
SchematicPlacer.place(this.schematic, world, new BlockPos(x, y, z));
|
||||
}
|
||||
|
||||
public void generate(StructureWorldAccess world, BlockPos pos) {
|
||||
SchematicPlacer.place(this.schematic, world, pos);
|
||||
}
|
||||
|
@ -80,6 +75,6 @@ public class SchematicV2Gateway extends BaseGateway {
|
|||
* @param y - the y-coordinate of the block on which the gateway may be built
|
||||
* @param z - the z-coordinate at which to center the gateway; usually where the door is placed
|
||||
*/
|
||||
protected void generateRandomBits(StructureWorldAccess world, int x, int y, int z) {
|
||||
protected void generateRandomBits(StructureWorldAccess world, BlockPos pos) {
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway.v2;
|
||||
package org.dimdev.dimdoors.world.feature.gateway.schematic;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.dimdev.dimdoors.world.feature.gateway.SchematicGatewayFeatureConfig;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.block.AirBlock;
|
|
@ -1,4 +1,4 @@
|
|||
package org.dimdev.dimdoors.world.feature.gateway.v2;
|
||||
package org.dimdev.dimdoors.world.feature.gateway.schematic;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
@ -0,0 +1,37 @@
|
|||
//package org.dimdev.dimdoors.world.feature.gateway.v2;
|
||||
//
|
||||
//import net.minecraft.block.Blocks;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.world.StructureWorldAccess;
|
||||
//
|
||||
//public class TwoPillarsV2Gateway extends SchematicGateway {
|
||||
// private static final int GATEWAY_RADIUS = 4;
|
||||
//
|
||||
// public TwoPillarsV2Gateway() {
|
||||
// super("two_pillars");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void generateRandomBits(StructureWorldAccess world, BlockPos pos) {
|
||||
// //Replace some of the ground around the gateway with bricks
|
||||
// for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++) {
|
||||
// for (int zc = -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++) {
|
||||
// //Check that the block is supported by an opaque block.
|
||||
// //This prevents us from building over a cliff, on the peak of a mountain,
|
||||
// //or the surface of the ocean or a frozen lake.
|
||||
// if (world.getBlockState(pos.add(xc, -1, zc)).getMaterial().isSolid()) {
|
||||
// //Randomly choose whether to place bricks or not. The math is designed so that the
|
||||
// //chances of placing a block decrease as we get farther from the gateway's center.
|
||||
// int i = Math.abs(xc) + Math.abs(zc);
|
||||
// if (i < world.getRandom().nextInt(2) + 3) {
|
||||
// //Place Stone Bricks
|
||||
// world.setBlockState(pos.add(xc, 0, zc), Blocks.STONE_BRICKS.getDefaultState(), 2);
|
||||
// } else if (i < world.getRandom().nextInt(3) + 3) {
|
||||
// //Place Cracked Stone Bricks
|
||||
// world.setBlockState(pos.add(xc, 0, zc), Blocks.CRACKED_STONE_BRICKS.getDefaultState(), 2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue