Various world patch, fix end portal crash (#81)
Also mapped world names
This commit is contained in:
parent
8d453dc287
commit
3d40d345fc
|
@ -0,0 +1,12 @@
|
||||||
|
package io.izzel.arclight.common.bridge.world.storage;
|
||||||
|
|
||||||
|
import net.minecraft.util.RegistryKey;
|
||||||
|
import net.minecraft.world.DimensionType;
|
||||||
|
import net.minecraft.world.storage.IServerWorldInfo;
|
||||||
|
|
||||||
|
public interface DerivedWorldInfoBridge {
|
||||||
|
|
||||||
|
IServerWorldInfo bridge$getDelegate();
|
||||||
|
|
||||||
|
void bridge$setDimType(RegistryKey<DimensionType> typeKey);
|
||||||
|
}
|
|
@ -921,6 +921,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||||
vector3d = new Vector3d(0.5D, 0.0D, 0.0D);
|
vector3d = new Vector3d(0.5D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArclightCaptures.captureCraftPortalEvent(event);
|
||||||
return PortalSize.func_242963_a(worldFinal, p_242275_2_, direction$axis, vector3d, this.getSize(this.getPose()), this.getMotion(), this.rotationYaw, this.rotationPitch);
|
return PortalSize.func_242963_a(worldFinal, p_242275_2_, direction$axis, vector3d, this.getSize(this.getPose()), this.getMotion(), this.rotationYaw, this.rotationPitch);
|
||||||
}).orElse(null);
|
}).orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -938,7 +939,10 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge,
|
||||||
}
|
}
|
||||||
blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
blockpos = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||||
|
|
||||||
return new PortalInfo(new Vector3d((double) blockpos.getX() + 0.5D, blockpos.getY(), (double) blockpos.getZ() + 0.5D), this.getMotion(), this.rotationYaw, this.rotationPitch);
|
PortalInfo portalInfo = new PortalInfo(new Vector3d((double) blockpos.getX() + 0.5D, blockpos.getY(), (double) blockpos.getZ() + 0.5D), this.getMotion(), this.rotationYaw, this.rotationPitch);
|
||||||
|
((PortalInfoBridge) portalInfo).bridge$setWorld(((CraftWorld) event.getTo().getWorld()).getHandle());
|
||||||
|
((PortalInfoBridge) portalInfo).bridge$setPortalEventInfo(event);
|
||||||
|
return portalInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||||
@Mixin(EnderDragonEntity.class)
|
@Mixin(EnderDragonEntity.class)
|
||||||
public abstract class EnderDragonEntityMixin extends MobEntityMixin {
|
public abstract class EnderDragonEntityMixin extends MobEntityMixin {
|
||||||
|
|
||||||
private Explosion explosionSource = new Explosion(null, (EnderDragonEntity) (Object) this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Mode.DESTROY);
|
private Explosion explosionSource = new Explosion(null, (EnderDragonEntity) (Object) this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Mode.DESTROY);
|
||||||
|
|
||||||
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/boss/dragon/phase/IPhase;getTargetLocation()Lnet/minecraft/util/math/vector/Vector3d;"))
|
@Redirect(method = "livingTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/boss/dragon/phase/IPhase;getTargetLocation()Lnet/minecraft/util/math/vector/Vector3d;"))
|
||||||
private Vector3d arclight$noMoveHovering(IPhase phase) {
|
private Vector3d arclight$noMoveHovering(IPhase phase) {
|
||||||
|
|
|
@ -467,6 +467,7 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
||||||
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 instanceof Teleporter) { //Forge: Fix non-vanilla teleporters triggering end credits
|
||||||
|
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
|
||||||
if (!this.queuedEndExit) {
|
if (!this.queuedEndExit) {
|
||||||
|
|
|
@ -284,7 +284,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
Vector3d vec3d2 = Vector3d.copyCenteredHorizontally(pos).subtract(vec3d).normalize();
|
Vector3d vec3d2 = Vector3d.copyCenteredHorizontally(pos).subtract(vec3d).normalize();
|
||||||
f2 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0);
|
f2 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0);
|
||||||
}
|
}
|
||||||
playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f);
|
// playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f);
|
||||||
playerIn.func_242111_a(spawnWorld.getDimensionKey(), pos, f, flag2, false);
|
playerIn.func_242111_a(spawnWorld.getDimensionKey(), pos, f, flag2, false);
|
||||||
flag3 = (!flag && flag4);
|
flag3 = (!flag && flag4);
|
||||||
isBedSpawn = true;
|
isBedSpawn = true;
|
||||||
|
@ -385,7 +385,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
if (spawnWorld != null) {
|
if (spawnWorld != null) {
|
||||||
Optional<Vector3d> optional;
|
Optional<Vector3d> optional;
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
optional = PlayerEntity.func_242374_a(spawnWorld, pos, f, flag2, flag2);
|
optional = PlayerEntity.func_242374_a(spawnWorld, pos, f, flag2, conqueredEnd);
|
||||||
} else {
|
} else {
|
||||||
optional = Optional.empty();
|
optional = Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
Vector3d vec3d2 = Vector3d.copyCenteredHorizontally(pos).subtract(vec3d).normalize();
|
Vector3d vec3d2 = Vector3d.copyCenteredHorizontally(pos).subtract(vec3d).normalize();
|
||||||
f2 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0);
|
f2 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d2.z, vec3d2.x) * 57.2957763671875 - 90.0);
|
||||||
}
|
}
|
||||||
playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f);
|
// playerIn.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, f2, 0.0f);
|
||||||
playerIn.func_242111_a(spawnWorld.getDimensionKey(), pos, f, flag2, false);
|
playerIn.func_242111_a(spawnWorld.getDimensionKey(), pos, f, flag2, false);
|
||||||
flag3 = (!flag2 && flag4);
|
flag3 = (!flag2 && flag4);
|
||||||
isBedSpawn = true;
|
isBedSpawn = true;
|
||||||
|
@ -421,7 +421,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
return playerIn;
|
return playerIn;
|
||||||
}
|
}
|
||||||
location = respawnEvent.getRespawnLocation();
|
location = respawnEvent.getRespawnLocation();
|
||||||
if (!flag2) {
|
if (!conqueredEnd) {
|
||||||
((ServerPlayerEntityBridge) playerIn).bridge$reset();
|
((ServerPlayerEntityBridge) playerIn).bridge$reset();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -441,7 +441,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
// Forward to new player instance
|
// Forward to new player instance
|
||||||
((InternalEntityBridge) playerIn).internal$getBukkitEntity().setHandle(serverplayerentity);
|
((InternalEntityBridge) playerIn).internal$getBukkitEntity().setHandle(serverplayerentity);
|
||||||
((EntityBridge) serverplayerentity).bridge$setBukkitEntity(((InternalEntityBridge) playerIn).internal$getBukkitEntity());
|
((EntityBridge) serverplayerentity).bridge$setBukkitEntity(((InternalEntityBridge) playerIn).internal$getBukkitEntity());
|
||||||
if ((Object) serverplayerentity instanceof MobEntity) {
|
if ((Object) playerIn instanceof MobEntity) {
|
||||||
((MobEntity) (Object) playerIn).clearLeashed(true, false);
|
((MobEntity) (Object) playerIn).clearLeashed(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,8 +455,8 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
serverplayerentity.addTag(s);
|
serverplayerentity.addTag(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerIn.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
serverplayerentity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||||
playerIn.connection.captureCurrentPosition();
|
serverplayerentity.connection.captureCurrentPosition();
|
||||||
|
|
||||||
this.setPlayerGameTypeBasedOnOther(serverplayerentity, playerIn, serverWorld);
|
this.setPlayerGameTypeBasedOnOther(serverplayerentity, playerIn, serverWorld);
|
||||||
while (avoidSuffocation && !serverWorld.hasNoCollisions(serverplayerentity) && serverplayerentity.getPosY() < 256.0D) {
|
while (avoidSuffocation && !serverWorld.hasNoCollisions(serverplayerentity) && serverplayerentity.getPosY() < 256.0D) {
|
||||||
|
@ -474,7 +474,7 @@ public abstract class PlayerListMixin implements PlayerListBridge {
|
||||||
serverplayerentity.connection.sendPacket(new SSetExperiencePacket(serverplayerentity.experience, serverplayerentity.experienceTotal, serverplayerentity.experienceLevel));
|
serverplayerentity.connection.sendPacket(new SSetExperiencePacket(serverplayerentity.experience, serverplayerentity.experienceTotal, serverplayerentity.experienceLevel));
|
||||||
this.sendWorldInfo(serverplayerentity, serverWorld);
|
this.sendWorldInfo(serverplayerentity, serverWorld);
|
||||||
this.updatePermissionLevel(serverplayerentity);
|
this.updatePermissionLevel(serverplayerentity);
|
||||||
if (!((ServerPlayNetHandlerBridge) playerIn.connection).bridge$isDisconnected()) {
|
if (!((ServerPlayNetHandlerBridge) serverplayerentity.connection).bridge$isDisconnected()) {
|
||||||
serverWorld.addRespawnedPlayer(serverplayerentity);
|
serverWorld.addRespawnedPlayer(serverplayerentity);
|
||||||
this.addPlayer(serverplayerentity);
|
this.addPlayer(serverplayerentity);
|
||||||
this.uuidToPlayerMap.put(serverplayerentity.getUniqueID(), serverplayerentity);
|
this.uuidToPlayerMap.put(serverplayerentity.getUniqueID(), serverplayerentity);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import io.izzel.arclight.common.bridge.world.ExplosionBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
import io.izzel.arclight.common.bridge.world.WorldBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.server.ServerChunkProviderBridge;
|
import io.izzel.arclight.common.bridge.world.server.ServerChunkProviderBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
|
import io.izzel.arclight.common.bridge.world.server.ServerWorldBridge;
|
||||||
|
import io.izzel.arclight.common.bridge.world.storage.DerivedWorldInfoBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.storage.MapDataBridge;
|
import io.izzel.arclight.common.bridge.world.storage.MapDataBridge;
|
||||||
import io.izzel.arclight.common.bridge.world.storage.WorldInfoBridge;
|
import io.izzel.arclight.common.bridge.world.storage.WorldInfoBridge;
|
||||||
import io.izzel.arclight.common.mixin.core.world.WorldMixin;
|
import io.izzel.arclight.common.mixin.core.world.WorldMixin;
|
||||||
|
@ -134,6 +135,7 @@ public abstract class ServerWorldMixin extends WorldMixin implements ServerWorld
|
||||||
} else if (worldInfo instanceof DerivedWorldInfo) {
|
} else if (worldInfo instanceof DerivedWorldInfo) {
|
||||||
// damn spigot again
|
// damn spigot again
|
||||||
this.$$worldDataServer = DelegateWorldInfo.wrap(((DerivedWorldInfo) worldInfo));
|
this.$$worldDataServer = DelegateWorldInfo.wrap(((DerivedWorldInfo) worldInfo));
|
||||||
|
((DerivedWorldInfoBridge) worldInfo).bridge$setDimType(this.getTypeKey());
|
||||||
}
|
}
|
||||||
((ServerChunkProviderBridge) this.field_241102_C_).bridge$setViewDistance(spigotConfig.viewDistance);
|
((ServerChunkProviderBridge) this.field_241102_C_).bridge$setViewDistance(spigotConfig.viewDistance);
|
||||||
((WorldInfoBridge) this.$$worldDataServer).bridge$setWorld((ServerWorld) (Object) this);
|
((WorldInfoBridge) this.$$worldDataServer).bridge$setWorld((ServerWorld) (Object) this);
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package io.izzel.arclight.common.mixin.core.world.storage;
|
|
||||||
|
|
||||||
import net.minecraft.world.storage.DerivedWorldInfo;
|
|
||||||
import net.minecraft.world.storage.IServerWorldInfo;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
|
||||||
|
|
||||||
@Mixin(DerivedWorldInfo.class)
|
|
||||||
public interface DerivedWorldInfoAccessor {
|
|
||||||
|
|
||||||
@Accessor("delegate")
|
|
||||||
IServerWorldInfo bridge$getDelegate();
|
|
||||||
}
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package io.izzel.arclight.common.mixin.core.world.storage;
|
||||||
|
|
||||||
|
import io.izzel.arclight.common.bridge.world.storage.DerivedWorldInfoBridge;
|
||||||
|
import net.minecraft.util.RegistryKey;
|
||||||
|
import net.minecraft.world.DimensionType;
|
||||||
|
import net.minecraft.world.storage.DerivedWorldInfo;
|
||||||
|
import net.minecraft.world.storage.IServerWorldInfo;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(DerivedWorldInfo.class)
|
||||||
|
public class DerivedWorldInfoMixin implements DerivedWorldInfoBridge {
|
||||||
|
|
||||||
|
@Shadow @Final private IServerWorldInfo delegate;
|
||||||
|
|
||||||
|
private RegistryKey<DimensionType> typeKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author IzzelAliz
|
||||||
|
* @reason
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public String getWorldName() {
|
||||||
|
if (typeKey == null || typeKey == DimensionType.OVERWORLD) {
|
||||||
|
return this.delegate.getWorldName();
|
||||||
|
} else {
|
||||||
|
String worldName = this.delegate.getWorldName() + "/";
|
||||||
|
String suffix;
|
||||||
|
if (typeKey == DimensionType.THE_END) {
|
||||||
|
suffix = "DIM1";
|
||||||
|
} else if (typeKey == DimensionType.THE_NETHER) {
|
||||||
|
suffix = "DIM-1";
|
||||||
|
} else {
|
||||||
|
suffix = typeKey.getLocation().getNamespace() + "/" + typeKey.getLocation().getPath();
|
||||||
|
}
|
||||||
|
return worldName + suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IServerWorldInfo bridge$getDelegate() {
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bridge$setDimType(RegistryKey<DimensionType> typeKey) {
|
||||||
|
this.typeKey = typeKey;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package io.izzel.arclight.common.mod.util;
|
||||||
|
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import io.izzel.arclight.common.bridge.world.storage.WorldInfoBridge;
|
import io.izzel.arclight.common.bridge.world.storage.WorldInfoBridge;
|
||||||
import io.izzel.arclight.common.mixin.core.world.storage.DerivedWorldInfoAccessor;
|
import io.izzel.arclight.common.bridge.world.storage.DerivedWorldInfoBridge;
|
||||||
import net.minecraft.command.TimerCallbackManager;
|
import net.minecraft.command.TimerCallbackManager;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
@ -247,7 +247,7 @@ public class DelegateWorldInfo extends ServerWorldInfo {
|
||||||
if (worldInfo instanceof ServerWorldInfo) {
|
if (worldInfo instanceof ServerWorldInfo) {
|
||||||
return ((WorldInfoBridge) worldInfo).bridge$getWorldSettings();
|
return ((WorldInfoBridge) worldInfo).bridge$getWorldSettings();
|
||||||
} else {
|
} else {
|
||||||
return worldSettings(((DerivedWorldInfoAccessor) worldInfo).bridge$getDelegate());
|
return worldSettings(((DerivedWorldInfoBridge) worldInfo).bridge$getDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ public class DelegateWorldInfo extends ServerWorldInfo {
|
||||||
if (worldInfo instanceof ServerWorldInfo) {
|
if (worldInfo instanceof ServerWorldInfo) {
|
||||||
return ((ServerWorldInfo) worldInfo).getDimensionGeneratorSettings();
|
return ((ServerWorldInfo) worldInfo).getDimensionGeneratorSettings();
|
||||||
} else {
|
} else {
|
||||||
return generatorSettings(((DerivedWorldInfoAccessor) worldInfo).bridge$getDelegate());
|
return generatorSettings(((DerivedWorldInfoBridge) worldInfo).bridge$getDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ public class DelegateWorldInfo extends ServerWorldInfo {
|
||||||
if (worldInfo instanceof ServerWorldInfo) {
|
if (worldInfo instanceof ServerWorldInfo) {
|
||||||
return ((WorldInfoBridge) worldInfo).bridge$getLifecycle();
|
return ((WorldInfoBridge) worldInfo).bridge$getLifecycle();
|
||||||
} else {
|
} else {
|
||||||
return lifecycle(((DerivedWorldInfoAccessor) worldInfo).bridge$getDelegate());
|
return lifecycle(((DerivedWorldInfoBridge) worldInfo).bridge$getDelegate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,7 +427,7 @@
|
||||||
"world.spawner.WanderingTraderSpawnerMixin",
|
"world.spawner.WanderingTraderSpawnerMixin",
|
||||||
"world.spawner.WorldEntitySpawner_EntityDensityManagerMixin",
|
"world.spawner.WorldEntitySpawner_EntityDensityManagerMixin",
|
||||||
"world.spawner.WorldEntitySpawnerMixin",
|
"world.spawner.WorldEntitySpawnerMixin",
|
||||||
"world.storage.DerivedWorldInfoAccessor",
|
"world.storage.DerivedWorldInfoMixin",
|
||||||
"world.storage.MapData_MapInfoMixin",
|
"world.storage.MapData_MapInfoMixin",
|
||||||
"world.storage.MapDataMixin",
|
"world.storage.MapDataMixin",
|
||||||
"world.storage.PlayerDataMixin",
|
"world.storage.PlayerDataMixin",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user