Fix nether portal crash ()

* Correct ordinal of `afterWorldChanged` mixin to the correct return

Co-authored-by: i509VCB <git@i509.me>

* Handle null entity when unable to be created

* Comply with Checkstyle

* Remove redundant ordinal and only use null return to check valid teleports

Co-authored-by: Player <player@player.to>

Co-authored-by: i509VCB <git@i509.me>
Co-authored-by: Player <player@player.to>
This commit is contained in:
Mitchell Skaggs 2021-01-03 10:32:33 -06:00 committed by GitHub
parent 36111fa0e1
commit c7d5c83208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,8 +33,13 @@ abstract class EntityMixin {
@Shadow
public World world;
@Inject(method = "moveToWorld", at = @At(value = "RETURN", ordinal = 1))
@Inject(method = "moveToWorld", at = @At("RETURN"))
private void afterWorldChanged(ServerWorld destination, CallbackInfoReturnable<Entity> cir) {
ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.invoker().afterChangeWorld((Entity) (Object) this, cir.getReturnValue(), (ServerWorld) this.world, (ServerWorld) cir.getReturnValue().world);
// Ret will only have an entity if the teleport worked (entity not removed, teleportTarget was valid, entity was successfully created)
Entity ret = cir.getReturnValue();
if (ret != null) {
ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.invoker().afterChangeWorld((Entity) (Object) this, ret, (ServerWorld) this.world, (ServerWorld) ret.world);
}
}
}