Port teleport fix from 1.15
This commit is contained in:
parent
c35bb35cf8
commit
f67d4c5739
@ -458,7 +458,8 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
|||||||
|
|
||||||
@Inject(method = "setPositionAndRotation", at = @At("RETURN"))
|
@Inject(method = "setPositionAndRotation", at = @At("RETURN"))
|
||||||
private void arclight$loadChunk(double x, double y, double z, float yaw, float pitch, CallbackInfo ci) {
|
private void arclight$loadChunk(double x, double y, double z, float yaw, float pitch, CallbackInfo ci) {
|
||||||
if (this.valid) this.world.getChunk((int) Math.floor(this.getPosX()) >> 4, (int) Math.floor(this.getPosZ()) >> 4);
|
if (this.valid)
|
||||||
|
this.world.getChunk((int) Math.floor(this.getPosX()) >> 4, (int) Math.floor(this.getPosZ()) >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCollideWith(Entity entity) {
|
public boolean canCollideWith(Entity entity) {
|
||||||
@ -828,12 +829,6 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
|||||||
ArclightCaptures.captureEndPortalEntity((Entity) (Object) this, spawnPortal);
|
ArclightCaptures.captureEndPortalEntity((Entity) (Object) this, spawnPortal);
|
||||||
ServerWorld.func_241121_a_(world);
|
ServerWorld.func_241121_a_(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getBukkitEntity().setHandle(entity);
|
|
||||||
((EntityBridge) entity).bridge$setBukkitEntity(this.bridge$getBukkitEntity());
|
|
||||||
if ((Object) this instanceof MobEntity) {
|
|
||||||
((MobEntity) (Object) this).clearLeashed(true, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}); //Forge: End vanilla logic
|
}); //Forge: End vanilla logic
|
||||||
@ -850,6 +845,15 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "copyDataFromOld", at = @At("HEAD"))
|
||||||
|
private void arclight$forwardHandle(Entity entityIn, CallbackInfo ci) {
|
||||||
|
((InternalEntityBridge) entityIn).internal$getBukkitEntity().setHandle((Entity) (Object) this);
|
||||||
|
((EntityBridge) this).bridge$setBukkitEntity(((InternalEntityBridge) entityIn).internal$getBukkitEntity());
|
||||||
|
if (entityIn instanceof MobEntity) {
|
||||||
|
((MobEntity) entityIn).clearLeashed(true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author IzzelAliz
|
* @author IzzelAliz
|
||||||
* @reason
|
* @reason
|
||||||
|
|||||||
@ -75,7 +75,6 @@ import net.minecraft.util.text.event.HoverEvent;
|
|||||||
import net.minecraft.world.DimensionType;
|
import net.minecraft.world.DimensionType;
|
||||||
import net.minecraft.world.GameRules;
|
import net.minecraft.world.GameRules;
|
||||||
import net.minecraft.world.GameType;
|
import net.minecraft.world.GameType;
|
||||||
import net.minecraft.world.Teleporter;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeManager;
|
import net.minecraft.world.biome.BiomeManager;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
@ -475,7 +474,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
// this.invulnerableDimensionChange = true;
|
// this.invulnerableDimensionChange = true;
|
||||||
ServerWorld serverworld = this.getServerWorld();
|
ServerWorld serverworld = this.getServerWorld();
|
||||||
RegistryKey<DimensionType> registrykey = ((WorldBridge) serverworld).bridge$getTypeKey();
|
RegistryKey<DimensionType> registrykey = ((WorldBridge) serverworld).bridge$getTypeKey();
|
||||||
if (registrykey == DimensionType.THE_END && ((WorldBridge) server).bridge$getTypeKey() == DimensionType.OVERWORLD && teleporter instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
|
if (registrykey == DimensionType.THE_END && ((WorldBridge) server).bridge$getTypeKey() == DimensionType.OVERWORLD && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits
|
||||||
this.invulnerableDimensionChange = true;
|
this.invulnerableDimensionChange = true;
|
||||||
this.detach();
|
this.detach();
|
||||||
this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
|
this.getServerWorld().removePlayer((ServerPlayerEntity) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom
|
||||||
@ -487,8 +486,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
|
|
||||||
return (ServerPlayerEntity) (Object) this;
|
return (ServerPlayerEntity) (Object) this;
|
||||||
} else {
|
} else {
|
||||||
PlayerList playerlist = this.server.getPlayerList();
|
|
||||||
/*
|
|
||||||
IWorldInfo iworldinfo = server.getWorldInfo();
|
IWorldInfo iworldinfo = server.getWorldInfo();
|
||||||
this.connection.sendPacket(new SRespawnPacket(server.getDimensionType(), server.getDimensionKey(), BiomeManager.getHashedSeed(server.getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), server.isDebug(), server.func_241109_A_(), true));
|
this.connection.sendPacket(new SRespawnPacket(server.getDimensionType(), server.getDimensionKey(), BiomeManager.getHashedSeed(server.getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), server.isDebug(), server.func_241109_A_(), true));
|
||||||
this.connection.sendPacket(new SServerDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked()));
|
this.connection.sendPacket(new SServerDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked()));
|
||||||
@ -496,7 +493,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
|
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
|
||||||
serverworld.removeEntity((ServerPlayerEntity) (Object) this, true); //Forge: the player entity is moved to the new world, NOT cloned. So keep the data alive with no matching invalidate call.
|
serverworld.removeEntity((ServerPlayerEntity) (Object) 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();
|
this.revive();
|
||||||
*/
|
|
||||||
PortalInfo portalinfo = teleporter.getPortalInfo((ServerPlayerEntity) (Object) this, server, this::func_241829_a);
|
PortalInfo portalinfo = teleporter.getPortalInfo((ServerPlayerEntity) (Object) this, server, this::func_241829_a);
|
||||||
ServerWorld[] exitWorld = new ServerWorld[]{server};
|
ServerWorld[] exitWorld = new ServerWorld[]{server};
|
||||||
if (portalinfo != null) {
|
if (portalinfo != null) {
|
||||||
@ -520,18 +516,18 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
exit = tpEvent.getTo();
|
exit = tpEvent.getTo();
|
||||||
exitWorld[0] = ((CraftWorld) exit.getWorld()).getHandle();
|
|
||||||
|
|
||||||
serverworld.getProfiler().endSection();
|
serverworld.getProfiler().endSection();
|
||||||
serverworld.getProfiler().startSection("placing");
|
serverworld.getProfiler().startSection("placing");
|
||||||
|
|
||||||
this.invulnerableDimensionChange = true;
|
this.invulnerableDimensionChange = true;
|
||||||
IWorldInfo iworldinfo = exitWorld[0].getWorldInfo();
|
ServerWorld newWorld = ((CraftWorld) exit.getWorld()).getHandle();
|
||||||
this.connection.sendPacket(new SRespawnPacket(exitWorld[0].getDimensionType(), exitWorld[0].getDimensionKey(), BiomeManager.getHashedSeed(exitWorld[0].getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), exitWorld[0].isDebug(), exitWorld[0].func_241109_A_(), true));
|
if (newWorld != exitWorld[0]) {
|
||||||
this.connection.sendPacket(new SServerDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked()));
|
exitWorld[0] = newWorld;
|
||||||
playerlist.updatePermissionLevel((ServerPlayerEntity) (Object) this);
|
IWorldInfo newWorldInfo = exitWorld[0].getWorldInfo();
|
||||||
serverworld.removeEntity((ServerPlayerEntity) (Object) 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.connection.sendPacket(new SRespawnPacket(exitWorld[0].getDimensionType(), exitWorld[0].getDimensionKey(), BiomeManager.getHashedSeed(exitWorld[0].getSeed()), this.interactionManager.getGameType(), this.interactionManager.func_241815_c_(), exitWorld[0].isDebug(), exitWorld[0].func_241109_A_(), true));
|
||||||
this.revive();
|
this.connection.sendPacket(new SServerDifficultyPacket(newWorldInfo.getDifficulty(), newWorldInfo.isDifficultyLocked()));
|
||||||
|
}
|
||||||
|
|
||||||
this.setWorld(exitWorld[0]);
|
this.setWorld(exitWorld[0]);
|
||||||
exitWorld[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
|
exitWorld[0].addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
|
||||||
@ -544,7 +540,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch
|
return (ServerPlayerEntity) (Object) this;//forge: this is part of the ITeleporter patch
|
||||||
});//Forge: End vanilla logic
|
});//Forge: End vanilla logic
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
return null;
|
serverworld.addDuringPortalTeleport((ServerPlayerEntity) (Object) this);
|
||||||
|
return (ServerPlayerEntity) (Object) this;
|
||||||
} else if (e != (Object) this) {
|
} else if (e != (Object) this) {
|
||||||
throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this));
|
throw new IllegalArgumentException(String.format("Teleporter %s returned not the player entity but instead %s, expected PlayerEntity %s", teleporter, e, this));
|
||||||
}
|
}
|
||||||
@ -565,8 +562,6 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, serverworld.getDimensionKey(), exitWorld[0].getDimensionKey());
|
BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayerEntity) (Object) this, serverworld.getDimensionKey(), exitWorld[0].getDimensionKey());
|
||||||
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld());
|
PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld());
|
||||||
Bukkit.getPluginManager().callEvent(changeEvent);
|
Bukkit.getPluginManager().callEvent(changeEvent);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ServerPlayerEntity) (Object) this;
|
return (ServerPlayerEntity) (Object) this;
|
||||||
@ -667,7 +662,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||||||
if (container != null) {
|
if (container != null) {
|
||||||
((ContainerBridge) container).bridge$setTitle(itileinventory.getDisplayName());
|
((ContainerBridge) container).bridge$setTitle(itileinventory.getDisplayName());
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
ArclightCaptures.captureContainerOwner((ServerPlayerEntity)(Object)this);
|
ArclightCaptures.captureContainerOwner((ServerPlayerEntity) (Object) this);
|
||||||
container = CraftEventFactory.callInventoryOpenEvent((ServerPlayerEntity) (Object) this, container, cancelled);
|
container = CraftEventFactory.callInventoryOpenEvent((ServerPlayerEntity) (Object) this, container, cancelled);
|
||||||
ArclightCaptures.resetContainerOwner();
|
ArclightCaptures.resetContainerOwner();
|
||||||
if (container == null && !cancelled) {
|
if (container == null && !cancelled) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user