2019-03-30 17:09:06 +01:00
|
|
|
From fe4d850a54704e52323047ac9dc0248efe732242 Mon Sep 17 00:00:00 2001
|
2019-01-15 04:29:51 +01:00
|
|
|
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
|
2019-03-30 17:09:06 +01:00
|
|
|
index edc16a7d..4372f758 100644
|
2019-01-15 04:29:51 +01:00
|
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
2019-03-30 17:09:06 +01:00
|
|
|
@@ -222,4 +222,9 @@ public interface ProxyConfig
|
|
|
|
* @return should we allow empty packets
|
|
|
|
*/
|
2019-01-15 04:29:51 +01:00
|
|
|
boolean isAllowEmptyPackets();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @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
|
2019-03-06 16:35:52 +01:00
|
|
|
index 04b21d0f..42b17a69 100644
|
2019-01-15 04:29:51 +01:00
|
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
|
|
@@ -60,6 +60,8 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
*/
|
|
|
|
private boolean allowEmptyPackets = false;
|
|
|
|
|
|
|
|
+ private boolean disableEntityMetadataRewrite = false;
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void load() {
|
|
|
|
super.load();
|
|
|
|
@@ -73,6 +75,7 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
|
|
disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
|
|
allowEmptyPackets = config.getBoolean("allow_empty_packets", allowEmptyPackets);
|
|
|
|
+ disableEntityMetadataRewrite = config.getBoolean("disable_entity_metadata_rewrite", disableEntityMetadataRewrite);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -109,4 +112,9 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
public boolean isAllowEmptyPackets() {
|
2019-03-06 16:35:52 +01:00
|
|
|
return allowEmptyPackets;
|
2019-01-15 04:29:51 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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 c7f081d4..110ac496 100644
|
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
|
|
@@ -225,7 +225,7 @@ public class ServerConnector extends PacketHandler
|
|
|
|
ch.write( message );
|
|
|
|
}
|
|
|
|
|
|
|
|
- if ( user.getSettings() != null )
|
|
|
|
+ if (!user.isDisableEntityMetadataRewrite() && user.getSettings() != null )
|
|
|
|
{
|
|
|
|
ch.write( user.getSettings() );
|
|
|
|
}
|
|
|
|
@@ -259,6 +259,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 ) );
|
|
|
|
@@ -271,6 +272,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() )
|
|
|
|
@@ -284,12 +286,27 @@ 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.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
user.setServerEntityId( login.getEntityId() );
|
|
|
|
+ // Waterfall start
|
|
|
|
+ if ( user.isDisableEntityMetadataRewrite() ) {
|
|
|
|
+ // Ensure that we maintain consistency
|
|
|
|
+ user.setClientEntityId( login.getEntityId() );
|
|
|
|
+
|
|
|
|
+ Login modLogin = new Login( login.getEntityId(),login.getGameMode(), login.getDimension(),
|
|
|
|
+ login.getDifficulty(), login.getMaxPlayers(), login.getLevelType(), login.isReducedDebugInfo() );
|
|
|
|
+ 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.getDifficulty(), login.getGameMode(), login.getLevelType()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Waterfall end
|
|
|
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
|
|
|
user.setDimension( login.getDimension() );
|
|
|
|
|
|
|
|
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 9c872a1c..8a524a64 100644
|
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
@@ -145,6 +145,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
@Setter
|
|
|
|
private ForgeServerHandler forgeServerHandler;
|
|
|
|
/*========================================================================*/
|
|
|
|
+ private boolean disableEntityMetadaRewrite;
|
|
|
|
private final Unsafe unsafe = new Unsafe()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
@@ -156,6 +157,13 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
{
|
|
|
|
+ // Waterfall start
|
|
|
|
+ disableEntityMetadaRewrite = bungee.getConfig().isDisableEntityMetadataRewrite();
|
|
|
|
+ if ( disableEntityMetadaRewrite )
|
|
|
|
+ {
|
|
|
|
+ entityRewrite = net.md_5.bungee.entitymap.EntityMap_Dummy.INSTANCE;
|
|
|
|
+ } else
|
|
|
|
+ // Waterfall end
|
|
|
|
this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
|
|
|
|
|
|
|
this.displayName = name;
|
|
|
|
@@ -730,4 +738,10 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
{
|
|
|
|
return serverSentScoreboard;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Waterfall start
|
|
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
|
|
|
+ return disableEntityMetadaRewrite;
|
|
|
|
+ }
|
|
|
|
+ // 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
|
2019-03-06 16:35:52 +01:00
|
|
|
index f635a7e4..c1dc6489 100644
|
2019-01-15 04:29:51 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
2019-01-31 23:24:13 +01:00
|
|
|
@@ -590,6 +590,7 @@ public class DownstreamBridge extends PacketHandler
|
2019-01-15 04:29:51 +01:00
|
|
|
@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()) {
|
2019-01-31 23:24:13 +01:00
|
|
|
@@ -601,6 +602,7 @@ public class DownstreamBridge extends PacketHandler
|
2019-01-15 04:29:51 +01:00
|
|
|
@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_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
|
|
|
|
--
|
2019-03-06 16:35:52 +01:00
|
|
|
2.21.0
|
2019-01-15 04:29:51 +01:00
|
|
|
|