Fix dimension switching (untested)
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IMixinServerPlayer
|
||||
{
|
||||
@Nullable
|
||||
ServerLevel distantHorizons$getDimensionChangeDestination();
|
||||
|
||||
}
|
||||
+12
-5
@@ -6,6 +6,7 @@ import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -47,11 +48,17 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
@Override
|
||||
public IServerLevelWrapper getLevel()
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
return ServerLevelWrapper.getWrapper(this.serverPlayer().getLevel());
|
||||
#else
|
||||
return ServerLevelWrapper.getWrapper(this.serverPlayer().serverLevel());
|
||||
#endif
|
||||
ServerLevel level = ((IMixinServerPlayer) this.serverPlayer()).distantHorizons$getDimensionChangeDestination();
|
||||
if (level == null)
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
level = this.serverPlayer().getLevel();
|
||||
#else
|
||||
level = this.serverPlayer().serverLevel();
|
||||
#endif
|
||||
}
|
||||
|
||||
return ServerLevelWrapper.getWrapper(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -76,9 +76,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassMultiverse)
|
||||
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level, boolean bypassLevelKeyManager)
|
||||
{
|
||||
if (!bypassMultiverse)
|
||||
if (!bypassLevelKeyManager)
|
||||
{
|
||||
if (level == null)
|
||||
{
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 93b57ae2e1...9d11733444
+1
-1
@@ -132,7 +132,7 @@ public abstract class MixinMinecraft
|
||||
}
|
||||
if (level != null)
|
||||
{
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level));
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level, true));
|
||||
}
|
||||
this.lastLevel = level;
|
||||
}
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.fabric.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
#if MC_VER >= MC_1_21
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
#endif
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private ServerLevel dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||
#if MC_VER >= MC_1_21
|
||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.dimensionChangeDestination = dimensionTransition.newLevel();
|
||||
}
|
||||
#else
|
||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.dimensionChangeDestination = destination;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"mixins": [
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinUtilBackgroundThread"
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientLevel",
|
||||
|
||||
@@ -40,6 +40,7 @@ loom {
|
||||
ideConfigGenerated(false)
|
||||
runDir("../run/client")
|
||||
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
|
||||
programArgs("--username", "NoNick")
|
||||
}
|
||||
server {
|
||||
server()
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
#endif
|
||||
{
|
||||
LOGGER.info("level load");
|
||||
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
LevelAccessor level = event.getWorld();
|
||||
#else
|
||||
@@ -133,7 +133,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
// TODO this causes a crash due to level being set to null somewhere
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
#endif
|
||||
{
|
||||
LOGGER.info("level unload");
|
||||
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
LevelAccessor level = event.getWorld();
|
||||
#else
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.seibel.distanthorizons.forge.mixins.client;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
|
||||
@@ -11,7 +13,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.forge.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.common.util.ITeleporter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private volatile ServerLevel distantHorizons$dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.distantHorizons$dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension", remap = false)
|
||||
public void changeDimension(ServerLevel destination, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = destination;
|
||||
}
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"mixins": [
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinTFChunkGenerator"
|
||||
"server.MixinTFChunkGenerator",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientPacketListener",
|
||||
|
||||
@@ -131,7 +131,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
// TODO this causes a crash due to level being set to null somewhere
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class MixinClientPacketListener
|
||||
void onHandleLoginEnd(CallbackInfo ci)
|
||||
{
|
||||
ClientApi.INSTANCE.onClientOnlyConnected();
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level));
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level, true));
|
||||
}
|
||||
|
||||
#if MC_VER < MC_1_19_4
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020-2023 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.seibel.distanthorizons.neoforge.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
#if MC_VER >= MC_1_21
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
#endif
|
||||
|
||||
|
||||
@Mixin(ServerPlayer.class)
|
||||
public class MixinServerPlayer implements IMixinServerPlayer
|
||||
{
|
||||
@Unique
|
||||
@Nullable
|
||||
private ServerLevel distantHorizons$dimensionChangeDestination;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ServerLevel distantHorizons$getDimensionChangeDestination()
|
||||
{
|
||||
return this.distantHorizons$dimensionChangeDestination;
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "changeDimension")
|
||||
#if MC_VER >= MC_1_21
|
||||
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = dimensionTransition.newLevel();
|
||||
}
|
||||
#else
|
||||
public void changeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = destination;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
@Inject(at = @At("RETURN"), method = "setServerLevel")
|
||||
public void setServerLevel(ServerLevel level, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At("RETURN"), method = "setLevel")
|
||||
public void setLevel(ServerLevel level, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
this.distantHorizons$dimensionChangeDestination = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"mixins": [
|
||||
"server.MixinUtilBackgroundThread",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinTFChunkGenerator"
|
||||
"server.MixinTFChunkGenerator",
|
||||
"server.MixinServerPlayer"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinClientPacketListener",
|
||||
|
||||
Reference in New Issue
Block a user