Skip to content

Commit

Permalink
Pass Entity to SpawnPlacement instead of Supplier
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph T. McQuigg <[email protected]>
  • Loading branch information
JT122406 committed Dec 20, 2024
1 parent 05495d2 commit a66322e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ private static <E extends Entity> Supplier<EntityType<E>> createEntity(String id

@SuppressWarnings("unchecked")
public static <T extends Mob> void registerSpawnPlacements(Consumer<SpawnPlacement<T>> consumer) {
consumer.accept((SpawnPlacement<T>) new SpawnPlacement<>(MAN_O_WAR, SpawnPlacementTypes.IN_WATER, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, ManOWar::checkManOWarSpawnRules));
consumer.accept((SpawnPlacement<T>) new SpawnPlacement<>(ODDION, SpawnPlacementTypes.ON_GROUND, Heightmap.Types.WORLD_SURFACE, Oddion::checkOddionSpawnRules));
consumer.accept((SpawnPlacement<T>) new SpawnPlacement<>(MAN_O_WAR.get(), SpawnPlacementTypes.IN_WATER, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, ManOWar::checkManOWarSpawnRules));
consumer.accept((SpawnPlacement<T>) new SpawnPlacement<>(ODDION.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.WORLD_SURFACE, Oddion::checkOddionSpawnRules));
}

public record SpawnPlacement<T extends Mob>(Supplier<EntityType<T>> entityType, SpawnPlacementType spawnPlacementType, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate<T> predicate) {}
public record SpawnPlacement<T extends Mob>(EntityType<T> entityType, SpawnPlacementType spawnPlacementType, Heightmap.Types heightmapType, SpawnPlacements.SpawnPredicate<T> predicate) {}

/**
* Registers Entity Attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void initializeBiomesWeveGone(String initializedFrom) {
BiomesWeveGone.init();
VanillaCompatFabric.init();
BWGEntities.registerEntityAttributes(FabricDefaultAttributeRegistry::register);
BWGEntities.registerSpawnPlacements((consumer) -> SpawnPlacements.register(consumer.entityType().get(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate()));
BWGEntities.registerSpawnPlacements((consumer) -> SpawnPlacements.register(consumer.entityType(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate()));
BiomesWeveGone.commonSetup();
BiomesWeveGone.postInit();
ServerLifecycleEvents.SERVER_STARTING.register(BiomesWeveGone::serverStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BiomesWeveGoneForge(final FMLJavaModLoadingContext context) {
MOD_BUS.addListener(this::onPostInitialize);
EVENT_BUS.addListener(this::onServerStarting);
MOD_BUS.addListener((EntityAttributeCreationEvent event) -> BWGEntities.registerEntityAttributes(event::put));
MOD_BUS.addListener((SpawnPlacementRegisterEvent event) -> BWGEntities.registerSpawnPlacements((consumer) -> event.register(consumer.entityType().get(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate(), SpawnPlacementRegisterEvent.Operation.OR)));
MOD_BUS.addListener((SpawnPlacementRegisterEvent event) -> BWGEntities.registerSpawnPlacements((consumer) -> event.register(consumer.entityType(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate(), SpawnPlacementRegisterEvent.Operation.OR)));
VanillaCompatForge.registerVanillaCompatEvents(EVENT_BUS);
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> BiomesWeveGoneClientForge.init(MOD_BUS));
LootModifiersRegister.register(MOD_BUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BiomesWeveGoneNeoForge(final IEventBus eventBus) {
eventBus.addListener(this::onPostInitialize);
EVENT_BUS.addListener(this::onServerStarting);
eventBus.addListener((EntityAttributeCreationEvent event) -> BWGEntities.registerEntityAttributes(event::put));
eventBus.addListener((RegisterSpawnPlacementsEvent event) -> BWGEntities.registerSpawnPlacements((consumer) -> event.register(consumer.entityType().get(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate(), RegisterSpawnPlacementsEvent.Operation.OR)));
eventBus.addListener((RegisterSpawnPlacementsEvent event) -> BWGEntities.registerSpawnPlacements((consumer) -> event.register(consumer.entityType(), consumer.spawnPlacementType(), consumer.heightmapType(), consumer.predicate(), RegisterSpawnPlacementsEvent.Operation.OR)));
VanillaCompatNeoForge.registerVanillaCompatEvents(EVENT_BUS);
LootModifiersRegister.register(eventBus);
}
Expand Down

0 comments on commit a66322e

Please sign in to comment.