2020-05-08 20:40:13 +02:00
|
|
|
From d5377834246c8b9d93ee383981289e25d0a0e6e4 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
|
2020-02-01 16:39:53 +01:00
|
|
|
index e0baca9c..f3bced0a 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
|
2020-02-01 16:39:53 +01:00
|
|
|
@@ -252,4 +252,9 @@ public interface ProxyConfig
|
2019-09-24 06:46:15 +02:00
|
|
|
* @return should we disable the tab completion limit for 1.13+ clients
|
2019-03-30 17:09:06 +01:00
|
|
|
*/
|
2019-09-24 06:46:15 +02:00
|
|
|
boolean isDisableModernTabLimiter();
|
2019-01-15 04:29:51 +01:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @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-09-24 06:46:15 +02:00
|
|
|
index 4ff8da6d..e860214f 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-09-24 06:46:15 +02:00
|
|
|
@@ -42,6 +42,8 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
private int tabThrottle = 1000;
|
|
|
|
private boolean disableModernTabLimiter = true;
|
2019-01-15 04:29:51 +01:00
|
|
|
|
|
|
|
+ private boolean disableEntityMetadataRewrite = false;
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void load() {
|
|
|
|
super.load();
|
2019-09-24 06:46:15 +02:00
|
|
|
@@ -53,6 +55,7 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
// Throttling options
|
2019-01-15 04:29:51 +01:00
|
|
|
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
|
|
disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
|
|
+ disableEntityMetadataRewrite = config.getBoolean("disable_entity_metadata_rewrite", disableEntityMetadataRewrite);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-24 06:46:15 +02:00
|
|
|
@@ -79,4 +82,9 @@ public class WaterfallConfiguration extends Configuration {
|
|
|
|
public boolean isDisableModernTabLimiter() {
|
|
|
|
return disableModernTabLimiter;
|
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
|
2020-05-08 20:40:13 +02:00
|
|
|
index f594a287..35a19224 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
|
2020-03-07 23:50:46 +01:00
|
|
|
@@ -228,7 +228,7 @@ public class ServerConnector extends PacketHandler
|
2019-01-15 04:29:51 +01:00
|
|
|
ch.write( message );
|
|
|
|
}
|
|
|
|
|
|
|
|
- if ( user.getSettings() != null )
|
|
|
|
+ if (!user.isDisableEntityMetadataRewrite() && user.getSettings() != null )
|
|
|
|
{
|
|
|
|
ch.write( user.getSettings() );
|
|
|
|
}
|
2020-03-07 23:50:46 +01:00
|
|
|
@@ -262,6 +262,7 @@ public class ServerConnector extends PacketHandler
|
2019-01-15 04:29:51 +01:00
|
|
|
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 ) );
|
2020-03-07 23:50:46 +01:00
|
|
|
@@ -274,6 +275,7 @@ public class ServerConnector extends PacketHandler
|
2019-01-15 04:29:51 +01:00
|
|
|
{
|
|
|
|
user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) );
|
|
|
|
}
|
|
|
|
+ } // Waterfall
|
|
|
|
serverScoreboard.clear();
|
|
|
|
|
|
|
|
for ( UUID bossbar : user.getSentBossBars() )
|
2020-03-07 23:50:46 +01:00
|
|
|
@@ -292,12 +294,33 @@ public class ServerConnector extends PacketHandler
|
|
|
|
}
|
2019-01-15 04:29:51 +01:00
|
|
|
|
|
|
|
user.setDimensionChange( true );
|
|
|
|
- if ( login.getDimension() == user.getDimension() )
|
|
|
|
+ if ( !user.isDisableEntityMetadataRewrite() && login.getDimension() == user.getDimension() ) // Waterfall - defer
|
|
|
|
{
|
2019-12-10 23:53:39 +01:00
|
|
|
user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
2019-01-15 04:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
user.setServerEntityId( login.getEntityId() );
|
2019-12-10 23:53:39 +01:00
|
|
|
+
|
2019-01-15 04:29:51 +01:00
|
|
|
+ // Waterfall start
|
|
|
|
+ if ( user.isDisableEntityMetadataRewrite() ) {
|
|
|
|
+ // Ensure that we maintain consistency
|
|
|
|
+ user.setClientEntityId( login.getEntityId() );
|
|
|
|
+
|
2019-06-27 15:42:56 +02:00
|
|
|
+ // Only send if we are not in the same dimension
|
|
|
|
+ if (user.getDimension() != login.getDimension()) {
|
2019-12-10 23:53:39 +01:00
|
|
|
+ user.unsafe().sendPacket( new Respawn(user.getDimension() == 0 ? -1 : 0, login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType()));
|
2019-06-27 15:42:56 +02:00
|
|
|
+ }
|
|
|
|
+
|
2019-12-10 23:53:39 +01:00
|
|
|
+ Login modLogin = new Login( login.getEntityId(),login.getGameMode(), login.getDimension(), login.getSeed(),
|
|
|
|
+ login.getDifficulty(), login.getMaxPlayers(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo(), login.isNormalRespawn() );
|
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()) {
|
2019-12-10 23:53:39 +01:00
|
|
|
+ user.unsafe().sendPacket( new Respawn(user.getDimension() == 0 ? -1 : 0, login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType()));
|
2019-01-15 04:29:51 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Waterfall end
|
2019-12-10 23:53:39 +01:00
|
|
|
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) );
|
2019-04-30 05:19:02 +02:00
|
|
|
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
|
|
|
|
{
|
2019-01-15 04:29:51 +01:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
2020-05-08 20:40:13 +02:00
|
|
|
index 0c36ab52..87cff4ff 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
|
2020-01-24 23:41:39 +01:00
|
|
|
@@ -745,4 +745,10 @@ public final class UserConnection implements ProxiedPlayer
|
2019-01-15 04:29:51 +01:00
|
|
|
{
|
|
|
|
return serverSentScoreboard;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Waterfall start
|
|
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
2019-12-02 04:30:55 +01:00
|
|
|
+ return entityRewrite == net.md_5.bungee.entitymap.EntityMap_Dummy.INSTANCE;
|
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
|
2020-02-01 16:39:53 +01:00
|
|
|
index cfd25859..f845da09 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
|
2020-02-01 16:39:53 +01:00
|
|
|
@@ -601,6 +601,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()) {
|
2020-02-01 16:39:53 +01:00
|
|
|
@@ -612,6 +613,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
|
2020-01-24 23:41:39 +01:00
|
|
|
index 05e6b438..e6afb98d 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-12-21 07:54:52 +01:00
|
|
|
@@ -7,6 +7,7 @@ import io.netty.buffer.ByteBufInputStream;
|
2019-12-02 04:24:35 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
+
|
|
|
|
import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
|
2019-12-21 07:54:52 +01:00
|
|
|
@@ -26,6 +27,11 @@ public abstract class EntityMap
|
2019-12-02 04:24:35 +01:00
|
|
|
// Returns the correct entity map for the protocol version
|
|
|
|
public static EntityMap getEntityMap(int version)
|
|
|
|
{
|
|
|
|
+ // Waterfall start
|
2019-12-02 04:30:55 +01:00
|
|
|
+ if (net.md_5.bungee.api.ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite()) {
|
2019-12-02 04:24:35 +01:00
|
|
|
+ return EntityMap_Dummy.INSTANCE;
|
|
|
|
+ }
|
|
|
|
+ // Waterfall end
|
|
|
|
switch ( version )
|
|
|
|
{
|
|
|
|
case ProtocolConstants.MINECRAFT_1_8:
|
2020-01-21 22:50:55 +01:00
|
|
|
@@ -278,7 +284,13 @@ public abstract class EntityMap
|
2019-04-23 10:09:26 +02:00
|
|
|
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
|
|
|
|
--
|
2020-05-08 20:40:13 +02:00
|
|
|
2.26.1
|
2019-01-15 04:29:51 +01:00
|
|
|
|