Posted August 20, 20214 yr Hello there! I'm a new modder. I have created a functional entity similar to Pillagers. Public class net.minecraft.world.spawner.PatrolSpawner which implements ISpecialSpawner spawns these, and I have copied this class with a variant that spawns my own entities. However, I can't for the life of me figure out where PatrolSpawner is ever called or initiated to happen, and thus, I am also unsure where to start with causing my own custom class to start working. The Illager spawn mechanic is pretty niche to work with and I can't find anything about it. Does anyone have ideas? Thanks for the help!
August 20, 20214 yr okay the whole thing is a bit complicated, as you already found out you need an Access Transformers, use it to make the field customSpawners in ServerWorld public then use WorldEvent.Load and check whether the world of the event is a ServerWorld if so, you can simply add a new instance of your spawner to the CustomSpawner list Edit: the AT for ServerWorld.customSpawners is: public net.minecraft.world.server.ServerWorld field_241104_N_ # customSpawners Edited August 20, 20214 yr by Luis_ST
August 20, 20214 yr Author ServerWorld, Access Transformers and a list entry, thank you very much, that sends me underway! I'll figure out what I can, though I am not familiar yet with Access Transformers. Any additional help is appreciated.
August 20, 20214 yr Author 2 minutes ago, diesieben07 said: There is no reason to use an access transformer or any other hacks like that and it is also not very complicated. All that is done with the customSpawners field is loop through it and call their tick method if GameRules.RULE_DOMOBSPAWNING is true. You can achieve the same thing using TickEvent.WorldTickEvent (note though that you need to check the phase field, otherwise your code runs twice every tick). That sounds feasible! Thank you, I'll try that as well. Though, silly question maybe, but where would I call customSpawners' tick method? Do you have an example? Should I call it from my RegisterEntities class? I'm not sure how to make it so that I call the method once ServerWorld starts, if that is how it works
August 20, 20214 yr Author 12 minutes ago, diesieben07 said: From your WorldTickEvent handler. @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent event) { ServerWorld.tickCustomSpawners(true, true); } } I have this in my main mod class- I see where it's going, but how do I obtain the correct instance of ServerWorld? I tried getting it by using the event variable by writing "event.world.tickCustomSpawners(true, true);" but I am not sure how to go from a WorldTickEvent to a ServerWorld
August 20, 20214 yr Author 15 minutes ago, diesieben07 said: You are not checking the phase of the event like I told you to. Don't call tickCustomSpawners, that would tick the vanilla spawners... You need to call tick on your spawner. You get the world instance from the event. MiSquadSpawner is my spawner, which is public int tick(ServerWorld, boolean, boolean). @SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent xevent) { if (xevent.phase != null) { MiSquadSpawner.tick(xevent.world, false, false); } } I do not fully understand what to do, how exactly to check the phase, and how to get a ServerWorld from a TickEvent.WorldTickEvent. Currently, the errors I get are- "xevent cannot be resolved to a type" "The method tick(Serverworld, boolean, boolean) is not applicable for the arguments (World, boolean, boolean)" Does anyone know how to continue from here?
August 20, 20214 yr Author Just now, diesieben07 said: Please learn basic Java. That's... Why I'm here. I guess I'll seek assistance elsewhere, then
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.