Fix immersive portals
This commit is contained in:
@@ -26,8 +26,8 @@ package com.seibel.distanthorizons.coreapi;
|
||||
public final class ModInfo
|
||||
{
|
||||
public static final String ID = "distanthorizons";
|
||||
/** The internal protocol version used for networking */
|
||||
public static final int PROTOCOL_VERSION = 1;
|
||||
/** The internal protocol version used for networking. Incremented every time any packets are added, changed or removed. */
|
||||
public static final int PROTOCOL_VERSION = 2;
|
||||
/** The protocol version used for multiverse networking */
|
||||
public static final int MULTIVERSE_PLUGIN_PROTOCOL_VERSION = 1;
|
||||
/** The internal mod name */
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ public class WorldRemoteGenerationQueue extends AbstractFullDataRequestQueue imp
|
||||
return;
|
||||
};
|
||||
|
||||
CompletableFuture<GenTaskPriorityResponseMessage> request = this.networkState.getClient().sendRequest(new GenTaskPriorityRequestMessage(posList), GenTaskPriorityResponseMessage.class);
|
||||
CompletableFuture<GenTaskPriorityResponseMessage> request = this.networkState.getClient().sendRequest(new GenTaskPriorityRequestMessage(posList, this.level), GenTaskPriorityResponseMessage.class);
|
||||
this.genTaskPriorityRequest = request;
|
||||
request.handleAsync((response, throwable) -> {
|
||||
try
|
||||
|
||||
@@ -210,7 +210,11 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel
|
||||
{
|
||||
this.dataFileHandler.removeGenRequestIf(p -> !renderState.quadtree.isSectionPosInBounds(p));
|
||||
}
|
||||
this.worldGenModule.worldGenTick(new DhBlockPos2D(MC_CLIENT.getPlayerBlockPos()));
|
||||
|
||||
this.worldGenModule.worldGenTick(
|
||||
new DhBlockPos2D(MC_CLIENT.getPlayerBlockPos())
|
||||
.scale(MC_CLIENT.getWrappedClientLevel().getDimensionType().getTeleportationScale(this.getLevelWrapper().getDimensionType()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -19,6 +19,7 @@ import com.seibel.distanthorizons.core.network.messages.session.PlayerUUIDMessag
|
||||
import com.seibel.distanthorizons.core.network.messages.session.RemotePlayerConfigMessage;
|
||||
import com.seibel.distanthorizons.core.network.protocol.FutureTrackableNetworkMessage;
|
||||
import com.seibel.distanthorizons.core.network.protocol.NetworkMessage;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -112,23 +113,25 @@ public class RemotePlayerConnectionHandler implements Closeable
|
||||
{
|
||||
return this.connectedPlayersOnly((msg, serverPlayerState) ->
|
||||
{
|
||||
if (serverPlayerState.serverPlayer.getLevel() != level.getLevelWrapper())
|
||||
LodUtil.assertTrue(msg instanceof ILevelRelatedMessage, "Received message does not implement " + ILevelRelatedMessage.class.getSimpleName() + ": " + msg.getClass().getSimpleName());
|
||||
|
||||
// Handle only in requested dimension
|
||||
if (!((ILevelRelatedMessage) msg).isSameLevelAs(level.getLevelWrapper()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg instanceof ILevelRelatedMessage)
|
||||
// If player is not in this dimension and handling multiple dimensions at once is not allowed
|
||||
if (serverPlayerState.serverPlayer.getLevel() != level.getLevelWrapper()
|
||||
&& !GENERATE_MULTIPLE_DIMENSIONS_CONFIG.get())
|
||||
{
|
||||
if (!GENERATE_MULTIPLE_DIMENSIONS_CONFIG.get() && !((ILevelRelatedMessage) msg).isSameLevelAs(level.getLevelWrapper()))
|
||||
// If the message can be replied to - reply with error, otherwise just ignore
|
||||
if (msg instanceof FutureTrackableNetworkMessage)
|
||||
{
|
||||
if (msg instanceof FutureTrackableNetworkMessage)
|
||||
{
|
||||
((FutureTrackableNetworkMessage) msg).sendResponse(new InvalidLevelException("Invalid level"));
|
||||
}
|
||||
|
||||
return;
|
||||
((FutureTrackableNetworkMessage) msg).sendResponse(new InvalidLevelException("Invalid level"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
next.accept(msg, serverPlayerState);
|
||||
|
||||
-2
@@ -86,9 +86,7 @@ public class FullDataPartialUpdateMessage extends NetworkMessage implements ILev
|
||||
public void decode(ByteBuf in)
|
||||
{
|
||||
this.levelHashCode = in.readInt();
|
||||
|
||||
this.chunkPos = new DhChunkPos(in.readInt(), in.readInt());
|
||||
|
||||
this.dataBuffer = in.readBytes(in.readInt());
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.network.messages.fullData.generation;
|
||||
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.ILevelRelatedMessage;
|
||||
import com.seibel.distanthorizons.core.network.protocol.FutureTrackableNetworkMessage;
|
||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -26,25 +28,35 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenTaskPriorityRequestMessage extends FutureTrackableNetworkMessage
|
||||
public class GenTaskPriorityRequestMessage extends FutureTrackableNetworkMessage implements ILevelRelatedMessage
|
||||
{
|
||||
public List<DhSectionPos> posList = new ArrayList<>();
|
||||
|
||||
private int levelHashCode;
|
||||
@Override
|
||||
public int getLevelHashCode() { return this.levelHashCode; }
|
||||
|
||||
|
||||
public GenTaskPriorityRequestMessage() { }
|
||||
public GenTaskPriorityRequestMessage(List<DhSectionPos> posList)
|
||||
public GenTaskPriorityRequestMessage(List<DhSectionPos> posList, IDhLevel level)
|
||||
{
|
||||
this.posList = posList;
|
||||
|
||||
// TODO Multiverse support
|
||||
this.levelHashCode = level.getLevelWrapper().getDimensionType().getDimensionName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encode0(ByteBuf out)
|
||||
{
|
||||
out.writeInt(this.levelHashCode);
|
||||
this.encodeCollection(out, this.posList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode0(ByteBuf in)
|
||||
{
|
||||
this.levelHashCode = in.readInt();
|
||||
this.decodeCollection(in, this.posList, DhSectionPos::zero);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -74,9 +74,8 @@ public class MessageHandler extends SimpleChannelInboundHandler<NetworkMessage>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
|
||||
{
|
||||
super.exceptionCaught(ctx, cause);
|
||||
this.closeReasonConsumer.accept(ctx, cause);
|
||||
ctx.close();
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public class DhBlockPos2D
|
||||
|
||||
public DhBlockPos2D subtract(DhBlockPos2D other) { return new DhBlockPos2D(this.x - other.x, this.z - other.z); }
|
||||
|
||||
public DhBlockPos2D scale(double scale) { return new DhBlockPos2D((int) (this.x * scale), (int) (this.z * scale)); }
|
||||
|
||||
public Pos2D toPos2D() { return new Pos2D(this.x, this.z); }
|
||||
|
||||
|
||||
|
||||
+2
@@ -37,4 +37,6 @@ public interface IDimensionTypeWrapper extends IDhApiDimensionTypeWrapper, IBind
|
||||
@Override
|
||||
boolean hasSkyLight();
|
||||
|
||||
double getTeleportationScale(IDimensionTypeWrapper to);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user