Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/18 in all areas

  1. So, you can get the registry instance in the RegistryEvent.Register<Biome> event. Even if you're not registering your own biome you can handle it. The event.getRegistry().getValues() returns a List<Biome> that can be stored in your own field for later reference. However, there is no guarantee that another mod isn't going to register more biomes after your chance to handle the event. So probably better to store the registry itself and grab the values later (maybe in the init loading phase) or if you're only looking up biomes occasionally performance probably isn't big concern and you can look it up whenever it makes sense. So, the steps would be: 1) make a class that is registered as an event handler, and have a method that subscribes to the event bus that handles the RegistryEvent.Register<Biome> case. 2) In that event handling method you would assign the registry to a public static field that you can access from elsewhere in your code. So something like this: /** /* This class would probably also be the one where you register your own biomes, if you /* do that in your mod. Otherwise can be its own class dedicated for this purpose. **/ @ObjectHolder(MainMod.MODID) // in case you're actually also registering biomes public class ModBiomes { // field to contain registry for later reference public final static IForgeRegistry<Biome> registry = null; @Mod.EventBusSubscriber(modid = MainMod.MODID) public static class RegistrationHandler { /** * Register this mod's {@link Biome}s. * * @param event The event */ @SubscribeEvent public static void onEvent(final RegistryEvent.Register<Biome> event) { System.out.println("Storing biome registry"); registry = event.getRegistry(); // Register any of your own biomes here as well // example: registry.register(new BiomeCloud().setRegistryName(MainMod.MODID, ModWorldGen.CLOUD_NAME)); // DEBUG System.out.println("Registry key set = " + registry.getKeys()); System.out.println("Registry value list = " + registry.getValues()); } } } Then later, you can just get the List<Biome> by referring to ModBiomes.registry.getValues(). Again I suggest you grab this in the init phase of your mod loading (where you'll be guaranteed that all other mods have added their biomes). You can put that list also into a public static field or not depending on how you intend to use the values.
    2 points
  2. Well, yes. But you need to follow Java practices for passing collections as varargs. I think generally you need a toArray() sort of conversion. This is explained in this article: http://programming.guide/java/passing-list-to-vararg-method.html Also, I'm a bit confused on what you want. Do you want to actually generate the structures in ALL biomes? Remember that list will contain ocean and nether and so forth. But of course you can create your own sublists by removing stuff you don't want. In particular you can use the BiomeDictionary to help algorithmically filter out things by type.
    1 point
  3. This is standard Java, which frankly we get a bit grumpy here about supporting since it is pretty easy to google. But it is a nice day, so I'll be nice! The error means that there is no such method. Your code is trying to call EnumFacing.getDirectionFromEntityLiving() but you're passing an EntityLivingBase as the placer. But the method requires an EntityLiving. There is no way for the code to be sure that something you typed as EntityLivingBase is an EntityLiving. EntityLiving are always EntityLivingBase, but not all EntityLivingBase are necessarily EntityLiving so it is an error. Even if every EntityLivingBase in Minecraft is extended to EntityLiving, the compiler cannot assume that is always true. In this case, as a coder you know that the placer field will actually be an EntityLiving. So you should "cast" the placer to EntityLiving before you pass it to the EnumFacing method. Look up casting in Java if you don't understand this.
    1 point
  4. You're using Java 9, which isn't supported by Forge. You need to use Java 8 instead.
    1 point
  5. Use the TX button (fifth from the right) to clear formatting or use Ctrl-Shift-V to paste as plain text.
    1 point
  6. Sure it is a forge registry so the actual singleton instances are registered.
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.