neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://projects.neoforged.net/neoforged/neoforge
Other
1.1k stars 161 forks source link

`PlayerSpawnPhantomsEvent` is just instantiated and not run on the event bus #71

Closed Insane96 closed 1 year ago

Insane96 commented 1 year ago

Minecraft Version: 1.20.1

NeoForge Version: 47.1.56

Logs: Not really needed

Steps to Reproduce:

  1. Subscribe a PlayerSpawnPhantomsEvent
  2. Run the game and check that the event is never run

Example code This makes Phantoms spawn in The End instead of the Overworld

@SubscribeEvent
public void onPhantomsSpawn(PlayerSpawnPhantomsEvent event) {
    if (event.getEntity().level().dimension() == Level.OVERWORLD)
        event.setResult(Event.Result.DENY);
    else if (event.getEntity().level().dimension() == Level.END)
        event.setResult(Event.Result.ALLOW);
}

Description of issue: This happens because the event is never posted, only instantiated: https://github.com/neoforged/NeoForge/blob/3323a2f37989bea3171273292f5a355ef445a9f3/patches/minecraft/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch#L10

sciwhiz12 commented 1 year ago

Looks like an undiscovered issue with the upstream PR MinecraftForge/MinecraftForge#9644 at the time it was merged, and we didn't discover it during our pulling of uncontested changes from upstream.