Jump to content

LocutusVonBorg

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

LocutusVonBorg's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Are you willing to pay for development work or are you looking for likeminded halo fans?
  2. I finally got a working state by rewriting the code for the registering. Even though the wiki suggests static registers, they seem unreliable. For Items and Blocks they work fine, but for EntityType they let me down: https://github.com/LocutusV0nB0rg/TotallyNotModded/commit/9d7ab1baf0acba3516f31601c6b7714e5ad2054e
  3. Making a clean cut about all the OT... --- It seems I'm misunderstanding the documentation on this point. https://forge.gemwire.uk/wiki/Registration#DeferredRegister It clearly suggests to just call the register method with static initialisation. I understand this might be suboptimal, but it is suggested there nevertheless. I am unsure on which code will run on the server and which one will run on the client. I undestand all rendering is done on the client (obviously, duh...), but what are the concrete consequences I have to draw? Just split my code up in two strictly separated sections with a "commons" area?
  4. I am a stackoverflow user, where it's greatly appreciated to demonstrate the code that seems to be the problem. However, if it is considered bad practice here, I will refrain from doing so in the future. All my code I have mentioned is live, on github, in the repository I linked in my original post. I have a background of Paper server plugins for vanilla minecraft. I have some experience with how learning to develop code for minecraft applications works and I do read any documentation I can get my hands on. No need to get offensive. Also, I'd be glad to be shown the door where noobs can ask questions that seem to be unworthy of the people here. Because I do not know better. Is that a crime? If I knew the answer to all those questions, I would probably not be here asking for help. I tried to copy the basic structure of the registry of the kaupenjoe tutorials, thats why I tried it like him. He does static initialisation https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.19/blob/3-blocks/src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java Anyways: I switched to a event based approach and got this: https://github.com/LocutusV0nB0rg/TotallyNotModded/blob/master/src/main/java/borg/locutus/totallynotmodded/EntityRendererRegisterListener.java This also seems to be wrong, I seem to register a lot of nonsense entries... https://haste.locutusvonborg.de/wixisokelo.yaml
  5. This wiki is helpful, and to be honest it's the first time I've ever heard of it, so thank you for that. I have switched to registering by the event as you suggested and tested it by registering the renderer on the EntityType.MINECART . It works fine, so that seems good. Now, I switch to my brand new EntityInitializer: @Mod.EventBusSubscriber(modid = TotallyNotModdedMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class EntityRendererRegisterListener { @SubscribeEvent public static void addEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(FASTCART_ENTITY_TYPE, (p_174070_) -> new FastcartRenderer<>(p_174070_, ModelLayers.MINECART)); } @SubscribeEvent public void register(RegisterEvent event) { event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> helper.register( "fastcart", FASTCART_ENTITY_TYPE)); } } This is my other class. public class EntityInitializer { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, TotallyNotModdedMod.MODID); public static final EntityType<? extends AbstractMinecart> FASTCART_ENTITY_TYPE = EntityType.Builder.<Fastcart>of(Fastcart::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8).build("fastcart"); } This should do the registration not at class load time, but now I get https://haste.locutusvonborg.de/sumewaridu.sql as an error, something seems to be wrong with my registration?
  6. I am currently adding a new type of minecart. The eventual goal will be to have it go faster than the vanilla minecart, therefore I named it "Fastcart". I have created my own model that is coloured differently and also created my custom renderer for it. This works as expected. The problem I have comes from the place where I want to set this renderer to go with the Fastcart Entity. I have this code to do the registration of the renderer, in fact my main mod class. @Mod(TotallyNotModdedMod.MODID) public class TotallyNotModdedMod { public static final String MODID = "totallynotmodded"; public TotallyNotModdedMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ItemInitializer.ITEMS.register(modEventBus); BlockInitializer.BLOCKS.register(modEventBus); MinecraftForge.EVENT_BUS.register(CreativeTabCreator.class); registerFastcartRenderer(); } private void registerFastcartRenderer() { EntityRenderers.register(EntityType.MINECART, (p_174070_) -> new FastcartRenderer<>(p_174070_, ModelLayers.MINECART)); } } Observe the last two lines. My renderer is registered with the EntityRenderers and is attached to the EntityType.MINECART . This allowed me to test my renderer, as this would render the vanilla minecarts with my own renderer, and this works fine. The minecarts are now rendered using my own texture and renderer and stuff. Yay for me! However, I now have to switch this to use my own EntityType so only my Fastcart Entity gets the FastcartRenderer and I don't overwrite the Renderer for the default Minecart. I thought I could do this by simply adding my own EntityType but turns out, everything in the EntityType class is private. I copied the contents of its register method and tried to create my own: public class FastcartEntityTypeProvider { //This seems to be the problem. //The write in the register takes place too later after the registries are already locked. //Might have to properly setup the Mixins to circumvent this. public static final EntityType<Fastcart> FASTCART = register("fastcart", EntityType.Builder.<Fastcart>of(Fastcart::new, MobCategory.MISC).sized(0.98F, 0.7F).clientTrackingRange(8)); private static <T extends Entity> EntityType<T> register(String p_20635_, EntityType.Builder<T> p_20636_) { return Registry.register(BuiltInRegistries.ENTITY_TYPE, p_20635_, p_20636_.build(p_20635_)); } } If I switch "EntityType.MINECART" for "FastcartEntityTypeProvider.FASTCART", I get an error that complains about the invalidity of my write, because the registries seem to already been frozen: https://haste.locutusvonborg.de/ejoquraqoz.yaml How can I register my EntityType early enough? Do I really have to use Mixin to insert my register in the static block of the EntityType class? To be honest, I'd rather like to avoid this, but I would do it if I have no other choice. All my code is available on https://github.com/LocutusV0nB0rg/TotallyNotModded
×
×
  • Create New...

Important Information

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