2019-04-23 10:09:26 +02:00
|
|
|
From fc9081afdc806555f78e430e6315dc2dfa23f2a3 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-04-23 10:09:26 +02:00
|
|
|
index 46adc983..0e69db36 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-04-23 10:09:26 +02:00
|
|
|
@@ -214,4 +214,9 @@ public interface ProxyConfig
|
2019-03-30 17:09:06 +01:00
|
|
|
* @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-04-22 21:56:28 +02:00
|
|
|
index f28f0111..41a71f65 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
|
2019-03-30 19:01:17 +01:00
|
|
|
@@ -53,6 +53,8 @@ public class WaterfallConfiguration extends Configuration {
|
2019-01-15 04:29:51 +01:00
|
|
|
*/
|
|
|
|
private boolean allowEmptyPackets = false;
|
|
|
|
|
|
|
|
+ private boolean disableEntityMetadataRewrite = false;
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void load() {
|
|
|
|
super.load();
|
2019-04-22 21:56:28 +02:00
|
|
|
@@ -65,6 +67,7 @@ public class WaterfallConfiguration extends Configuration {
|
2019-01-15 04:29:51 +01:00
|
|
|
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
|
2019-04-22 21:56:28 +02:00
|
|
|
@@ -96,4 +99,9 @@ public class WaterfallConfiguration extends Configuration {
|
2019-01-15 04:29:51 +01:00
|
|
|
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
|
2019-04-23 10:09:26 +02:00
|
|
|
index c8fc4e41..94545251 100644
|
2019-01-15 04:29:51 +01:00
|
|
|
--- 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(),
|
2019-04-23 10:09:26 +02:00
|
|
|
+ login.getDifficulty(), login.getMaxPlayers(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo() );
|
2019-01-15 04:29:51 +01:00
|
|
|
+ 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
|
2019-04-23 10:09:26 +02:00
|
|
|
index 74aa4f3e..7e9678d9 100644
|
2019-01-15 04:29:51 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
2019-04-22 21:56:28 +02:00
|
|
|
@@ -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
|
2019-01-15 04:29:51 +01:00
|
|
|
{
|
|
|
|
return serverSentScoreboard;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Waterfall start
|
|
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
2019-04-22 21:56:28 +02:00
|
|
|
+ return disableEntityMetadaRewrite;
|
2019-01-15 04:29:51 +01:00
|
|
|
+ }
|
|
|
|
+ // 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-04-23 10:09:26 +02:00
|
|
|
index fd14f518..fba84905 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-04-23 10:09:26 +02:00
|
|
|
@@ -588,6 +588,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-04-23 10:09:26 +02:00
|
|
|
@@ -599,6 +600,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());
|
|
|
|
}
|
|
|
|
|
2019-04-09 05:35:23 +02:00
|
|
|
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
|
2019-04-23 10:09:26 +02:00
|
|
|
index c1206a3f..f1ed6050 100644
|
2019-04-09 05:35:23 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -271,7 +271,13 @@ public abstract class EntityMap
|
|
|
|
DefinedPacket.readVarInt( packet );
|
2019-04-22 21:56:28 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-15 04:29:51 +01:00
|
|
|
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
|
|
|
|