Waterfall/BungeeCord-Patches/0043-Provide-an-option-to-d...

230 lines
12 KiB
Diff
Raw Normal View History

From 3eb3ba0ef9ff74b095ea44a1385af0b3a5a71293 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 e0baca9c..f3bced0a 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
@@ -252,4 +252,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 e10f33ad..c0c523e3 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
@@ -264,7 +264,8 @@ public class ServerConnector extends PacketHandler
2021-11-12 20:47:23 +01:00
ch.write( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:register" : "REGISTER", Joiner.on( "\0" ).join( registeredChannels ).getBytes( StandardCharsets.UTF_8 ), false ) );
}
- if ( user.getSettings() != null )
+ // Something deeper is going wrong here, but, as it stands, this project is EOL, so, we'll just shove this through.
2023-12-12 19:58:28 +01:00
+ if (user.getSettings() != null && (!user.isDisableEntityMetadataRewrite() || user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2))
{
ch.write( user.getSettings() );
}
@@ -319,6 +320,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(
@@ -342,6 +344,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() )
@@ -360,13 +363,34 @@ public class ServerConnector extends PacketHandler
}
user.setDimensionChange( true );
- if ( login.getDimension() == user.getDimension() )
+ if ( !user.isDisableEntityMetadataRewrite() && login.getDimension() == user.getDimension() ) // Waterfall - defer
{
user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
2023-09-21 12:33:23 +02:00
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
}
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 ( login.getDimension() != user.getDimension() ) // Waterfall - defer
+ {
Updated Upstream (BungeeCord) Upstream has released updates that appear 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: 5a1e342e Minecraft 1.20.2 support d9bbdc32 Add Java 21 compilation support cfe00fa4 #3490: Add ComponentBuilder#build() and ComponentSerializer#deserialize() d68ebd1e Minecraft 1.20.2-rc1 support a7cd79eb #3516: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 9e83ee6f #3508: Use same compression threshold checks as Vanilla 7c81d917 #3513: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 5b126b7f Fix javadoc plugin version in non-dist builds 9fe7d21f #3510: Bump actions/checkout from 3 to 4 94ea0271 #3505: Bump io.netty:netty-bom from 4.1.96.Final to 4.1.97.Final 3af672d2 #3504: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 0dd7b984 Bump version to 1.20-R0.2-SNAPSHOT a793692a Release 1.20-R0.1 23fb8382 #3493: Bump io.netty:netty-bom from 4.1.95.Final to 4.1.96.Final 2d6d89d6 #3492: Bump io.netty:netty-bom from 4.1.94.Final to 4.1.95.Final 0199cb90 #3489: Add command string length limit when decoding ClientCommand 958cef50 #3488: Bump scriptus from 0.4.1 to 0.5.0 9f5ace90 #3418: Add tab completion for bungee command names in pre-1.13 versions 3a6e2631 #3479: Bump netty-bom from 4.1.93.Final to 4.1.94.Final c7adcf9f Disable maven enforcer for now da3616e6 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends b371fe67 #3478: Bump maven-shade-plugin from 3.4.1 to 3.5.0 6324c7d5 #3401: Only synchronize necessary parts of the BungeeServerInfo#sendData method 6263fe28 #3426: Made find command output hover and clickable 9a7617f9 #3475: Add KickPlayerRaw channel 9a71358d #3439: Add GetPlayerServer bungee plugin message subchannel a96a2e80 #3437: Remove unused enum in ServerConnector and add color to exception message
2023-09-21 18:59:49 +02:00
+ user.unsafe().sendPacket( new Respawn( (Integer) user.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), (byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
+ }
2020-08-12 15:44:07 +02:00
+ Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
Updated Upstream (BungeeCord) Upstream has released updates that appear 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: 5a1e342e Minecraft 1.20.2 support d9bbdc32 Add Java 21 compilation support cfe00fa4 #3490: Add ComponentBuilder#build() and ComponentSerializer#deserialize() d68ebd1e Minecraft 1.20.2-rc1 support a7cd79eb #3516: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 9e83ee6f #3508: Use same compression threshold checks as Vanilla 7c81d917 #3513: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 5b126b7f Fix javadoc plugin version in non-dist builds 9fe7d21f #3510: Bump actions/checkout from 3 to 4 94ea0271 #3505: Bump io.netty:netty-bom from 4.1.96.Final to 4.1.97.Final 3af672d2 #3504: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 0dd7b984 Bump version to 1.20-R0.2-SNAPSHOT a793692a Release 1.20-R0.1 23fb8382 #3493: Bump io.netty:netty-bom from 4.1.95.Final to 4.1.96.Final 2d6d89d6 #3492: Bump io.netty:netty-bom from 4.1.94.Final to 4.1.95.Final 0199cb90 #3489: Add command string length limit when decoding ClientCommand 958cef50 #3488: Bump scriptus from 0.4.1 to 0.5.0 9f5ace90 #3418: Add tab completion for bungee command names in pre-1.13 versions 3a6e2631 #3479: Bump netty-bom from 4.1.93.Final to 4.1.94.Final c7adcf9f Disable maven enforcer for now da3616e6 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends b371fe67 #3478: Bump maven-shade-plugin from 3.4.1 to 3.5.0 6324c7d5 #3401: Only synchronize necessary parts of the BungeeServerInfo#sendData method 6263fe28 #3426: Made find command output hover and clickable 9a7617f9 #3475: Add KickPlayerRaw channel 9a71358d #3439: Add GetPlayerServer bungee plugin message subchannel a96a2e80 #3437: Remove unused enum in ServerConnector and add color to exception message
2023-09-21 18:59:49 +02:00
+ (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(),
+ login.getPortalCooldown(), login.isSecureProfile() );
+ user.unsafe().sendPacket(modLogin);
+ // Only send if we're in the same dimension
+ if ( login.getDimension() == user.getDimension() ) // Waterfall - defer
+ {
Updated Upstream (BungeeCord) Upstream has released updates that appear 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: 5a1e342e Minecraft 1.20.2 support d9bbdc32 Add Java 21 compilation support cfe00fa4 #3490: Add ComponentBuilder#build() and ComponentSerializer#deserialize() d68ebd1e Minecraft 1.20.2-rc1 support a7cd79eb #3516: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 9e83ee6f #3508: Use same compression threshold checks as Vanilla 7c81d917 #3513: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 5b126b7f Fix javadoc plugin version in non-dist builds 9fe7d21f #3510: Bump actions/checkout from 3 to 4 94ea0271 #3505: Bump io.netty:netty-bom from 4.1.96.Final to 4.1.97.Final 3af672d2 #3504: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 0dd7b984 Bump version to 1.20-R0.2-SNAPSHOT a793692a Release 1.20-R0.1 23fb8382 #3493: Bump io.netty:netty-bom from 4.1.95.Final to 4.1.96.Final 2d6d89d6 #3492: Bump io.netty:netty-bom from 4.1.94.Final to 4.1.95.Final 0199cb90 #3489: Add command string length limit when decoding ClientCommand 958cef50 #3488: Bump scriptus from 0.4.1 to 0.5.0 9f5ace90 #3418: Add tab completion for bungee command names in pre-1.13 versions 3a6e2631 #3479: Bump netty-bom from 4.1.93.Final to 4.1.94.Final c7adcf9f Disable maven enforcer for now da3616e6 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends b371fe67 #3478: Bump maven-shade-plugin from 3.4.1 to 3.5.0 6324c7d5 #3401: Only synchronize necessary parts of the BungeeServerInfo#sendData method 6263fe28 #3426: Made find command output hover and clickable 9a7617f9 #3475: Add KickPlayerRaw channel 9a71358d #3439: Add GetPlayerServer bungee plugin message subchannel a96a2e80 #3437: Remove unused enum in ServerConnector and add color to exception message
2023-09-21 18:59:49 +02:00
+ user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), (byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
+ }
+ }
+ // Waterfall end
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
2023-09-21 12:33:23 +02:00
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
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 d15f2bcc..b8762fc0 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -821,4 +821,9 @@ public final class UserConnection implements ProxiedPlayer
unsafe().sendPacket( new Transfer( host, port ) );
}
+ // Waterfall start
+ public boolean isDisableEntityMetadataRewrite() {
2019-12-02 04:30:55 +01:00
+ 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 ad9fc042..6ed25f82 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
@@ -757,6 +757,7 @@ public class DownstreamBridge extends PacketHandler
@Override
Updated Upstream (BungeeCord) Upstream has released updates that appear 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: 5a1e342e Minecraft 1.20.2 support d9bbdc32 Add Java 21 compilation support cfe00fa4 #3490: Add ComponentBuilder#build() and ComponentSerializer#deserialize() d68ebd1e Minecraft 1.20.2-rc1 support a7cd79eb #3516: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 9e83ee6f #3508: Use same compression threshold checks as Vanilla 7c81d917 #3513: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 5b126b7f Fix javadoc plugin version in non-dist builds 9fe7d21f #3510: Bump actions/checkout from 3 to 4 94ea0271 #3505: Bump io.netty:netty-bom from 4.1.96.Final to 4.1.97.Final 3af672d2 #3504: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 0dd7b984 Bump version to 1.20-R0.2-SNAPSHOT a793692a Release 1.20-R0.1 23fb8382 #3493: Bump io.netty:netty-bom from 4.1.95.Final to 4.1.96.Final 2d6d89d6 #3492: Bump io.netty:netty-bom from 4.1.94.Final to 4.1.95.Final 0199cb90 #3489: Add command string length limit when decoding ClientCommand 958cef50 #3488: Bump scriptus from 0.4.1 to 0.5.0 9f5ace90 #3418: Add tab completion for bungee command names in pre-1.13 versions 3a6e2631 #3479: Bump netty-bom from 4.1.93.Final to 4.1.94.Final c7adcf9f Disable maven enforcer for now da3616e6 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends b371fe67 #3478: Bump maven-shade-plugin from 3.4.1 to 3.5.0 6324c7d5 #3401: Only synchronize necessary parts of the BungeeServerInfo#sendData method 6263fe28 #3426: Made find command output hover and clickable 9a7617f9 #3475: Add KickPlayerRaw channel 9a71358d #3439: Add GetPlayerServer bungee plugin message subchannel a96a2e80 #3437: Remove unused enum in ServerConnector and add color to exception message
2023-09-21 18:59:49 +02:00
public void handle(net.md_5.bungee.protocol.packet.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()) {
@@ -768,6 +769,7 @@ public class DownstreamBridge extends PacketHandler
@Override
Updated Upstream (BungeeCord) Upstream has released updates that appear 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: 5a1e342e Minecraft 1.20.2 support d9bbdc32 Add Java 21 compilation support cfe00fa4 #3490: Add ComponentBuilder#build() and ComponentSerializer#deserialize() d68ebd1e Minecraft 1.20.2-rc1 support a7cd79eb #3516: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 9e83ee6f #3508: Use same compression threshold checks as Vanilla 7c81d917 #3513: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.4.0 to 3.4.1 5b126b7f Fix javadoc plugin version in non-dist builds 9fe7d21f #3510: Bump actions/checkout from 3 to 4 94ea0271 #3505: Bump io.netty:netty-bom from 4.1.96.Final to 4.1.97.Final 3af672d2 #3504: Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 0dd7b984 Bump version to 1.20-R0.2-SNAPSHOT a793692a Release 1.20-R0.1 23fb8382 #3493: Bump io.netty:netty-bom from 4.1.95.Final to 4.1.96.Final 2d6d89d6 #3492: Bump io.netty:netty-bom from 4.1.94.Final to 4.1.95.Final 0199cb90 #3489: Add command string length limit when decoding ClientCommand 958cef50 #3488: Bump scriptus from 0.4.1 to 0.5.0 9f5ace90 #3418: Add tab completion for bungee command names in pre-1.13 versions 3a6e2631 #3479: Bump netty-bom from 4.1.93.Final to 4.1.94.Final c7adcf9f Disable maven enforcer for now da3616e6 SPIGOT-7400: Downgrade maven-resolver due to issues resolving certain depends b371fe67 #3478: Bump maven-shade-plugin from 3.4.1 to 3.5.0 6324c7d5 #3401: Only synchronize necessary parts of the BungeeServerInfo#sendData method 6263fe28 #3426: Made find command output hover and clickable 9a7617f9 #3475: Add KickPlayerRaw channel 9a71358d #3439: Add GetPlayerServer bungee plugin message subchannel a96a2e80 #3437: Remove unused enum in ServerConnector and add color to exception message
2023-09-21 18:59:49 +02:00
public void handle(net.md_5.bungee.protocol.packet.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 ccebe19f..cb4f1098 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
2022-06-07 19:12:20 +02:00
@@ -27,6 +27,11 @@ public abstract class EntityMap
// 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()) {
+ return EntityMap_Dummy.INSTANCE;
+ }
+ // Waterfall end
switch ( version )
{
case ProtocolConstants.MINECRAFT_1_8:
@@ -304,7 +309,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.44.0