diff --git a/gradle.properties b/gradle.properties index 61ec4081..e4d60498 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use # or better: https://modmuss50.me/fabric.html - minecraft_version=20w27a - yarn_mappings=20w27a+build.1 + minecraft_version=20w28a + yarn_mappings=20w28a+build.17 loader_version=0.8.9+build.203 # Mod Properties diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 1e452f2b..44b99983 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -68,13 +68,6 @@ public class CarpetSettings ) public static String language = "none"; - @Rule( - desc = "Nether portals correctly place entities going through", - extra = "Entities shouldn't suffocate in obsidian", - category = BUGFIX - ) - public static boolean portalSuffocationFix = false; - @Rule(desc = "Gbhs sgnf sadsgras fhskdpri!", category = EXPERIMENTAL) public static boolean superSecretSetting = false; diff --git a/src/main/java/carpet/helpers/FeatureGenerator.java b/src/main/java/carpet/helpers/FeatureGenerator.java index 42f263ea..f069837a 100644 --- a/src/main/java/carpet/helpers/FeatureGenerator.java +++ b/src/main/java/carpet/helpers/FeatureGenerator.java @@ -1,66 +1,97 @@ package carpet.helpers; import carpet.CarpetSettings; -import carpet.fakes.BiomeInterface; import carpet.fakes.StructureFeatureInterface; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import net.minecraft.block.Blocks; +import com.mojang.datafixers.util.Pair; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.StructureManager; import net.minecraft.structure.StructureStart; +import net.minecraft.structure.pool.StructurePool; +import net.minecraft.structure.pool.StructurePoolElement; +import net.minecraft.structure.processor.ProcessorLists; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; -import net.minecraft.structure.BastionRemnantGenerator; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; -import net.minecraft.world.gen.chunk.StructureConfig; -import net.minecraft.world.gen.feature.DefaultBiomeFeatures; import net.minecraft.world.biome.source.BiomeAccess; -//import net.minecraft.world.biome.source.BiomeSource; -//import net.minecraft.world.biome.source.FixedBiomeSource; -//import net.minecraft.world.biome.source.VanillaLayeredBiomeSource; -//import net.minecraft.world.biome.source.VanillaLayeredBiomeSourceConfig; import net.minecraft.world.gen.ChunkRandom; import net.minecraft.world.gen.chunk.ChunkGenerator; -//import net.minecraft.world.gen.chunk.OverworldChunkGenerator; -//import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig; +import net.minecraft.world.gen.chunk.StructureConfig; import net.minecraft.world.gen.decorator.BeehiveTreeDecorator; -import net.minecraft.world.gen.feature.BastionRemnantFeatureConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.ForestRockFeatureConfig; -import net.minecraft.world.gen.feature.HugeFungusFeatureConfig; -import net.minecraft.world.gen.feature.MineshaftFeature; -import net.minecraft.world.gen.feature.MineshaftFeatureConfig; -import net.minecraft.world.gen.feature.OceanRuinFeature; -import net.minecraft.world.gen.feature.OceanRuinFeatureConfig; -import net.minecraft.world.gen.feature.RandomPatchFeatureConfig; -import net.minecraft.world.gen.feature.SeaPickleFeatureConfig; -import net.minecraft.world.gen.feature.SeagrassFeatureConfig; -import net.minecraft.world.gen.feature.ShipwreckFeatureConfig; -import net.minecraft.world.gen.feature.SingleStateFeatureConfig; +import net.minecraft.world.gen.feature.SimpleRandomFeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.feature.StructurePoolFeatureConfig; import net.minecraft.world.gen.feature.TreeFeatureConfig; -import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; -import java.util.List; -import java.util.Locale; import java.util.Map; -import static net.minecraft.world.gen.feature.DefaultBiomeFeatures.FANCY_TREE_CONFIG; -import static net.minecraft.world.gen.feature.DefaultBiomeFeatures.OAK_TREE_CONFIG; - public class FeatureGenerator { + + synchronized public static Boolean plop(String featureName, ServerWorld world, BlockPos pos) + { + Thing custom = featureMap.get(featureName); + if (custom != null) + { + return custom.plop(world, pos); + } + Identifier id = new Identifier(featureName); + ConfiguredStructureFeature structureFeature = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.get(id); + if (structureFeature != null) + { + return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere( + world, pos, world.getChunkManager().getChunkGenerator(), + false, Biomes.PLAINS, structureFeature.config); + + } + + ConfiguredFeature feature = BuiltinRegistries.CONFIGURED_FEATURE.get(id); + if (feature != null) + { + CarpetSettings.skipGenerationChecks = true; + try + { + return feature.generate(world, world.getChunkManager().getChunkGenerator(), world.random, pos); + } + finally + { + CarpetSettings.skipGenerationChecks = false; + } + } + return null; + } + + public static ConfiguredStructureFeature resolveConfiguredStructure(String name, ServerWorld world, BlockPos pos) + { + Identifier id = new Identifier(name); + ConfiguredStructureFeature configuredStructureFeature = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.get(id); + if (configuredStructureFeature != null) return configuredStructureFeature; + StructureFeature structureFeature = Registry.STRUCTURE_FEATURE.get(id); + if (structureFeature == null) return null; + return getDefaultFeature(structureFeature, world, pos, true); + + // optionally fish out + + } + + synchronized public static Boolean plopGrid(ConfiguredStructureFeature structureFeature, ServerWorld world, BlockPos pos) + { + return ((StructureFeatureInterface)structureFeature.feature).plopAnywhere( + world, pos, world.getChunkManager().getChunkGenerator(), + true, Biomes.PLAINS, structureFeature.config); + } + @FunctionalInterface private interface Thing { @@ -80,10 +111,6 @@ public class FeatureGenerator } }; } - private static Thing simplePlop(Feature feature) - { - return simplePlop(feature.configure(FeatureConfig.DEFAULT)); - } private static Thing simpleTree(TreeFeatureConfig config) { @@ -91,11 +118,6 @@ public class FeatureGenerator return simplePlop(Feature.TREE.configure(config)); } - private static Thing simplePatch(RandomPatchFeatureConfig config) - { - return simplePlop(Feature.RANDOM_PATCH.configure(config)); - } - private static Thing spawnCustomStructure(StructureFeature structure, FeatureConfig conf, Biome biome) { return setupCustomStructure(structure, conf, biome, false); @@ -115,235 +137,103 @@ public class FeatureGenerator return featureMap.get(name).plop(world, pos); return null; } - public static void noop() {System.out.println("boo");} - public static Boolean gridStructure(String name, ServerWorld world, BlockPos pos) + private static ConfiguredStructureFeature getDefaultFeature(StructureFeature structure, ServerWorld world, BlockPos pos, boolean tryHard) { - if (gridMap.containsKey(name)) - return gridMap.get(name).plop(world, pos); - return null; + ConfiguredStructureFeature configuredFeature = world.getBiome(pos).method_28405(structure.configure(null)); + if (configuredFeature.config != null || !tryHard) return configuredFeature; + return BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getEntries().stream(). + filter(cS -> cS.getValue().feature == structure). + findFirst().map(Map.Entry::getValue).orElse(null); } + public static StructureStart shouldStructureStartAt(ServerWorld world, BlockPos pos, StructureFeature structure, boolean computeBox) { long seed = world.getSeed(); ChunkGenerator generator = world.getChunkManager().getChunkGenerator(); - StructureConfig params = generator.getConfig().method_28600(structure); + StructureConfig params = generator.getConfig().getForType(structure); if (!generator.getBiomeSource().hasStructureFeature(structure)) return null; BiomeAccess biomeAccess = world.getBiomeAccess().withSource(generator.getBiomeSource()); ChunkRandom chunkRandom = new ChunkRandom(); ChunkPos chunkPos = new ChunkPos(pos); Biome biome = biomeAccess.getBiome(new BlockPos(chunkPos.getStartX() + 9, 0, chunkPos.getStartZ() + 9)); - ConfiguredStructureFeature configuredFeature = ((BiomeInterface)biome).getConfiguredFeature(structure); - if (configuredFeature == null) return null; - ChunkPos chunkPos2 = structure.method_27218(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess - if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.field_24836)) // should start at + ConfiguredStructureFeature configuredFeature = biome.method_28405(structure.configure(null)); + if (configuredFeature == null || configuredFeature.config == null) return null; + ChunkPos chunkPos2 = structure.getStartChunk(params, seed, chunkRandom, chunkPos.x, chunkPos.z); //find some chunk I guess + if (chunkPos.x == chunkPos2.x && chunkPos.z == chunkPos2.z && ((StructureFeatureInterface)structure).shouldStartPublicAt(generator, generator.getBiomeSource(), seed, chunkRandom, chunkPos.x, chunkPos.z, biome, chunkPos, configuredFeature.config)) // should start at { if (!computeBox) return StructureStart.DEFAULT; StructureManager manager = world.getStructureManager(); - StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.field_24835, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed); - structureStart3.init(generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.field_24836); + StructureStart structureStart3 = structure.getStructureStartFactory().create((StructureFeature) configuredFeature.feature, chunkPos.x, chunkPos.z, BlockBox.empty(), 0, seed); + structureStart3.init(world.method_30349(), generator, manager, chunkPos.x, chunkPos.z, biome, (T) configuredFeature.config); if (!structureStart3.hasChildren()) return null; return structureStart3; } return null; } - - public static final Map, List> structureToFeature = new HashMap<>(); - public static final Map> featureToStructure = new HashMap<>(); - static - { - structureToFeature.put(StructureFeature.MONUMENT, Collections.singletonList("monument")); - structureToFeature.put(StructureFeature.END_CITY, Collections.singletonList("end_city")); - structureToFeature.put(StructureFeature.OCEAN_RUIN, Arrays.asList("ocean_ruin", "ocean_ruin_warm", "ocean_ruin_small", "ocean_ruin_warm_small", "ocean_ruin_tall", "ocean_ruin_warm_tall")); - structureToFeature.put(StructureFeature.VILLAGE, Arrays.asList("village", "village_desert", "village_savanna", "village_taiga", "village_snowy")); - structureToFeature.put(StructureFeature.MANSION, Collections.singletonList("mansion")); - structureToFeature.put(StructureFeature.BURIED_TREASURE, Collections.singletonList("treasure")); - structureToFeature.put(StructureFeature.SWAMP_HUT, Collections.singletonList("witch_hut")); - structureToFeature.put(StructureFeature.STRONGHOLD, Collections.singletonList("stronghold")); - structureToFeature.put(StructureFeature.DESERT_PYRAMID, Collections.singletonList("desert_temple")); - structureToFeature.put(StructureFeature.JUNGLE_PYRAMID, Collections.singletonList("jungle_temple")); - structureToFeature.put(StructureFeature.SHIPWRECK, Arrays.asList("shipwreck", "shipwreck2")); - structureToFeature.put(StructureFeature.PILLAGER_OUTPOST, Collections.singletonList("pillager_outpost")); - structureToFeature.put(StructureFeature.MINESHAFT, Arrays.asList("mineshaft", "mineshaft_mesa")); - structureToFeature.put(StructureFeature.IGLOO, Collections.singletonList("igloo")); - structureToFeature.put(StructureFeature.FORTRESS, Collections.singletonList("fortress")); - structureToFeature.put(StructureFeature.NETHER_FOSSIL, Collections.singletonList("nether_fossil")); - structureToFeature.put(StructureFeature.BASTION_REMNANT, Arrays.asList("bastion_remnant", "bastion_remnant_housing", "bastion_remnant_stable", "bastion_remnant_treasure", "bastion_remnant_bridge")); - structureToFeature.put(StructureFeature.RUINED_PORTAL, Collections.singletonList("ruined_portal")); - - structureToFeature.forEach((key, value) -> value.forEach(el -> featureToStructure.put(el, key))); - } - - - private static final Map gridMap = new HashMap() {{ - put("monument", ((StructureFeatureInterface)StructureFeature.MONUMENT)::gridAnywhere); - put("fortress", ((StructureFeatureInterface)StructureFeature.FORTRESS)::gridAnywhere); - put("mansion", ((StructureFeatureInterface)StructureFeature.MANSION)::gridAnywhere); - put("jungle_temple", ((StructureFeatureInterface)StructureFeature.JUNGLE_PYRAMID)::gridAnywhere); - put("desert_temple", ((StructureFeatureInterface)StructureFeature.DESERT_PYRAMID)::gridAnywhere); - put("end_city", ((StructureFeatureInterface)StructureFeature.END_CITY)::gridAnywhere); - put("igloo", ((StructureFeatureInterface)StructureFeature.IGLOO)::gridAnywhere); - put("shipwreck", gridCustomStructure(StructureFeature.SHIPWRECK, new ShipwreckFeatureConfig(true), Biomes.PLAINS)); - put("shipwreck2", gridCustomStructure(StructureFeature.SHIPWRECK, new ShipwreckFeatureConfig(false), Biomes.PLAINS)); - put("witch_hut", ((StructureFeatureInterface)StructureFeature.SWAMP_HUT)::gridAnywhere); - put("stronghold", ((StructureFeatureInterface)StructureFeature.STRONGHOLD)::gridAnywhere); - - put("ocean_ruin_small", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 0.0F, 0.5F), Biomes.PLAINS)); - put("ocean_ruin_warm_small", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 0.0F, 0.5F), Biomes.PLAINS)); - put("ocean_ruin_tall", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 1.0F, 0.0F), Biomes.PLAINS)); - put("ocean_ruin_warm_tall", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 1.0F, 0.0F), Biomes.PLAINS)); - put("ocean_ruin", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 1.0F, 1.0F), Biomes.PLAINS)); - put("ocean_ruin_warm", gridCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 1.0F, 1.0F), Biomes.PLAINS)); - put("treasure", ((StructureFeatureInterface)StructureFeature.BURIED_TREASURE)::gridAnywhere); - - put("pillager_outpost", ((StructureFeatureInterface)StructureFeature.PILLAGER_OUTPOST)::gridAnywhere); - - - put("mineshaft", gridCustomStructure(StructureFeature.MINESHAFT, new MineshaftFeatureConfig(0.0, MineshaftFeature.Type.NORMAL), Biomes.PLAINS)); - put("mineshaft_mesa", gridCustomStructure(StructureFeature.MINESHAFT, new MineshaftFeatureConfig(0.0, MineshaftFeature.Type.MESA), Biomes.PLAINS)); - - put("village", gridCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/plains/town_centers"),6), Biomes.PLAINS)); - put("village_desert", gridCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/desert/town_centers"), 6), Biomes.PLAINS)); - put("village_savanna", gridCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/savanna/town_centers"), 6), Biomes.PLAINS)); - put("village_taiga", gridCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/taiga/town_centers"), 6), Biomes.PLAINS)); - put("village_snowy", gridCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/snowy/town_centers"), 6), Biomes.PLAINS)); - put("nether_fossil", ((StructureFeatureInterface)StructureFeature.NETHER_FOSSIL)::gridAnywhere); - put("bastion_remnant", gridCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(BastionRemnantGenerator.START_POOLS_TO_SIZES), Biomes.NETHER_WASTES)); - put("bastion_remnant_housing", gridCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/units/base", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_stable", gridCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/hoglin_stable/origin", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_treasure", gridCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/treasure/starters", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_bridge", gridCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/bridge/start", 60).build()), Biomes.NETHER_WASTES)); - }}; - private static final Map featureMap = new HashMap() {{ - - - put("oak", simpleTree(OAK_TREE_CONFIG)); - put("oak_beehive", simpleTree( - (OAK_TREE_CONFIG.setTreeDecorators((ImmutableList.of(new BeehiveTreeDecorator(1.0F)))) - ))); - put("oak_large", simpleTree(DefaultBiomeFeatures.FANCY_TREE_CONFIG)); - put("oak_large_beehive", simpleTree( - FANCY_TREE_CONFIG.setTreeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))))); - put("birch", simpleTree(DefaultBiomeFeatures.BIRCH_TREE_CONFIG)); - put("birch_large", simpleTree(DefaultBiomeFeatures.LARGE_BIRCH_TREE_CONFIG)); - put("shrub", simpleTree(DefaultBiomeFeatures.JUNGLE_GROUND_BUSH_CONFIG)); - put("jungle", simpleTree(DefaultBiomeFeatures.JUNGLE_TREE_CONFIG)); - put("jungle_large", simpleTree(DefaultBiomeFeatures.MEGA_JUNGLE_TREE_CONFIG)); - put("spruce", simpleTree(DefaultBiomeFeatures.SPRUCE_TREE_CONFIG)); - put("spruce_large", simpleTree(DefaultBiomeFeatures.MEGA_SPRUCE_TREE_CONFIG)); - put("pine", simpleTree(DefaultBiomeFeatures.PINE_TREE_CONFIG)); - put("pine_large", simpleTree(DefaultBiomeFeatures.MEGA_PINE_TREE_CONFIG)); - put("dark_oak", simpleTree(DefaultBiomeFeatures.DARK_OAK_TREE_CONFIG)); - put("acacia", simpleTree(DefaultBiomeFeatures.ACACIA_TREE_CONFIG)); - put("oak_swamp", simpleTree(DefaultBiomeFeatures.SWAMP_TREE_CONFIG)); - put("well", simplePlop(Feature.DESERT_WELL)); - put("grass", simplePatch(DefaultBiomeFeatures.GRASS_CONFIG)); - put("tall_grass", simplePatch(DefaultBiomeFeatures.TALL_GRASS_CONFIG)); - - put("lush_grass", simplePatch(DefaultBiomeFeatures.LUSH_GRASS_CONFIG)); - put("fern", simplePatch(DefaultBiomeFeatures.LARGE_FERN_CONFIG)); - - - put("cactus", simplePatch(DefaultBiomeFeatures.CACTUS_CONFIG)); - put("dead_bush", simplePatch(DefaultBiomeFeatures.DEAD_BUSH_CONFIG)); - put("fossils", simplePlop(Feature.FOSSIL)); // spawn above, spawn invisible - put("mushroom_brown", simplePlop(Feature.HUGE_BROWN_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG))); - put("mushroom_red", simplePlop(Feature.HUGE_RED_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG))); - put("ice_spike", simplePlop(Feature.ICE_SPIKE)); - put("glowstone", simplePlop(Feature.GLOWSTONE_BLOB)); - put("melon", simplePatch(DefaultBiomeFeatures.MELON_PATCH_CONFIG)); - put("melon_pile", simplePlop(Feature.BLOCK_PILE.configure(DefaultBiomeFeatures.MELON_PILE_CONFIG))); - put("pumpkin", simplePatch(DefaultBiomeFeatures.PUMPKIN_PATCH_CONFIG)); - put("pumpkin_pile", simplePlop(Feature.BLOCK_PILE.configure(DefaultBiomeFeatures.PUMPKIN_PILE_CONFIG))); - put("sugarcane", simplePatch(DefaultBiomeFeatures.SUGAR_CANE_CONFIG)); - put("lilypad", simplePatch(DefaultBiomeFeatures.LILY_PAD_CONFIG)); - put("dungeon", simplePlop(Feature.MONSTER_ROOM)); - put("iceberg", simplePlop(Feature.ICEBERG.configure(new SingleStateFeatureConfig(Blocks.PACKED_ICE.getDefaultState())))); - put("iceberg_blue", simplePlop(Feature.ICEBERG.configure(new SingleStateFeatureConfig(Blocks.BLUE_ICE.getDefaultState())))); - put("lake", simplePlop(Feature.LAKE.configure(new SingleStateFeatureConfig(Blocks.WATER.getDefaultState())))); - put("lake_lava", simplePlop(Feature.LAKE.configure(new SingleStateFeatureConfig(Blocks.LAVA.getDefaultState())))); - //put("end tower", simplePlop(Feature.END_SPIKE.configure(new EndSpikeFeatureConfig(false, )))); - put("end_island", simplePlop(Feature.END_ISLAND)); - put("chorus", simplePlop(Feature.CHORUS_PLANT)); - put("sea_grass", simplePlop(Feature.SEAGRASS.configure( new SeagrassFeatureConfig(80, 0.8D)))); - put("sea_grass_river", simplePlop(Feature.SEAGRASS.configure( new SeagrassFeatureConfig(48, 0.4D)))); - put("kelp", simplePlop(Feature.KELP)); - put("coral_tree", simplePlop(Feature.CORAL_TREE)); - put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM)); - put("coral_claw", simplePlop(Feature.CORAL_CLAW)); - put("coral", (w, p) -> - w.random.nextInt(3)!=0? - (w.random.nextInt(2)!=0? - simplePlop(Feature.CORAL_MUSHROOM).plop(w, p): - simplePlop(Feature.CORAL_TREE).plop(w, p)) - :simplePlop(Feature.CORAL_CLAW).plop(w, p)); - put("sea_pickle", simplePlop(Feature.SEA_PICKLE.configure( new SeaPickleFeatureConfig(20)))); - put("boulder", simplePlop(Feature.FOREST_ROCK.configure( new ForestRockFeatureConfig(Blocks.MOSSY_COBBLESTONE.getDefaultState(), 0)))); - put("crimson_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.CRIMSON_FUNGUS_NOT_PLANTED_CONFIG))); - put("warped_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.WARPED_FUNGUS_NOT_PLANTED_CONFIG))); - put("nether_sprouts", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.NETHER_SPROUTS_CONFIG))); - put("crimson_roots", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.CRIMSON_ROOTS_CONFIG))); - put("warped_roots", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.WARPED_ROOTS_CONFIG))); - put("weeping_vines", simplePlop(Feature.WEEPING_VINES)); - put("twisting_vines", simplePlop(Feature.TWISTING_VINES)); - put("basalt_pillar", simplePlop(Feature.BASALT_PILLAR)); - - //structures - put("monument", ((StructureFeatureInterface)StructureFeature.MONUMENT)::plopAnywhere); - put("fortress", ((StructureFeatureInterface)StructureFeature.FORTRESS)::plopAnywhere); - put("mansion", ((StructureFeatureInterface)StructureFeature.MANSION)::plopAnywhere); - put("jungle_temple", ((StructureFeatureInterface)StructureFeature.JUNGLE_PYRAMID)::plopAnywhere); - put("desert_temple", ((StructureFeatureInterface)StructureFeature.DESERT_PYRAMID)::plopAnywhere); - put("end_city", ((StructureFeatureInterface)StructureFeature.END_CITY)::plopAnywhere); - put("igloo", ((StructureFeatureInterface)StructureFeature.IGLOO)::plopAnywhere); - put("shipwreck", spawnCustomStructure(StructureFeature.SHIPWRECK, new ShipwreckFeatureConfig(true), Biomes.PLAINS)); - put("shipwreck2", spawnCustomStructure(StructureFeature.SHIPWRECK, new ShipwreckFeatureConfig(false), Biomes.PLAINS)); - put("witch_hut", ((StructureFeatureInterface)StructureFeature.SWAMP_HUT)::plopAnywhere); - put("stronghold", ((StructureFeatureInterface)StructureFeature.STRONGHOLD)::plopAnywhere); - - put("ocean_ruin_small", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 0.0F, 0.5F), Biomes.PLAINS)); - put("ocean_ruin_warm_small", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 0.0F, 0.5F), Biomes.PLAINS)); - put("ocean_ruin_tall", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 1.0F, 0.0F), Biomes.PLAINS)); - put("ocean_ruin_warm_tall", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 1.0F, 0.0F), Biomes.PLAINS)); - put("ocean_ruin", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.COLD, 1.0F, 1.0F), Biomes.PLAINS)); - put("ocean_ruin_warm", spawnCustomStructure(StructureFeature.OCEAN_RUIN, - new OceanRuinFeatureConfig(OceanRuinFeature.BiomeType.WARM, 1.0F, 1.0F), Biomes.PLAINS)); - put("treasure", ((StructureFeatureInterface)StructureFeature.BURIED_TREASURE)::plopAnywhere); - - put("pillager_outpost", ((StructureFeatureInterface)StructureFeature.PILLAGER_OUTPOST)::plopAnywhere); - - - put("mineshaft", spawnCustomStructure(StructureFeature.MINESHAFT, new MineshaftFeatureConfig(0.0, MineshaftFeature.Type.NORMAL), Biomes.PLAINS)); - put("mineshaft_mesa", spawnCustomStructure(StructureFeature.MINESHAFT, new MineshaftFeatureConfig(0.0, MineshaftFeature.Type.MESA), Biomes.PLAINS)); - - put("village", spawnCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/plains/town_centers"),6), Biomes.PLAINS)); - put("village_desert", spawnCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/desert/town_centers"), 6), Biomes.PLAINS)); - put("village_savanna", spawnCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/savanna/town_centers"), 6), Biomes.PLAINS)); - put("village_taiga", spawnCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/taiga/town_centers"), 6), Biomes.PLAINS)); - put("village_snowy", spawnCustomStructure(StructureFeature.VILLAGE, new StructurePoolFeatureConfig(new Identifier("village/snowy/town_centers"), 6), Biomes.PLAINS)); - put("nether_fossil", ((StructureFeatureInterface)StructureFeature.NETHER_FOSSIL)::plopAnywhere); - put("bastion_remnant", spawnCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(BastionRemnantGenerator.START_POOLS_TO_SIZES), Biomes.NETHER_WASTES)); - put("bastion_remnant_housing", spawnCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/units/base", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_stable", spawnCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/hoglin_stable/origin", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_treasure", spawnCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/treasure/starters", 60).build()), Biomes.NETHER_WASTES)); - put("bastion_remnant_bridge", spawnCustomStructure(StructureFeature.BASTION_REMNANT, new BastionRemnantFeatureConfig(new ImmutableMap.Builder().put("bastion/bridge/start", 60).build()), Biomes.NETHER_WASTES)); - put("ruined_portal", ((StructureFeatureInterface)StructureFeature.RUINED_PORTAL)::plopAnywhere); - + put("oak_bees", simpleTree(ConfiguredFeatures.OAK.method_30381().setTreeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))))); + put("fancy_oak_bees", simpleTree(ConfiguredFeatures.FANCY_OAK.method_30381().setTreeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))))); + put("birch_bees", simpleTree(ConfiguredFeatures.BIRCH.method_30381().setTreeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))))); + put("coral_tree", simplePlop(Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT))); + put("coral_claw", simplePlop(Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT))); + put("coral_mushroom", simplePlop(Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT))); + put("coral", simplePlop(Feature.SIMPLE_RANDOM_SELECTOR.configure(new SimpleRandomFeatureConfig(ImmutableList.of( + () -> Feature.CORAL_TREE.configure(FeatureConfig.DEFAULT), + () -> Feature.CORAL_CLAW.configure(FeatureConfig.DEFAULT), + () -> Feature.CORAL_MUSHROOM.configure(FeatureConfig.DEFAULT) + ))))); + put("bastion_remnant_units", spawnCustomStructure( + StructureFeature.BASTION_REMNANT, + new StructurePoolFeatureConfig(() -> new StructurePool( + new Identifier("bastion/starts"), + new Identifier("empty"), + ImmutableList.of( + Pair.of(StructurePoolElement.method_30435("bastion/units/air_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + ), + StructurePool.Projection.RIGID + ), 6), + Biomes.NETHER_WASTES + )); + put("bastion_remnant_hoglin_stable", spawnCustomStructure( + StructureFeature.BASTION_REMNANT, + new StructurePoolFeatureConfig(() -> new StructurePool( + new Identifier("bastion/starts"), + new Identifier("empty"), + ImmutableList.of( + Pair.of(StructurePoolElement.method_30435("bastion/hoglin_stable/air_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + ), + StructurePool.Projection.RIGID + ), 6), + Biomes.NETHER_WASTES + )); + put("bastion_remnant_treasure", spawnCustomStructure( + StructureFeature.BASTION_REMNANT, + new StructurePoolFeatureConfig(() -> new StructurePool( + new Identifier("bastion/starts"), + new Identifier("empty"), + ImmutableList.of( + Pair.of(StructurePoolElement.method_30435("bastion/treasure/big_air_full", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + ), + StructurePool.Projection.RIGID + ), 6), + Biomes.NETHER_WASTES + )); + put("bastion_remnant_bridge", spawnCustomStructure( + StructureFeature.BASTION_REMNANT, + new StructurePoolFeatureConfig(() -> new StructurePool( + new Identifier("bastion/starts"), + new Identifier("empty"), + ImmutableList.of( + Pair.of(StructurePoolElement.method_30435("bastion/bridge/starting_pieces/entrance_base", ProcessorLists.BASTION_GENERIC_DEGRADATION), 1) + ), + StructurePool.Projection.RIGID + ), 6), + Biomes.NETHER_WASTES + )); }}; } diff --git a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java index ea28e41c..2fdfa29e 100644 --- a/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java +++ b/src/main/java/carpet/mixins/BastionRemnantFeatureMixin.java @@ -4,28 +4,29 @@ import carpet.CarpetSettings; import com.google.common.collect.Lists; import com.mojang.serialization.Codec; +import net.minecraft.class_5434; import net.minecraft.entity.EntityType; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.BastionRemnantFeature; -import net.minecraft.world.gen.feature.BastionRemnantFeatureConfig; -import net.minecraft.world.gen.feature.StructureFeature; +import net.minecraft.world.gen.feature.StructurePoolFeatureConfig; import org.spongepowered.asm.mixin.Mixin; import java.util.Collections; import java.util.List; @Mixin(BastionRemnantFeature.class) -public abstract class BastionRemnantFeatureMixin extends StructureFeature { - +public abstract class BastionRemnantFeatureMixin extends class_5434 +{ private static final List spawnList = Lists.newArrayList( new Biome.SpawnEntry(EntityType.PIGLIN_BRUTE, 5, 1, 2), new Biome.SpawnEntry(EntityType.PIGLIN, 10, 2, 4), new Biome.SpawnEntry(EntityType.HOGLIN, 2, 1, 2) ); - public BastionRemnantFeatureMixin(Codec codec) { - super(codec); + public BastionRemnantFeatureMixin(Codec codec, int i, boolean bl, boolean bl2) + { + super(codec, i, bl, bl2); } @Override diff --git a/src/main/java/carpet/mixins/Biome_scarpetMixin.java b/src/main/java/carpet/mixins/Biome_scarpetMixin.java index 0ce5f1ce..305bd022 100644 --- a/src/main/java/carpet/mixins/Biome_scarpetMixin.java +++ b/src/main/java/carpet/mixins/Biome_scarpetMixin.java @@ -11,13 +11,14 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Map; @Mixin(Biome.class) -public class Biome_scarpetMixin implements BiomeInterface +public class Biome_scarpetMixin { - @Shadow @Final private Map, ConfiguredStructureFeature> structureFeatures; - + //@Shadow @Final private Map, ConfiguredStructureFeature> structureFeatures; +/* @Override public ConfiguredStructureFeature getConfiguredFeature(StructureFeature arg) { - return structureFeatures.get(arg); - } + return null; + // return structureFeatures.get(arg); + }*/ } diff --git a/src/main/java/carpet/mixins/ChunkGeneratorMixin.java b/src/main/java/carpet/mixins/ChunkGeneratorMixin.java index 9d63b47d..b7e5f091 100644 --- a/src/main/java/carpet/mixins/ChunkGeneratorMixin.java +++ b/src/main/java/carpet/mixins/ChunkGeneratorMixin.java @@ -15,12 +15,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ChunkGenerator.class) public abstract class ChunkGeneratorMixin implements ChunkGeneratorInterface { - @Shadow protected abstract void method_28509(); + @Shadow protected abstract void generateStrongholdPositions(); @Override public void initStrongholds() { - method_28509(); + generateStrongholdPositions(); } // this might not be needed anymore /* diff --git a/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java b/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java index 9a68c6bb..29b9a16b 100644 --- a/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java +++ b/src/main/java/carpet/mixins/ClientPlayNetworkHandler_smoothClientAnimationsMixin.java @@ -10,6 +10,7 @@ import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket; import net.minecraft.client.world.ClientWorld; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.biome.source.BiomeArray; import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -31,7 +32,7 @@ public class ClientPlayNetworkHandler_smoothClientAnimationsMixin shift = At.Shift.AFTER )) private void recreateMovingPistons(ChunkDataS2CPacket packet, CallbackInfo ci, - int i, int j, WorldChunk worldChunk, Iterator var5, CompoundTag tag, BlockPos blockPos) + int i, int j, BiomeArray biomeArray, WorldChunk worldChunk, Iterator var5, CompoundTag tag, BlockPos blockPos) { if (CarpetSettings.smoothClientAnimations) { diff --git a/src/main/java/carpet/mixins/Entity_portalSuffocationMixin.java b/src/main/java/carpet/mixins/Entity_portalSuffocationMixin.java index 4f1676a0..3323e2c0 100644 --- a/src/main/java/carpet/mixins/Entity_portalSuffocationMixin.java +++ b/src/main/java/carpet/mixins/Entity_portalSuffocationMixin.java @@ -15,6 +15,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Entity.class) public abstract class Entity_portalSuffocationMixin { + // FIXED IN 20w28a + /* @Shadow public abstract Box getBoundingBox(); @Inject(method = "changeDimension", at = @At( @@ -48,4 +50,6 @@ public abstract class Entity_portalSuffocationMixin CarpetSettings.currentTelepotingEntityBox = null; CarpetSettings.fixedPosition = null; } + + */ } diff --git a/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java b/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java index ff32165b..7b10e3fe 100644 --- a/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java +++ b/src/main/java/carpet/mixins/PortalForcer_portalSuffocationMixin.java @@ -18,6 +18,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PortalForcer.class) public class PortalForcer_portalSuffocationMixin { + //FIXED IN 20w28a + /* @Inject(method = "usePortal", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getLastNetherPortalDirectionVector()Lnet/minecraft/util/math/Vec3d;" @@ -84,4 +86,6 @@ public class PortalForcer_portalSuffocationMixin CarpetSettings.fixedPosition = target.pos; return target; } + + */ } diff --git a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java index d05cebaf..5a774d68 100644 --- a/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerEntity_scarpetEventMixin.java @@ -92,25 +92,25 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity private Vec3d previousLocation; private RegistryKey previousDimension; - @Inject(method = "changeDimension", at = @At("HEAD")) + @Inject(method = "moveToWorld", at = @At("HEAD")) private void logPreviousCoordinates(ServerWorld serverWorld, CallbackInfoReturnable cir) { previousLocation = getPos(); previousDimension = world.getRegistryKey(); //dimension type } - @Inject(method = "changeDimension", at = @At("RETURN")) - private void atChangeDimension(ServerWorld newWorld, CallbackInfoReturnable cir) + @Inject(method = "moveToWorld", at = @At("RETURN")) + private void atChangeDimension(ServerWorld destination, CallbackInfoReturnable cir) { if (PLAYER_CHANGES_DIMENSION.isNeeded()) { ServerPlayerEntity player = (ServerPlayerEntity) (Object)this; Vec3d to = null; - if (!notInAnyWorld || previousDimension != World.END || newWorld.getRegistryKey() != World.OVERWORLD) // end ow + if (!notInAnyWorld || previousDimension != World.END || destination.getRegistryKey() != World.OVERWORLD) // end ow { to = getPos(); } - PLAYER_CHANGES_DIMENSION.onDimensionChange(player, previousLocation, to, previousDimension, newWorld.getRegistryKey()); + PLAYER_CHANGES_DIMENSION.onDimensionChange(player, previousLocation, to, previousDimension, destination.getRegistryKey()); } } diff --git a/src/main/java/carpet/mixins/ServerWorld_unloadedEntityMixin.java b/src/main/java/carpet/mixins/ServerWorld_unloadedEntityMixin.java index a2a1c080..e9a70ba2 100644 --- a/src/main/java/carpet/mixins/ServerWorld_unloadedEntityMixin.java +++ b/src/main/java/carpet/mixins/ServerWorld_unloadedEntityMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ServerWorld.class) public class ServerWorld_unloadedEntityMixin { - @Redirect(method = "checkChunk", at = @At( + @Redirect(method = "checkEntityChunkPos", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/Entity;teleportRequested()Z" )) diff --git a/src/main/java/carpet/mixins/StructureFeatureMixin.java b/src/main/java/carpet/mixins/StructureFeatureMixin.java index 39512007..ab707594 100644 --- a/src/main/java/carpet/mixins/StructureFeatureMixin.java +++ b/src/main/java/carpet/mixins/StructureFeatureMixin.java @@ -135,7 +135,7 @@ public abstract class StructureFeatureMixin implements StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,worldIn.getSeed()); if (config == null) config = new DefaultFeatureConfig(); - structurestart1.init(generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config); + structurestart1.init(worldIn.method_30349(), generator, worldIn.getStructureManager() , chunkpos.x, chunkpos.z, biome_1, config); structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; if (structurestart.hasChildren()) diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index a3909e6d..93e8c9f6 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -8,12 +8,10 @@ import carpet.fakes.IngredientInterface; import carpet.fakes.MinecraftServerInterface; import carpet.fakes.RecipeManagerInterface; import carpet.fakes.ServerChunkManagerInterface; -import carpet.fakes.ServerLightingProviderInterface; import carpet.fakes.SpawnHelperInnerInterface; import carpet.fakes.StatTypeInterface; import carpet.fakes.ThreadedAnvilChunkStorageInterface; import carpet.helpers.FeatureGenerator; -import carpet.mixins.ChunkGeneratorMixin; import carpet.mixins.PointOfInterest_scarpetMixin; import carpet.script.Fluff.TriFunction; import carpet.script.argument.BlockArgument; @@ -130,6 +128,7 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.gen.chunk.ChunkGenerator; +import net.minecraft.world.gen.feature.ConfiguredStructureFeature; import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.SpawnHelper; import net.minecraft.world.poi.PointOfInterest; @@ -1086,7 +1085,9 @@ public class CarpetExpression ServerWorld world = cc.s.getWorld(); BlockPos pos = locator.block.getPos(); Biome biome = world.getBiome(pos); - Value res = new StringValue(biome.getTranslationKey().replaceFirst("^biome\\.minecraft\\.", "")); + // in locatebiome + Identifier biomeId = cc.s.getMinecraftServer().method_30611().method_30530(Registry.BIOME_KEY).getId(biome); + Value res = new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId)); return (_c, _t) -> res; }); @@ -1097,7 +1098,8 @@ public class CarpetExpression if (lv.size() == locator.offset) throw new InternalExpressionException("'set_biome' needs a biome name as an argument"); String biomeName = lv.get(locator.offset+0).evalValue(c).getString(); - Biome biome = Registry.BIOME.get(new Identifier(biomeName)); + // from locatebiome command code + Biome biome = cc.s.getMinecraftServer().method_30611().method_30530(Registry.BIOME_KEY).get(new Identifier(biomeName)); if (biome == null) throw new InternalExpressionException("Unknown biome: "+biomeName); boolean doImmediateUpdate = true; @@ -1132,13 +1134,13 @@ public class CarpetExpression //CarpetSettings.LOG.error(references.keySet().stream().collect(Collectors.joining(","))); List referenceList = references.entrySet().stream(). filter(e -> e.getValue()!= null && !e.getValue().isEmpty()). - map(e -> new StringValue(FeatureGenerator.structureToFeature.get(e.getKey()).get(0))).collect(Collectors.toList()); + map(e -> new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(e.getKey())))).collect(Collectors.toList()); return (_c, _t ) -> ListValue.wrap(referenceList); } String simpleStructureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT); //CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.keySet().stream().collect(Collectors.joining(","))); //CarpetSettings.LOG.error(FeatureGenerator.featureToStructure.values().stream().collect(Collectors.joining(","))); - StructureFeature structureName = FeatureGenerator.featureToStructure.get(simpleStructureName); + StructureFeature structureName = Registry.STRUCTURE_FEATURE.get(new Identifier(simpleStructureName)); if (structureName == null) return LazyValue.NULL; LongSet structureReferences = references.get(structureName); if (structureReferences == null || structureReferences.isEmpty()) return ListValue.lazyEmpty(); @@ -1168,7 +1170,7 @@ public class CarpetExpression if (!(requested instanceof NullValue)) { String reqString = requested.getString(); - structure = FeatureGenerator.featureToStructure.get(reqString); + structure = Registry.STRUCTURE_FEATURE.get(new Identifier(reqString)); if (structure == null) throw new InternalExpressionException("Unknown structure: " + reqString); } if (lv.size() > locator.offset+1) @@ -1190,7 +1192,7 @@ public class CarpetExpression StructureStart start = FeatureGenerator.shouldStructureStartAt(world, pos, str, needSize); if (start == null) continue; - Value key = new StringValue(FeatureGenerator.structureToFeature.get(str).get(0)); + Value key = new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(str))); ret.put(key, (!needSize)?Value.NULL:structureToValue(start)); } Value retMap = MapValue.wrap(ret); @@ -1214,7 +1216,7 @@ public class CarpetExpression continue; BlockBox box = start.getBoundingBox(); structureList.put( - new StringValue(FeatureGenerator.structureToFeature.get(entry.getKey()).get(0)), + new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_FEATURE.getId(entry.getKey()))), ListValue.of(ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ)) ); } @@ -1222,7 +1224,7 @@ public class CarpetExpression return (_c, _t) -> ret; } String structureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT); - StructureStart start = structures.get(FeatureGenerator.featureToStructure.get(structureName)); + StructureStart start = structures.get(Registry.STRUCTURE_FEATURE.get(new Identifier(structureName))); Value ret = structureToValue(start); return (_c, _t) -> ret; }); @@ -1238,8 +1240,8 @@ public class CarpetExpression if (lv.size() == locator.offset) throw new InternalExpressionException("'set_structure requires at least position and a structure name"); String structureName = lv.get(locator.offset).evalValue(c).getString().toLowerCase(Locale.ROOT); - StructureFeature structureId = FeatureGenerator.featureToStructure.get(structureName); - if (structureId == null) throw new InternalExpressionException("Unknown structure: "+structureName); + ConfiguredStructureFeature configuredStructure = FeatureGenerator.resolveConfiguredStructure(structureName, world, pos); + if (configuredStructure == null) throw new InternalExpressionException("Unknown structure: "+structureName); // good 'ol pointer Value[] result = new Value[]{Value.NULL}; // technically a world modification. Even if we could let it slide, we will still park it @@ -1248,7 +1250,8 @@ public class CarpetExpression Map, StructureStart> structures = world.getChunk(pos).getStructureStarts(); if (lv.size() == locator.offset + 1) { - Boolean res = FeatureGenerator.gridStructure(structureName, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); + Boolean res = FeatureGenerator.plopGrid(configuredStructure, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); + //Boolean res = FeatureGenerator.gridStructure(structureName, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); if (res == null) return; result[0] = res?Value.TRUE:Value.FALSE; return; @@ -1256,11 +1259,12 @@ public class CarpetExpression Value newValue = lv.get(locator.offset+1).evalValue(c); if (newValue instanceof NullValue) // remove structure { - if (!structures.containsKey(structureId)) + StructureFeature structure = configuredStructure.feature; + if (!structures.containsKey(structure)) { return; } - StructureStart start = structures.get(structureId); + StructureStart start = structures.get(structure); ChunkPos structureChunkPos = new ChunkPos(start.getChunkX(), start.getChunkZ()); BlockBox box = start.getBoundingBox(); for (int chx = box.minX / 16; chx <= box.maxX / 16; chx++) @@ -1270,11 +1274,11 @@ public class CarpetExpression ChunkPos chpos = new ChunkPos(chx, chz); // getting a chunk will convert it to full, allowing to modify references Map, LongSet> references = world.getChunk(chpos.getCenterBlockPos()).getStructureReferences(); - if (references.containsKey(structureId) && references.get(structureId) != null) - references.get(structureId).remove(structureChunkPos.toLong()); + if (references.containsKey(structure) && references.get(structure) != null) + references.get(structure).remove(structureChunkPos.toLong()); } } - structures.remove(structureId); + structures.remove(structure); result[0] = Value.TRUE; } }); @@ -3136,7 +3140,7 @@ public class CarpetExpression { long newTime = NumericValue.asNumber(lv.get(0).evalValue(c)).getLong(); if (newTime < 0) newTime = 0; - ((CarpetContext) c).s.getWorld().method_29199(newTime);// setTimeOfDay(newTime); + ((CarpetContext) c).s.getWorld().setTimeOfDay(newTime);// setTimeOfDay(newTime); } return (cc, tt) -> time; }); @@ -3283,8 +3287,9 @@ public class CarpetExpression Value [] result = new Value[]{Value.NULL}; ((CarpetContext)c).s.getMinecraftServer().submitAndJoin( () -> { + Boolean res = FeatureGenerator.plop(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); - Boolean res = FeatureGenerator.spawn(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); + //Boolean res = FeatureGenerator.spawn(what, ((CarpetContext) c).s.getWorld(), locator.block.getPos()); if (res == null) return; if (what.equalsIgnoreCase("boulder")) // there might be more of those diff --git a/src/main/java/carpet/script/value/BlockValue.java b/src/main/java/carpet/script/value/BlockValue.java index 7579b267..e7bba07b 100644 --- a/src/main/java/carpet/script/value/BlockValue.java +++ b/src/main/java/carpet/script/value/BlockValue.java @@ -278,7 +278,11 @@ public class BlockValue extends Value @Override public BlockPos getBlockPos() { - return this.hit.getBlockPos(); + boolean prevcanReplaceExisting = canReplaceExisting; + canReplaceExisting = true; + BlockPos ret = super.getBlockPos(); + canReplaceExisting = prevcanReplaceExisting; + return ret; } @Override diff --git a/src/main/java/carpet/utils/Messenger.java b/src/main/java/carpet/utils/Messenger.java index 8c7a43b5..6c9daf75 100644 --- a/src/main/java/carpet/utils/Messenger.java +++ b/src/main/java/carpet/utils/Messenger.java @@ -166,7 +166,7 @@ public class Messenger { if (previous_message != null) previous_message.setStyle( - previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1)))) + previous_message.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1)))) ); return previous_message; } diff --git a/src/main/resources/assets/carpet/scripts/overlay.sc b/src/main/resources/assets/carpet/scripts/overlay.sc index 820282bc..7bba815f 100644 --- a/src/main/resources/assets/carpet/scripts/overlay.sc +++ b/src/main/resources/assets/carpet/scripts/overlay.sc @@ -27,20 +27,21 @@ __command() -> ''; monument() -> __toggle('monument', 'structures'); fortress() -> __toggle('fortress', 'structures'); mansion() -> __toggle('mansion', 'structures'); -jungle_temple() -> __toggle('jungle_temple', 'structures'); -desert_temple() -> __toggle('desert_temple', 'structures'); -end_city() -> __toggle('end_city', 'structures'); +jungle_pyramid() -> __toggle('jungle_pyramid', 'structures'); +desert_pyramid() -> __toggle('desert_pyramid', 'structures'); +endcity() -> __toggle('endcity', 'structures'); igloo() -> __toggle('igloo', 'structures'); shipwreck() -> __toggle('shipwreck', 'structures'); -witch_hut() -> __toggle('witch_hut', 'structures'); +swamp_hut() -> __toggle('swamp_hut', 'structures'); stronghold() -> __toggle('stronghold', 'structures'); ocean_ruin() -> __toggle('ocean_ruin', 'structures'); -treasure() -> __toggle('treasure', 'structures'); +buried_treasure() -> __toggle('buried_treasure', 'structures'); pillager_outpost() -> __toggle('pillager_outpost', 'structures'); mineshaft() -> __toggle('mineshaft', 'structures'); village() -> __toggle('village', 'structures'); nether_fossil() -> __toggle('nether_fossil', 'structures'); bastion_remnant() -> __toggle('bastion_remnant', 'structures'); +ruined_portal() -> __toggle('ruined_portal', 'structures'); slime_chunks() -> __toggle('slime_chunks', 'chunks');