Fix custom teleporters NPE (#7296)
This commit is contained in:
parent
178e3d244a
commit
e421ea164c
3 changed files with 18 additions and 6 deletions
|
@ -218,7 +218,7 @@
|
|||
}
|
||||
|
||||
public boolean func_70028_i(Entity p_70028_1_) {
|
||||
@@ -2087,6 +2117,10 @@
|
||||
@@ -2087,14 +2117,19 @@
|
||||
|
||||
@Nullable
|
||||
public Entity func_241206_a_(ServerWorld p_241206_1_) {
|
||||
|
@ -229,8 +229,11 @@
|
|||
if (this.field_70170_p instanceof ServerWorld && !this.field_70128_L) {
|
||||
this.field_70170_p.func_217381_Z().func_76320_a("changeDimension");
|
||||
this.func_213319_R();
|
||||
@@ -2095,6 +2129,7 @@
|
||||
if (portalinfo == null) {
|
||||
this.field_70170_p.func_217381_Z().func_76320_a("reposition");
|
||||
- PortalInfo portalinfo = this.func_241829_a(p_241206_1_);
|
||||
- if (portalinfo == null) {
|
||||
+ PortalInfo portalinfo = teleporter.isVanilla() ? this.func_241829_a(p_241206_1_) : null;
|
||||
+ if (portalinfo == null && teleporter.isVanilla()) {
|
||||
return null;
|
||||
} else {
|
||||
+ Entity transportedEntity = teleporter.placeEntity(this, (ServerWorld) this.field_70170_p, p_241206_1_, this.field_70177_z, spawnPortal -> { //Forge: Start vanilla logic
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
ServerWorld serverworld = this.func_71121_q();
|
||||
RegistryKey<World> registrykey = serverworld.func_234923_W_();
|
||||
- if (registrykey == World.field_234920_i_ && p_241206_1_.func_234923_W_() == World.field_234918_g_) {
|
||||
+ if (registrykey == World.field_234920_i_ && p_241206_1_.func_234923_W_() == World.field_234918_g_ && teleporter instanceof net.minecraft.world.Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
|
||||
+ if (registrykey == World.field_234920_i_ && p_241206_1_.func_234923_W_() == World.field_234918_g_ && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits
|
||||
this.func_213319_R();
|
||||
- this.func_71121_q().func_217434_e(this);
|
||||
+ this.func_71121_q().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
|
||||
|
@ -32,10 +32,12 @@
|
|||
playerlist.func_187243_f(this);
|
||||
- serverworld.func_217434_e(this);
|
||||
- this.field_70128_L = false;
|
||||
- PortalInfo portalinfo = this.func_241829_a(p_241206_1_);
|
||||
- if (portalinfo != null) {
|
||||
+ serverworld.removeEntity(this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
|
||||
+ this.revive();
|
||||
PortalInfo portalinfo = this.func_241829_a(p_241206_1_);
|
||||
if (portalinfo != null) {
|
||||
+ PortalInfo portalinfo = teleporter.isVanilla() ? this.func_241829_a(p_241206_1_) : null;
|
||||
+ if (portalinfo != null || !teleporter.isVanilla()) {
|
||||
+ Entity e = teleporter.placeEntity(this, serverworld, p_241206_1_, this.field_70177_z, spawnPortal -> {//Forge: Start vanilla logic
|
||||
serverworld.func_217381_Z().func_76320_a("moving");
|
||||
if (registrykey == World.field_234918_g_ && p_241206_1_.func_234923_W_() == World.field_234919_h_) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.function.Function;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
/**
|
||||
|
@ -57,4 +58,10 @@ public interface ITeleporter {
|
|||
default Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity) {
|
||||
return repositionEntity.apply(true);
|
||||
}
|
||||
|
||||
//used internally to handle vanilla hardcoding
|
||||
default boolean isVanilla()
|
||||
{
|
||||
return getClass() == Teleporter.class;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue