mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-02 16:49:31 +01:00
3426625706
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: 4cccf537 Minecraft 1.15 support
237 lines
11 KiB
Diff
237 lines
11 KiB
Diff
From 0eba7da12fc8c161aa50d07bfcd616a8acbede73 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
Date: Mon, 14 Jan 2019 03:35:21 +0000
|
|
Subject: [PATCH] Provide an option to disable entity metadata rewriting
|
|
|
|
The work here is derived from the research and guidance of
|
|
various members of the minecraft community
|
|
|
|
This patch provides the ability to disable entity remapping,
|
|
which creates various incompatability issues with mods, however,
|
|
may also create various issues with mods which do not support this,
|
|
hence why the configuration option is provided
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
index 058cca67..6bc54495 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
@@ -207,4 +207,9 @@ public interface ProxyConfig
|
|
* @return should we disable the tab completion limit for 1.13+ clients
|
|
*/
|
|
boolean isDisableModernTabLimiter();
|
|
+
|
|
+ /**
|
|
+ * @return Should we disable entity metadata rewriting?
|
|
+ */
|
|
+ boolean isDisableEntityMetadataRewrite();
|
|
}
|
|
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
index 4ff8da6d..e860214f 100644
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
@@ -42,6 +42,8 @@ public class WaterfallConfiguration extends Configuration {
|
|
private int tabThrottle = 1000;
|
|
private boolean disableModernTabLimiter = true;
|
|
|
|
+ private boolean disableEntityMetadataRewrite = false;
|
|
+
|
|
@Override
|
|
public void load() {
|
|
super.load();
|
|
@@ -53,6 +55,7 @@ public class WaterfallConfiguration extends Configuration {
|
|
// Throttling options
|
|
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
+ disableEntityMetadataRewrite = config.getBoolean("disable_entity_metadata_rewrite", disableEntityMetadataRewrite);
|
|
}
|
|
|
|
@Override
|
|
@@ -79,4 +82,9 @@ public class WaterfallConfiguration extends Configuration {
|
|
public boolean isDisableModernTabLimiter() {
|
|
return disableModernTabLimiter;
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
|
+ return disableEntityMetadataRewrite;
|
|
+ }
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
index 7aa792a2..00cd477f 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -226,7 +226,7 @@ public class ServerConnector extends PacketHandler
|
|
ch.write( message );
|
|
}
|
|
|
|
- if ( user.getSettings() != null )
|
|
+ if (!user.isDisableEntityMetadataRewrite() && user.getSettings() != null )
|
|
{
|
|
ch.write( user.getSettings() );
|
|
}
|
|
@@ -260,6 +260,7 @@ public class ServerConnector extends PacketHandler
|
|
user.getTabListHandler().onServerChange();
|
|
|
|
Scoreboard serverScoreboard = user.getServerSentScoreboard();
|
|
+ if ( !user.isDisableEntityMetadataRewrite() ) { // Waterfall
|
|
for ( Objective objective : serverScoreboard.getObjectives() )
|
|
{
|
|
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) );
|
|
@@ -272,6 +273,7 @@ public class ServerConnector extends PacketHandler
|
|
{
|
|
user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) );
|
|
}
|
|
+ } // Waterfall
|
|
serverScoreboard.clear();
|
|
|
|
for ( UUID bossbar : user.getSentBossBars() )
|
|
@@ -285,12 +287,33 @@ public class ServerConnector extends PacketHandler
|
|
user.unsafe().sendPacket( new EntityStatus( user.getClientEntityId(), login.isReducedDebugInfo() ? EntityStatus.DEBUG_INFO_REDUCED : EntityStatus.DEBUG_INFO_NORMAL ) );
|
|
|
|
user.setDimensionChange( true );
|
|
- if ( login.getDimension() == user.getDimension() )
|
|
+ if ( !user.isDisableEntityMetadataRewrite() && login.getDimension() == user.getDimension() ) // Waterfall - defer
|
|
{
|
|
user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
|
}
|
|
|
|
user.setServerEntityId( login.getEntityId() );
|
|
+
|
|
+ // Waterfall start
|
|
+ if ( user.isDisableEntityMetadataRewrite() ) {
|
|
+ // Ensure that we maintain consistency
|
|
+ user.setClientEntityId( login.getEntityId() );
|
|
+
|
|
+ // Only send if we are not in the same dimension
|
|
+ if (user.getDimension() != login.getDimension()) {
|
|
+ user.unsafe().sendPacket( new Respawn(user.getDimension() == 0 ? -1 : 0, login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType()));
|
|
+ }
|
|
+
|
|
+ Login modLogin = new Login( login.getEntityId(),login.getGameMode(), login.getDimension(), login.getSeed(),
|
|
+ login.getDifficulty(), login.getMaxPlayers(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo(), login.isNormalRespawn() );
|
|
+ user.unsafe().sendPacket(modLogin);
|
|
+
|
|
+ // Only send if we're in the same dimension
|
|
+ if (user.getDimension() == login.getDimension()) {
|
|
+ user.unsafe().sendPacket( new Respawn(user.getDimension() == 0 ? -1 : 0, login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType()));
|
|
+ }
|
|
+ }
|
|
+ // Waterfall end
|
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
|
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
|
|
{
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
index 74aa4f3e..eeb7a51e 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
@@ -730,4 +730,10 @@ public final class UserConnection implements ProxiedPlayer
|
|
{
|
|
return serverSentScoreboard;
|
|
}
|
|
+
|
|
+ // Waterfall start
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
|
+ return entityRewrite == net.md_5.bungee.entitymap.EntityMap_Dummy.INSTANCE;
|
|
+ }
|
|
+ // Waterfall end
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index fd14f518..fba84905 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -588,6 +588,7 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
public void handle(EntityEffect entityEffect) throws Exception
|
|
{
|
|
+ if (con.isDisableEntityMetadataRewrite()) return; // Waterfall
|
|
// Don't send any potions when switching between servers (which involves a handshake), which can trigger a race
|
|
// condition on the client.
|
|
if (this.con.getForgeClientHandler().isForgeUser() && !this.con.getForgeClientHandler().isHandshakeComplete()) {
|
|
@@ -599,6 +600,7 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
public void handle(EntityRemoveEffect removeEffect) throws Exception
|
|
{
|
|
+ if (con.isDisableEntityMetadataRewrite()) return; // Waterfall
|
|
con.getPotions().remove(rewriteEntityId(removeEffect.getEntityId()), removeEffect.getEffectId());
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
index 298a99be..e5d566bd 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
@@ -8,6 +8,7 @@ import io.netty.buffer.ByteBufInputStream;
|
|
import java.io.IOException;
|
|
import lombok.AccessLevel;
|
|
import lombok.NoArgsConstructor;
|
|
+
|
|
import net.md_5.bungee.protocol.DefinedPacket;
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
@@ -27,6 +28,11 @@ public abstract class EntityMap
|
|
// Returns the correct entity map for the protocol version
|
|
public static EntityMap getEntityMap(int version)
|
|
{
|
|
+ // Waterfall start
|
|
+ if (net.md_5.bungee.api.ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite()) {
|
|
+ return EntityMap_Dummy.INSTANCE;
|
|
+ }
|
|
+ // Waterfall end
|
|
switch ( version )
|
|
{
|
|
case ProtocolConstants.MINECRAFT_1_8:
|
|
@@ -277,7 +283,13 @@ public abstract class EntityMap
|
|
DefinedPacket.readVarInt( packet );
|
|
break;
|
|
default:
|
|
- throw new IllegalArgumentException( "Unknown meta type " + type );
|
|
+ // Waterfall start - Don't lie
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
|
+ {
|
|
+ type++;
|
|
+ }
|
|
+ throw new IllegalArgumentException( "Unknown meta type " + type + ": Using mods? refer to disable_entity_metadata_rewrite in waterfall.yml" );
|
|
+ // Waterfall end
|
|
}
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java
|
|
new file mode 100644
|
|
index 00000000..cb81d1dd
|
|
--- /dev/null
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java
|
|
@@ -0,0 +1,30 @@
|
|
+
|
|
+package net.md_5.bungee.entitymap;
|
|
+
|
|
+import io.netty.buffer.ByteBuf;
|
|
+// Waterfall start
|
|
+
|
|
+public class EntityMap_Dummy extends EntityMap {
|
|
+
|
|
+ public static final EntityMap_Dummy INSTANCE = new EntityMap_Dummy();
|
|
+
|
|
+ EntityMap_Dummy() {
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) {
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion) {
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void rewriteClientbound(ByteBuf packet, int oldId, int newId) {
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) {
|
|
+ }
|
|
+}
|
|
+// Waterfall end
|
|
\ No newline at end of file
|
|
--
|
|
2.24.0
|
|
|