Posted January 29, 20214 yr The new mob spawns properly when run from Intellij but not from the minecraft launcher using the jar. The strangest part is that the other two mobs I added spawn as expected in both cases. I have included the code used to register the spawns below. @Mod.EventBusSubscriber(modid = GreekMyths.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class EntitySpawning { @SubscribeEvent(priority = EventPriority.HIGH) public static void addBiomeSpawns(final BiomeLoadingEvent event) { if(event.getCategory() == Biome.Category.OCEAN) { addSpawns(event, ModEntities.HIPPOCAMPUS.get(), 100, 1, 2); } addSpawns(event, ModEntities.GREEKVILLAGER.get(), 100, 1, 3); addSpawns(event, ModEntities.PEGASUS.get(), 100, 1, 3); } private static void addSpawns(final BiomeLoadingEvent biome, final EntityType<?> entity, final int chance, final int min, final int max) { if (biome.getCategory() == Biome.Category.NETHER) { } else if (biome.getCategory() == Biome.Category.THEEND) { } else { biome.getSpawns().withSpawner(entity.getClassification(), new MobSpawnInfo.Spawners(entity, chance, min, max)); } } } Also, you are still able to summon the mob using commands. Any thoughts?
January 29, 20214 yr Author Another this to note is that the lang file doesn't seem to load from the jar file either. Not sure if that is related or not...
January 29, 20214 yr Which is the entity not spawning? Also, it would be easier to see what's wrong if you posted a link to your repository Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
January 29, 20214 yr Author I don't have a repo set up yet. It is the hippocampus entity which is not spawning. Here is the class which registers the entities if it is helpful. @Mod.EventBusSubscriber(modid = GreekMyths.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEntities { public static final EntityClassification MOD_FREINDLY = EntityClassification.create("ModFriendly", "ModFriendly", 20, true, true, 128); public static final EntityClassification MOD_WATER_CREATURE = EntityClassification.create("ModWater", "ModWater", 20, true, true, 128); public static final EntityClassification MOD_FREINDLY_CREATURE = EntityClassification.create("ModFriendlyCreature", "ModFriendlyCreature", 10, true, true, 128); public static final RegistryObject<EntityType<?>> GREEKVILLAGER = register("greekvillager_entity", () -> EntityType.Builder.create(GreekVillagerEntity::new, MOD_FREINDLY).build(new ResourceLocation(GreekMyths.MOD_ID, "greekvillager_entity").toString())); public static final RegistryObject<EntityType<?>> HIPPOCAMPUS = register("hippocampus_entity", () -> EntityType.Builder.create(HippocampusEntity::new, MOD_WATER_CREATURE).size(1.2f, 1.3f).build(new ResourceLocation(GreekMyths.MOD_ID, "hippocampus_entity").toString())); public static final RegistryObject<EntityType<?>> PEGASUS = register("pegasus_entity", () -> EntityType.Builder.create(PegasusEntity::new, MOD_FREINDLY_CREATURE).size(1.36f, 1.6f).build(new ResourceLocation(GreekMyths.MOD_ID, "pegasus_entity").toString())); // public static final RegistryObject<Item> GREEK_VILLAGER_SPAWN_EGG = Registration.ITEMS.register("greek_villager_spawn_egg", () -> // new SpawnEggItem(GREEKVILLAGER.get(), 0x2f5882, 0x6f1499, new Item.Properties().group(GreekMyths.ITEM_GROUP))); public static void register() { } public static <T extends EntityType<?>> RegistryObject<T> register(String name, Supplier<T> entity) { RegistryObject<T> ret = Registration.ENTITIES.register(name, entity); return ret; } @SubscribeEvent public static void setupEntityHandler(final FMLCommonSetupEvent event) { event.enqueueWork(() -> { setupEntity((EntityType<MobEntity>)GREEKVILLAGER.get(),GreekVillagerEntity::getAttributes, GreekVillagerEntity::canSpawnOn); setupEntity((EntityType<MobEntity>)HIPPOCAMPUS.get(), HippocampusEntity::getAttributes, HippocampusEntity::canSpawnOn); setupEntity((EntityType<MobEntity>)PEGASUS.get(), PegasusEntity::getAttributes, PegasusEntity::canSpawnOn); }); } public static <T extends MobEntity> void setupEntity(final EntityType<T> entityType, final Supplier<AttributeModifierMap.MutableAttribute> mapSupplier, @Nullable final EntitySpawnPlacementRegistry.IPlacementPredicate<T> placementPredicate){ GlobalEntityTypeAttributes.put((EntityType<? extends LivingEntity>) entityType, mapSupplier.get().create()); final EntitySpawnPlacementRegistry.PlacementType placementType = entityType.getClassification() == MOD_WATER_CREATURE ? EntitySpawnPlacementRegistry.PlacementType.IN_WATER : EntitySpawnPlacementRegistry.PlacementType.ON_GROUND; final EntitySpawnPlacementRegistry.IPlacementPredicate<T> placement = (entity, world, reason, pos, rand) -> placementPredicate.test(entity, world, reason, pos, rand); EntitySpawnPlacementRegistry.register(entityType, placementType, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, placement); } }
January 29, 20214 yr Author Just set up the repo. Here is the link: https://github.com/WindRunner7/GreekMyths
January 30, 20214 yr I didn't really have time to carefully read all your code, so..what was the problem? Sharing how you solved your issue may be helpful to those who may read this post in the future Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
January 30, 20214 yr Author For some reason the canSpawnOn function wasn't running properly from the jar. It seems to have clashed with where I set spawn placement type to inWater. public static boolean canSpawnOn(final EntityType<? extends MobEntity> entity, final IWorld world, final SpawnReason reason, final BlockPos pos, final Random rand) { if (pos.getY() > 25) { Optional<RegistryKey<Biome>> optional = world.func_242406_i(pos); return (Objects.equals(optional, Optional.of(Biomes.OCEAN)) || Objects.equals(optional, Optional.of(Biomes.DEEP_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.WARM_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.DEEP_WARM_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.LUKEWARM_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.DEEP_LUKEWARM_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.COLD_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.DEEP_COLD_OCEAN)) || Objects.equals(optional, Optional.of(Biomes.DEEP_OCEAN))) && world.getFluidState(pos).isTagged(FluidTags.WATER); } else { return false; } } I got this code mostly from the dolphinEntity class but modified it slightly. I tried changing this and ended up with this. I also changed the name of the function as I think there may have been an inheritance issue. This is what I ended up with. public static boolean canHippocampusSpawnOn(final EntityType<? extends MobEntity> entity, final IWorld world, final SpawnReason reason, final BlockPos pos, final Random rand) { if (pos.getY() <= 25 || pos.getY() >= world.getSeaLevel()) { return false; } RegistryKey<Biome> biome = world.func_242406_i(pos).orElse(Biomes.PLAINS); return (BiomeDictionary.hasType(biome, BiomeDictionary.Type.OCEAN)) && world.getFluidState(pos).isTagged(FluidTags.WATER); } This seems to have fixed the issue. Thanks again!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.