Skip to content

Commit

Permalink
Enqueue some registrations
Browse files Browse the repository at this point in the history
Because parallel events are better when you cannot safely run basically anything in parallel
  • Loading branch information
KnightMiner committed Jun 15, 2021
1 parent 4d6c281 commit ef08cc7
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 83 deletions.
140 changes: 72 additions & 68 deletions src/main/java/slimeknights/tconstruct/world/TinkerStructures.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,78 +147,82 @@ public static void addStructureSeparation() {
*/
@SubscribeEvent
void commonSetup(FMLCommonSetupEvent event) {
addStructureToMap(earthSlimeIsland.get());
addStructureToMap(skySlimeIsland.get());
addStructureToMap(clayIsland.get());
addStructureToMap(bloodSlimeIsland.get());
addStructureToMap(endSlimeIsland.get());

// earth slime islands
EARTH_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("earth_slime_island"), earthSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
SKY_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("sky_slime_island"), skySlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
CLAY_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("clay_island"), clayIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
BLOOD_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("blood_slime_island"), bloodSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
END_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("end_slime_island"), endSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
event.enqueueWork(() -> {
addStructureToMap(earthSlimeIsland.get());
addStructureToMap(skySlimeIsland.get());
addStructureToMap(clayIsland.get());
addStructureToMap(bloodSlimeIsland.get());
addStructureToMap(endSlimeIsland.get());
});

// mark ready, so the config can also call that method
structureSettingsReady = true;
event.enqueueWork(TinkerStructures::addStructureSeparation);

EARTH_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("earth_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.EARTH).getDefaultState())
.baseHeight(4).randomHeight(3)
.build())));

SKY_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("sky_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.skyroot.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.SKY).getDefaultState())
.build())));
SKY_SLIME_ISLAND_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("sky_slime_island_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.skyroot.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.SKY).getDefaultState())
.vines(() -> TinkerWorld.skySlimeVine.get().getDefaultState().with(SlimeVineBlock.STAGE, VineStage.MIDDLE))
.build())));

ENDER_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ender_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState()) // TODO: temporary until we have proper green trees and ender shrooms
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ENDER).getDefaultState())
.build())));
ENDER_SLIME_ISLAND_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ender_slime_island_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState()) // TODO: temporary until we have proper green trees and ender shrooms
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ENDER).getDefaultState())
.vines(() -> TinkerWorld.enderSlimeVine.get().getDefaultState().with(SlimeVineBlock.STAGE, VineStage.MIDDLE))
.build())));

BLOOD_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("blood_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.bloodshroom.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.BLOOD).getDefaultState())
.baseHeight(7)
.build())));
ICHOR_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ichor_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.bloodshroom.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ICHOR).getDefaultState())
.build())));
event.enqueueWork(() -> {
EARTH_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("earth_slime_island"), earthSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
SKY_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("sky_slime_island"), skySlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
CLAY_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("clay_island"), clayIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
BLOOD_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("blood_slime_island"), bloodSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));
END_SLIME_ISLAND = WorldGenRegistries.register(WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE, location("end_slime_island"), endSlimeIsland.get().withConfiguration(NoFeatureConfig.field_236559_b_));

// trees
EARTH_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("earth_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.EARTH).getDefaultState())
.baseHeight(4).randomHeight(3)
.build())));

SKY_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("sky_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.skyroot.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.SKY).getDefaultState())
.build())));
SKY_SLIME_ISLAND_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("sky_slime_island_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.skyroot.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.SKY).getDefaultState())
.vines(() -> TinkerWorld.skySlimeVine.get().getDefaultState().with(SlimeVineBlock.STAGE, VineStage.MIDDLE))
.build())));

ENDER_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ender_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState()) // TODO: temporary until we have proper green trees and ender shrooms
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ENDER).getDefaultState())
.build())));
ENDER_SLIME_ISLAND_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ender_slime_island_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.greenheart.getLog().getDefaultState()) // TODO: temporary until we have proper green trees and ender shrooms
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ENDER).getDefaultState())
.vines(() -> TinkerWorld.enderSlimeVine.get().getDefaultState().with(SlimeVineBlock.STAGE, VineStage.MIDDLE))
.build())));

BLOOD_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("blood_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.bloodshroom.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.BLOOD).getDefaultState())
.baseHeight(7)
.build())));
ICHOR_SLIME_TREE = Registry.register(
WorldGenRegistries.CONFIGURED_FEATURE, location("ichor_slime_tree"),
SLIME_TREE.get().withConfiguration((
new BaseSlimeTreeFeatureConfig.Builder()
.trunk(() -> TinkerWorld.bloodshroom.getLog().getDefaultState())
.leaves(() -> TinkerWorld.slimeLeaves.get(SlimeType.ICHOR).getDefaultState())
.build())));
});
}
}
32 changes: 17 additions & 15 deletions src/main/java/slimeknights/tconstruct/world/TinkerWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,23 @@ void commonSetup(final FMLCommonSetupEvent event) {
});

// ores
COPPER_ORE_FEATURE = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("copper_ore"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.BASE_STONE_OVERWORLD, TinkerWorld.copperOre.get().getDefaultState(), 9))
.withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(40, 0, 60)))
.square()
.func_242731_b(Config.COMMON.veinCountCopper.get()));
// small veins, standard distribution
COBALT_ORE_FEATURE_SMALL = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("cobalt_ore_small"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.NETHERRACK, cobaltOre.get().getDefaultState(), 4))
.withPlacement(Features.Placements.NETHER_SPRING_ORE_PLACEMENT)
.square().func_242731_b(Config.COMMON.veinCountCobalt.get() / 2));
// large veins, around y=16, up to 48
COBALT_ORE_FEATURE_LARGE = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("cobalt_ore_large"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.NETHERRACK, cobaltOre.get().getDefaultState(), 8))
.withPlacement(Placement.DEPTH_AVERAGE.configure(new DepthAverageConfig(32, 16)))
.square().func_242731_b(Config.COMMON.veinCountCobalt.get() / 2));
event.enqueueWork(() -> {
COPPER_ORE_FEATURE = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("copper_ore"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.BASE_STONE_OVERWORLD, TinkerWorld.copperOre.get().getDefaultState(), 9))
.withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(40, 0, 60)))
.square()
.func_242731_b(Config.COMMON.veinCountCopper.get()));
// small veins, standard distribution
COBALT_ORE_FEATURE_SMALL = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("cobalt_ore_small"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.NETHERRACK, cobaltOre.get().getDefaultState(), 4))
.withPlacement(Features.Placements.NETHER_SPRING_ORE_PLACEMENT)
.square().func_242731_b(Config.COMMON.veinCountCobalt.get() / 2));
// large veins, around y=16, up to 48
COBALT_ORE_FEATURE_LARGE = Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, location("cobalt_ore_large"),
Feature.ORE.withConfiguration(new OreFeatureConfig(FillerBlockType.NETHERRACK, cobaltOre.get().getDefaultState(), 8))
.withPlacement(Placement.DEPTH_AVERAGE.configure(new DepthAverageConfig(32, 16)))
.square().func_242731_b(Config.COMMON.veinCountCobalt.get() / 2));
});
}

@SubscribeEvent
Expand Down

0 comments on commit ef08cc7

Please sign in to comment.