mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-17 07:45:26 +01:00
3241 lines
161 KiB
Diff
3241 lines
161 KiB
Diff
From f293b6e489e70340e1f7fd46146bfa75e468a2d1 Mon Sep 17 00:00:00 2001
|
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
|
Date: Thu, 10 Mar 2022 20:23:55 -0300
|
|
Subject: [PATCH] Disable entity Metadata Rewrite
|
|
|
|
|
|
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 469fe0e12..97bd384b2 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
|
|
@@ -251,11 +251,6 @@ public interface ProxyConfig
|
|
*/
|
|
boolean isDisableModernTabLimiter();
|
|
|
|
- /**
|
|
- * @return Should we disable entity metadata rewriting?
|
|
- */
|
|
- boolean isDisableEntityMetadataRewrite();
|
|
-
|
|
/**
|
|
* Whether tablist rewriting should be disabled or not
|
|
* @return {@code true} if tablist rewriting is disabled, {@code false} otherwise
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java
|
|
index 0c334afcf..88865b851 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java
|
|
@@ -10,8 +10,6 @@ import net.md_5.bungee.protocol.packet.ClientStatus;
|
|
import net.md_5.bungee.protocol.packet.Commands;
|
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
|
-import net.md_5.bungee.protocol.packet.EntityEffect; // Waterfall
|
|
-import net.md_5.bungee.protocol.packet.EntityRemoveEffect; // Waterfall
|
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
|
import net.md_5.bungee.protocol.packet.GameState;
|
|
import net.md_5.bungee.protocol.packet.Handshake;
|
|
@@ -225,14 +223,4 @@ public abstract class AbstractPacketHandler
|
|
public void handle(ServerData serverData) throws Exception
|
|
{
|
|
}
|
|
-
|
|
- // Waterfall start
|
|
- public void handle(EntityEffect entityEffect) throws Exception
|
|
- {
|
|
- }
|
|
-
|
|
- public void handle(EntityRemoveEffect removeEffect) throws Exception
|
|
- {
|
|
- }
|
|
- // Waterfall end
|
|
}
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
index 022f94b2d..970011e8f 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
@@ -22,8 +22,6 @@ import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
|
import net.md_5.bungee.protocol.packet.GameState;
|
|
-import net.md_5.bungee.protocol.packet.EntityEffect;
|
|
-import net.md_5.bungee.protocol.packet.EntityRemoveEffect;
|
|
import net.md_5.bungee.protocol.packet.Handshake;
|
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
|
import net.md_5.bungee.protocol.packet.Kick;
|
|
@@ -140,20 +138,6 @@ public enum Protocol
|
|
map( ProtocolConstants.MINECRAFT_1_17, 0x0D ),
|
|
map( ProtocolConstants.MINECRAFT_1_19, 0x0A )
|
|
);
|
|
- // Waterfall start
|
|
- TO_CLIENT.registerPacket(
|
|
- EntityEffect.class,
|
|
- EntityEffect::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_7_2, 0x1D ), // FlameCord - 1.7.x support
|
|
- map(ProtocolConstants.MINECRAFT_1_9, -1)
|
|
- );
|
|
- TO_CLIENT.registerPacket(
|
|
- EntityRemoveEffect.class,
|
|
- EntityRemoveEffect::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_7_2, 0x1E ), // FlameCord - 1.7.x support
|
|
- map(ProtocolConstants.MINECRAFT_1_9, -1)
|
|
- );
|
|
- // Waterfall end
|
|
TO_CLIENT.registerPacket(
|
|
PlayerListItem.class, // PlayerInfo
|
|
PlayerListItem::new,
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java
|
|
deleted file mode 100644
|
|
index 0ed78a8c4..000000000
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java
|
|
+++ /dev/null
|
|
@@ -1,67 +0,0 @@
|
|
-package net.md_5.bungee.protocol.packet;
|
|
-
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import lombok.AllArgsConstructor;
|
|
-import lombok.Data;
|
|
-import lombok.EqualsAndHashCode;
|
|
-import lombok.NoArgsConstructor;
|
|
-import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-@Data
|
|
-@NoArgsConstructor
|
|
-@AllArgsConstructor
|
|
-@EqualsAndHashCode(callSuper = false)
|
|
-public class EntityEffect extends DefinedPacket {
|
|
-
|
|
- private int entityId;
|
|
- private int effectId;
|
|
- private int amplifier;
|
|
- private int duration;
|
|
- private boolean hideParticles;
|
|
-
|
|
- @Override
|
|
- public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
- this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support
|
|
- this.effectId = buf.readUnsignedByte();
|
|
- this.amplifier = buf.readUnsignedByte();
|
|
- this.duration = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readShort(); // FlameCord - 1.7.x support
|
|
- // FlameCord start - 1.7.x support
|
|
- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
|
- {
|
|
- this.hideParticles = buf.readBoolean();
|
|
- }
|
|
- // FlameCord end - 1.7.x support
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
- // FlameCord start - 1.7.x support
|
|
- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
- {
|
|
- writeVarInt(this.entityId, buf);
|
|
- } else
|
|
- {
|
|
- buf.writeInt(effectId);
|
|
- }
|
|
- // FlameCord end - 1.7.x support
|
|
- buf.writeByte(this.effectId);
|
|
- buf.writeByte(this.amplifier);
|
|
- // FlameCord start - 1.7.x support
|
|
- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
- {
|
|
- writeVarInt(this.duration, buf);
|
|
- } else
|
|
- {
|
|
- buf.writeShort(duration);
|
|
- }
|
|
- // FlameCord end - 1.7.x support
|
|
- buf.writeBoolean(this.hideParticles);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void handle(AbstractPacketHandler handler) throws Exception {
|
|
- handler.handle(this);
|
|
- }
|
|
-}
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java
|
|
deleted file mode 100644
|
|
index 435b85789..000000000
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java
|
|
+++ /dev/null
|
|
@@ -1,45 +0,0 @@
|
|
-package net.md_5.bungee.protocol.packet;
|
|
-
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import lombok.AllArgsConstructor;
|
|
-import lombok.Data;
|
|
-import lombok.EqualsAndHashCode;
|
|
-import lombok.NoArgsConstructor;
|
|
-import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-@Data
|
|
-@NoArgsConstructor
|
|
-@AllArgsConstructor
|
|
-@EqualsAndHashCode(callSuper = false)
|
|
-public class EntityRemoveEffect extends DefinedPacket {
|
|
-
|
|
- private int entityId;
|
|
- private int effectId;
|
|
-
|
|
- @Override
|
|
- public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
- this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support
|
|
- this.effectId = buf.readUnsignedByte();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
- // FlameCord start - 1.7.x support
|
|
- if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
- {
|
|
- writeVarInt(this.entityId, buf);
|
|
- } else
|
|
- {
|
|
- buf.writeInt(entityId);
|
|
- }
|
|
- // FlameCord end - 1.7.x support
|
|
- buf.writeByte(effectId);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void handle(AbstractPacketHandler handler) throws Exception {
|
|
- handler.handle(this);
|
|
- }
|
|
-}
|
|
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 966d2442b..be337a680 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,7 +42,6 @@ public class WaterfallConfiguration extends Configuration {
|
|
private int tabThrottle = 1000;
|
|
private boolean disableModernTabLimiter = true;
|
|
|
|
- private boolean disableEntityMetadataRewrite = false;
|
|
private boolean disableTabListRewrite = true;
|
|
|
|
/*
|
|
@@ -74,7 +73,6 @@ 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);
|
|
disableTabListRewrite = config.getBoolean("disable_tab_list_rewrite", disableTabListRewrite);
|
|
pluginChannelLimit = config.getInt("registered_plugin_channels_limit", pluginChannelLimit);
|
|
pluginChannelNameLimit = config.getInt("plugin_channel_name_limit", pluginChannelNameLimit);
|
|
@@ -105,11 +103,6 @@ public class WaterfallConfiguration extends Configuration {
|
|
return disableModernTabLimiter;
|
|
}
|
|
|
|
- @Override
|
|
- public boolean isDisableEntityMetadataRewrite() {
|
|
- return disableEntityMetadataRewrite;
|
|
- }
|
|
-
|
|
@Override
|
|
public boolean isDisableTabListRewrite() {
|
|
return disableTabListRewrite;
|
|
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 3a07c7c8a..f51c668d7 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -245,11 +245,6 @@ public class ServerConnector extends PacketHandler
|
|
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.isDisableEntityMetadataRewrite() && user.getSettings() != null )
|
|
- {
|
|
- ch.write( user.getSettings() );
|
|
- }
|
|
-
|
|
if ( user.getForgeClientHandler().getClientModList() == null && !user.getForgeClientHandler().isHandshakeComplete() ) // Vanilla
|
|
{
|
|
user.getForgeClientHandler().setHandshakeComplete();
|
|
@@ -308,20 +303,6 @@ 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(), objective.getType() == null ? null : ScoreboardObjective.HealthDisplay.fromString(objective.getType()), (byte) 1 ) ); // FlameCord - 1.7 support
|
|
- }
|
|
- for ( Score score : serverScoreboard.getScores() )
|
|
- {
|
|
- user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue() ) );
|
|
- }
|
|
- for ( Team team : serverScoreboard.getTeams() )
|
|
- {
|
|
- user.unsafe().sendPacket( new net.md_5.bungee.protocol.packet.Team( team.getName() ) );
|
|
- }
|
|
- } // Waterfall
|
|
serverScoreboard.clear();
|
|
|
|
for ( UUID bossbar : user.getSentBossBars() )
|
|
@@ -340,33 +321,27 @@ public class ServerConnector extends PacketHandler
|
|
}
|
|
|
|
user.setDimensionChange( true );
|
|
- 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(), false, login.getDeathLocation() ) );
|
|
- }
|
|
|
|
user.setServerEntityId( login.getEntityId() );
|
|
|
|
// Waterfall start
|
|
- if ( user.isDisableEntityMetadataRewrite() ) {
|
|
- // Ensure that we maintain consistency
|
|
- user.setClientEntityId( login.getEntityId() );
|
|
+ // 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
|
|
- {
|
|
- 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(), false, login.getDeathLocation() ) );
|
|
- }
|
|
+ // Only send if we are not in the same dimension
|
|
+ if ( login.getDimension() != user.getDimension() ) // Waterfall - defer
|
|
+ {
|
|
+ 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(), false, login.getDeathLocation() ) );
|
|
+ }
|
|
|
|
- Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
|
|
- (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat(), login.getDeathLocation() );
|
|
- user.unsafe().sendPacket(modLogin);
|
|
+ Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
|
|
+ (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat(), login.getDeathLocation() );
|
|
+ user.unsafe().sendPacket(modLogin);
|
|
|
|
- // Only send if we're in the same dimension
|
|
- if ( 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(), false, login.getDeathLocation() ) );
|
|
- }
|
|
+ // Only send if we're in the same dimension
|
|
+ if ( 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(), false, login.getDeathLocation() ) );
|
|
}
|
|
// 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(), false, login.getDeathLocation() ) );
|
|
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 909227970..f3d60253f 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
@@ -44,7 +44,6 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
|
import net.md_5.bungee.api.score.Scoreboard;
|
|
import net.md_5.bungee.chat.ComponentSerializer;
|
|
import net.md_5.bungee.connection.InitialHandler;
|
|
-import net.md_5.bungee.entitymap.EntityMap;
|
|
import net.md_5.bungee.forge.ForgeClientHandler;
|
|
import net.md_5.bungee.forge.ForgeConstants;
|
|
import net.md_5.bungee.forge.ForgeServerHandler;
|
|
@@ -137,8 +136,6 @@ public final class UserConnection implements ProxiedPlayer
|
|
/*========================================================================*/
|
|
@Getter
|
|
private String displayName;
|
|
- @Getter
|
|
- private EntityMap entityRewrite;
|
|
private Locale locale;
|
|
/*========================================================================*/
|
|
@Getter
|
|
@@ -159,8 +156,6 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
public void init()
|
|
{
|
|
- this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
|
-
|
|
this.displayName = name;
|
|
|
|
tabListHandler = new ServerUnique( this );
|
|
@@ -794,10 +789,4 @@ 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 0ac22ad38..6e425764b 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
|
|
@@ -46,7 +46,6 @@ import net.md_5.bungee.api.score.Score;
|
|
import net.md_5.bungee.api.score.Scoreboard;
|
|
import net.md_5.bungee.api.score.Team;
|
|
import net.md_5.bungee.chat.ComponentSerializer;
|
|
-import net.md_5.bungee.entitymap.EntityMap;
|
|
import net.md_5.bungee.netty.ChannelWrapper;
|
|
import net.md_5.bungee.netty.PacketHandler;
|
|
import net.md_5.bungee.protocol.DefinedPacket;
|
|
@@ -54,8 +53,6 @@ import net.md_5.bungee.protocol.PacketWrapper;
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
import net.md_5.bungee.protocol.packet.BossBar;
|
|
import net.md_5.bungee.protocol.packet.Commands;
|
|
-import net.md_5.bungee.protocol.packet.EntityEffect;
|
|
-import net.md_5.bungee.protocol.packet.EntityRemoveEffect;
|
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
|
import net.md_5.bungee.protocol.packet.Kick;
|
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
|
@@ -150,11 +147,6 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
public void handle(PacketWrapper packet) throws Exception
|
|
{
|
|
- EntityMap rewrite = con.getEntityRewrite();
|
|
- if ( rewrite != null )
|
|
- {
|
|
- rewrite.rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId(), con.getPendingConnection().getVersion() );
|
|
- }
|
|
con.sendPacket( packet );
|
|
}
|
|
|
|
@@ -705,34 +697,6 @@ public class DownstreamBridge extends PacketHandler
|
|
}
|
|
}
|
|
|
|
- // Waterfall start
|
|
- @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()) {
|
|
- throw CancelSendSignal.INSTANCE;
|
|
- }
|
|
- con.getPotions().put(rewriteEntityId(entityEffect.getEntityId()), entityEffect.getEffectId());
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void handle(EntityRemoveEffect removeEffect) throws Exception
|
|
- {
|
|
- if (con.isDisableEntityMetadataRewrite()) return; // Waterfall
|
|
- con.getPotions().remove(rewriteEntityId(removeEffect.getEntityId()), removeEffect.getEffectId());
|
|
- }
|
|
-
|
|
- private int rewriteEntityId(int entityId) {
|
|
- if (entityId == con.getServerEntityId()) {
|
|
- return con.getClientEntityId();
|
|
- }
|
|
- return entityId;
|
|
- }
|
|
- // Waterfall end
|
|
-
|
|
@Override
|
|
public void handle(Respawn respawn)
|
|
{
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
index 667364aea..10e46779f 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
@@ -25,7 +25,6 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
|
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
|
import net.md_5.bungee.api.event.TabCompleteEvent;
|
|
-import net.md_5.bungee.entitymap.EntityMap;
|
|
import net.md_5.bungee.forge.ForgeConstants;
|
|
import net.md_5.bungee.netty.ChannelWrapper;
|
|
import net.md_5.bungee.netty.PacketHandler;
|
|
@@ -145,11 +144,6 @@ public class UpstreamBridge extends PacketHandler
|
|
{
|
|
if ( con.getServer() != null )
|
|
{
|
|
- EntityMap rewrite = con.getEntityRewrite();
|
|
- if ( rewrite != null )
|
|
- {
|
|
- rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
|
- }
|
|
con.getServer().getCh().write( packet );
|
|
}
|
|
}
|
|
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
|
|
deleted file mode 100644
|
|
index 688ff72d2..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
+++ /dev/null
|
|
@@ -1,372 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import io.netty.buffer.ByteBufInputStream;
|
|
-import java.io.DataInputStream;
|
|
-import lombok.AccessLevel;
|
|
-import lombok.NoArgsConstructor;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-import se.llbit.nbt.NamedTag;
|
|
-import se.llbit.nbt.Tag;
|
|
-
|
|
-/**
|
|
- * Class to rewrite integers within packets.
|
|
- */
|
|
-@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
|
-public abstract class EntityMap
|
|
-{
|
|
-
|
|
- private final boolean[] clientboundInts = new boolean[ 256 ];
|
|
- private final boolean[] clientboundVarInts = new boolean[ 256 ];
|
|
-
|
|
- private final boolean[] serverboundInts = new boolean[ 256 ];
|
|
- private final boolean[] serverboundVarInts = new boolean[ 256 ];
|
|
-
|
|
- // 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 )
|
|
- {
|
|
- // FlameCord start - 1.7.x support
|
|
- case ProtocolConstants.MINECRAFT_1_7_2:
|
|
- return EntityMap_1_7_2.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_7_6:
|
|
- return EntityMap_1_7_6.INSTANCE;
|
|
- // FlameCord end - 1.7.x support
|
|
- case ProtocolConstants.MINECRAFT_1_8:
|
|
- return EntityMap_1_8.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_9:
|
|
- case ProtocolConstants.MINECRAFT_1_9_1:
|
|
- case ProtocolConstants.MINECRAFT_1_9_2:
|
|
- return EntityMap_1_9.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_9_4:
|
|
- return EntityMap_1_9_4.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_10:
|
|
- return EntityMap_1_10.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_11:
|
|
- case ProtocolConstants.MINECRAFT_1_11_1:
|
|
- return EntityMap_1_11.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_12:
|
|
- return EntityMap_1_12.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_12_1:
|
|
- case ProtocolConstants.MINECRAFT_1_12_2:
|
|
- return EntityMap_1_12_1.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_13:
|
|
- case ProtocolConstants.MINECRAFT_1_13_1:
|
|
- case ProtocolConstants.MINECRAFT_1_13_2:
|
|
- return EntityMap_1_13.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_14:
|
|
- case ProtocolConstants.MINECRAFT_1_14_1:
|
|
- case ProtocolConstants.MINECRAFT_1_14_2:
|
|
- case ProtocolConstants.MINECRAFT_1_14_3:
|
|
- case ProtocolConstants.MINECRAFT_1_14_4:
|
|
- return EntityMap_1_14.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_15:
|
|
- case ProtocolConstants.MINECRAFT_1_15_1:
|
|
- case ProtocolConstants.MINECRAFT_1_15_2:
|
|
- return EntityMap_1_15.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_16:
|
|
- case ProtocolConstants.MINECRAFT_1_16_1:
|
|
- return EntityMap_1_16.INSTANCE;
|
|
- case ProtocolConstants.MINECRAFT_1_16_2:
|
|
- case ProtocolConstants.MINECRAFT_1_16_3:
|
|
- case ProtocolConstants.MINECRAFT_1_16_4:
|
|
- return EntityMap_1_16_2.INSTANCE_1_16_2;
|
|
- case ProtocolConstants.MINECRAFT_1_17:
|
|
- case ProtocolConstants.MINECRAFT_1_17_1:
|
|
- return EntityMap_1_16_2.INSTANCE_1_17;
|
|
- case ProtocolConstants.MINECRAFT_1_18:
|
|
- case ProtocolConstants.MINECRAFT_1_18_2:
|
|
- return EntityMap_1_16_2.INSTANCE_1_18;
|
|
- case ProtocolConstants.MINECRAFT_1_19:
|
|
- return EntityMap_1_16_2.INSTANCE_1_19;
|
|
- case ProtocolConstants.MINECRAFT_1_19_1:
|
|
- case ProtocolConstants.MINECRAFT_1_19_3:
|
|
- return EntityMap_1_16_2.INSTANCE_1_19_1;
|
|
- }
|
|
- throw new RuntimeException( "Version " + version + " has no entity map" );
|
|
- }
|
|
-
|
|
- protected void addRewrite(int id, ProtocolConstants.Direction direction, boolean varint)
|
|
- {
|
|
- if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
|
- {
|
|
- if ( varint )
|
|
- {
|
|
- clientboundVarInts[id] = true;
|
|
- } else
|
|
- {
|
|
- clientboundInts[id] = true;
|
|
- }
|
|
- } else if ( varint )
|
|
- {
|
|
- serverboundVarInts[id] = true;
|
|
- } else
|
|
- {
|
|
- serverboundInts[id] = true;
|
|
- }
|
|
- }
|
|
-
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- rewrite( packet, oldId, newId, serverboundInts, serverboundVarInts );
|
|
- }
|
|
-
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- rewriteServerbound( packet, oldId, newId );
|
|
- }
|
|
-
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- rewrite( packet, oldId, newId, clientboundInts, clientboundVarInts );
|
|
- }
|
|
-
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- rewriteClientbound( packet, oldId, newId );
|
|
- }
|
|
-
|
|
- protected static void rewriteInt(ByteBuf packet, int oldId, int newId, int offset)
|
|
- {
|
|
- int readId = packet.getInt( offset );
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( offset, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( offset, oldId );
|
|
- }
|
|
- }
|
|
-
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- protected static void rewriteVarInt(ByteBuf packet, int oldId, int newId, int offset)
|
|
- {
|
|
- // Need to rewrite the packet because VarInts are variable length
|
|
- int readId = DefinedPacket.readVarInt( packet );
|
|
- int readIdLength = packet.readerIndex() - offset;
|
|
- if ( readId == oldId || readId == newId )
|
|
- {
|
|
- ByteBuf data = packet.copy();
|
|
-
|
|
- try {
|
|
- packet.readerIndex( offset );
|
|
- packet.writerIndex( offset );
|
|
- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet );
|
|
- packet.writeBytes( data );
|
|
- } finally {
|
|
- data.release();
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex)
|
|
- {
|
|
- rewriteMetaVarInt( packet, oldId, newId, metaIndex, -1 );
|
|
- }
|
|
-
|
|
- protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex, int protocolVersion)
|
|
- {
|
|
- int readerIndex = packet.readerIndex();
|
|
-
|
|
- short index;
|
|
- while ( ( index = packet.readUnsignedByte() ) != 0xFF )
|
|
- {
|
|
- int type = DefinedPacket.readVarInt( packet );
|
|
- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
|
- {
|
|
- switch ( type )
|
|
- {
|
|
- case 5: // optional chat
|
|
- if ( packet.readBoolean() )
|
|
- {
|
|
- DefinedPacket.readString( packet );
|
|
- }
|
|
- continue;
|
|
- case 15: // particle
|
|
- int particleId = DefinedPacket.readVarInt( packet );
|
|
-
|
|
- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_14 )
|
|
- {
|
|
- switch ( particleId )
|
|
- {
|
|
- case 3: // minecraft:block
|
|
- case 23: // minecraft:falling_dust
|
|
- DefinedPacket.readVarInt( packet ); // block state
|
|
- break;
|
|
- case 14: // minecraft:dust
|
|
- packet.skipBytes( 16 ); // float, float, float, flat
|
|
- break;
|
|
- case 32: // minecraft:item
|
|
- readSkipSlot( packet, protocolVersion );
|
|
- break;
|
|
- }
|
|
- } else
|
|
- {
|
|
- switch ( particleId )
|
|
- {
|
|
- case 3: // minecraft:block
|
|
- case 20: // minecraft:falling_dust
|
|
- DefinedPacket.readVarInt( packet ); // block state
|
|
- break;
|
|
- case 11: // minecraft:dust
|
|
- packet.skipBytes( 16 ); // float, float, float, flat
|
|
- break;
|
|
- case 27: // minecraft:item
|
|
- readSkipSlot( packet, protocolVersion );
|
|
- break;
|
|
- }
|
|
- }
|
|
- continue;
|
|
- default:
|
|
- if ( type >= 6 )
|
|
- {
|
|
- type--;
|
|
- }
|
|
- break;
|
|
- }
|
|
- }
|
|
-
|
|
- switch ( type )
|
|
- {
|
|
- case 0:
|
|
- packet.skipBytes( 1 ); // byte
|
|
- break;
|
|
- case 1:
|
|
- if ( index == metaIndex )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, position );
|
|
- packet.readerIndex( position );
|
|
- }
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- case 2:
|
|
- packet.skipBytes( 4 ); // float
|
|
- break;
|
|
- case 3:
|
|
- case 4:
|
|
- DefinedPacket.readString( packet );
|
|
- break;
|
|
- case 5:
|
|
- readSkipSlot( packet, protocolVersion );
|
|
- break;
|
|
- case 6:
|
|
- packet.skipBytes( 1 ); // boolean
|
|
- break;
|
|
- case 7:
|
|
- packet.skipBytes( 12 ); // float, float, float
|
|
- break;
|
|
- case 8:
|
|
- packet.readLong();
|
|
- break;
|
|
- case 9:
|
|
- if ( packet.readBoolean() )
|
|
- {
|
|
- packet.skipBytes( 8 ); // long
|
|
- }
|
|
- break;
|
|
- case 10:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- case 11:
|
|
- if ( packet.readBoolean() )
|
|
- {
|
|
- packet.skipBytes( 16 ); // long, long
|
|
- }
|
|
- break;
|
|
- case 12:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- case 13:
|
|
- Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) );
|
|
- if ( tag.isError() )
|
|
- {
|
|
- throw new RuntimeException( tag.error() );
|
|
- }
|
|
- break;
|
|
- case 15:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- case 16:
|
|
- if ( index == metaIndex )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId + 1, newId + 1, position );
|
|
- packet.readerIndex( position );
|
|
- }
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- case 17:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- break;
|
|
- default:
|
|
- // 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
|
|
- }
|
|
- }
|
|
-
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- private static void readSkipSlot(ByteBuf packet, int protocolVersion)
|
|
- {
|
|
- if ( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2 ) ? packet.readBoolean() : packet.readShort() != -1 )
|
|
- {
|
|
- if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2 )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.skipBytes( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? 1 : 3 ); // byte vs byte, short
|
|
-
|
|
- int position = packet.readerIndex();
|
|
- if ( packet.readByte() != 0 )
|
|
- {
|
|
- packet.readerIndex( position );
|
|
-
|
|
- Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( packet ) ) );
|
|
- if ( tag.isError() )
|
|
- {
|
|
- throw new RuntimeException( tag.error() );
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- // Handles simple packets
|
|
- private static void rewrite(ByteBuf packet, int oldId, int newId, boolean[] ints, boolean[] varints)
|
|
- {
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if (packetId < 0 || packetId > ints.length || packetId > varints.length) { // Invalid packet id
|
|
- // Ignore these invalid packets for compatibility reasons
|
|
- packet.readerIndex( readerIndex );
|
|
- return;
|
|
- }
|
|
-
|
|
- if ( ints[packetId] )
|
|
- {
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength );
|
|
- } else if ( varints[packetId] )
|
|
- {
|
|
- rewriteVarInt( packet, oldId, newId, readerIndex + packetIdLength );
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java
|
|
deleted file mode 100644
|
|
index 6db530c3a..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java
|
|
+++ /dev/null
|
|
@@ -1,182 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_10 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_10 INSTANCE = new EntityMap_1_10();
|
|
-
|
|
- EntityMap_1_10()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount
|
|
- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x48 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x40 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java
|
|
deleted file mode 100644
|
|
index 368221275..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java
|
|
+++ /dev/null
|
|
@@ -1,183 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_11 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_11 INSTANCE = new EntityMap_1_11();
|
|
-
|
|
- EntityMap_1_11()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount
|
|
- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x48 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x40 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java
|
|
deleted file mode 100644
|
|
index 38e12ce40..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java
|
|
+++ /dev/null
|
|
@@ -1,183 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_12 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_12 INSTANCE = new EntityMap_1_12();
|
|
-
|
|
- EntityMap_1_12()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x32, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x35, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x15, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3C /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x4A /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x42 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x31 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x3B /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java
|
|
deleted file mode 100644
|
|
index 5f2968394..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java
|
|
+++ /dev/null
|
|
@@ -1,183 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_12_1 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_12_1 INSTANCE = new EntityMap_1_12_1();
|
|
-
|
|
- EntityMap_1_12_1()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x30, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3D, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x4C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4E, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x15, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3D /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x4B /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x43 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x32 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2D /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x3C /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 7 ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 13 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java
|
|
deleted file mode 100644
|
|
index f3372f088..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java
|
|
+++ /dev/null
|
|
@@ -1,183 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_13 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_13 INSTANCE = new EntityMap_1_13();
|
|
-
|
|
- EntityMap_1_13()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x41, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x50, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x52, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x53, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0D, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x19, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x40 /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x4F /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x46 /* Set Passengers : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2F /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x3F /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6, protocolVersion ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 7, protocolVersion ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 13, protocolVersion ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java
|
|
deleted file mode 100644
|
|
index 8210b0a7e..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java
|
|
+++ /dev/null
|
|
@@ -1,187 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_14 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_14 INSTANCE = new EntityMap_1_14();
|
|
-
|
|
- EntityMap_1_14()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x55, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x58, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x44 /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x55 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x4A /* Set Passengers : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = DefinedPacket.readVarInt( packet );
|
|
-
|
|
- if ( type == 2 || type == 101 || type == 71 ) // arrow, fishing_bobber or spectral_arrow
|
|
- {
|
|
- if ( type == 2 || type == 71 ) // arrow or spectral_arrow
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x32 /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x43 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 15, protocolVersion ); // guardian beam
|
|
- break;
|
|
- case 0x50 /* Entity Sound Effect : PacketPlayOutEntitySound */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java
|
|
deleted file mode 100644
|
|
index c2cf810f3..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java
|
|
+++ /dev/null
|
|
@@ -1,187 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_15 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_15 INSTANCE = new EntityMap_1_15();
|
|
-
|
|
- EntityMap_1_15()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x09, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x57, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x5A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x56 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x4B /* Set Passengers : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x38 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = DefinedPacket.readVarInt( packet );
|
|
-
|
|
- if ( type == 2 || type == 102 || type == 72 ) // arrow, fishing_bobber or spectral_arrow
|
|
- {
|
|
- if ( type == 2 || type == 72 ) // arrow or spectral_arrow
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x33 /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 16, protocolVersion ); // guardian beam
|
|
- break;
|
|
- case 0x51 /* Entity Sound Effect : PacketPlayOutEntitySound */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java
|
|
deleted file mode 100644
|
|
index c8b067071..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java
|
|
+++ /dev/null
|
|
@@ -1,187 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_16 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_16 INSTANCE = new EntityMap_1_16();
|
|
-
|
|
- EntityMap_1_16()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x02, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x3E, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
|
- addRewrite( 0x55, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x58, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x1C, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x55 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x4B /* Set Passengers : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = DefinedPacket.readVarInt( packet );
|
|
-
|
|
- if ( type == 2 || type == 102 || type == 72 ) // arrow, fishing_bobber or spectral_arrow
|
|
- {
|
|
- if ( type == 2 || type == 72 ) // arrow or spectral_arrow
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x04 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x32 /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al)
|
|
- rewriteMetaVarInt( packet, oldId, newId, 16, protocolVersion ); // guardian beam
|
|
- break;
|
|
- case 0x50 /* Entity Sound Effect : PacketPlayOutEntitySound */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java
|
|
deleted file mode 100644
|
|
index 7241dc56b..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java
|
|
+++ /dev/null
|
|
@@ -1,76 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import lombok.AccessLevel;
|
|
-import lombok.RequiredArgsConstructor;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-
|
|
-@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
|
-class EntityMap_1_16_2 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_16_2 INSTANCE_1_16_2 = new EntityMap_1_16_2( 0x04, 0x2D );
|
|
- static final EntityMap_1_16_2 INSTANCE_1_17 = new EntityMap_1_16_2( 0x04, 0x2D );
|
|
- static final EntityMap_1_16_2 INSTANCE_1_18 = new EntityMap_1_16_2( 0x04, 0x2D );
|
|
- static final EntityMap_1_16_2 INSTANCE_1_19 = new EntityMap_1_16_2( 0x02, 0x2F );
|
|
- static final EntityMap_1_16_2 INSTANCE_1_19_1 = new EntityMap_1_16_2( 0x02, 0x30 );
|
|
- //
|
|
- private final int spawnPlayerId;
|
|
- private final int spectateId;
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
|
- {
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == spawnPlayerId )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == spectateId && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java
|
|
deleted file mode 100644
|
|
index cdc07dc45..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java
|
|
+++ /dev/null
|
|
@@ -1,102 +0,0 @@
|
|
-// FlameCord start - 1.7.x support
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_7_2 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap INSTANCE = new EntityMap_1_7_2();
|
|
-
|
|
- EntityMap_1_7_2()
|
|
- {
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Equipment
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, false ); // Use bed
|
|
- addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation
|
|
- addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player
|
|
- addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, false ); // Collect Item
|
|
- addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object
|
|
- addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob
|
|
- addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting
|
|
- addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb
|
|
- addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Velocity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity
|
|
- addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Relative Move
|
|
- addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look
|
|
- addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look and Relative Move
|
|
- addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Teleport
|
|
- addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Head Look
|
|
- addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity
|
|
- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Metadata
|
|
- addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Effect
|
|
- addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, false ); // Remove Entity Effect
|
|
- addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Properties
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation
|
|
- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity
|
|
-
|
|
- addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, false ); // Use Entity
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, false ); // Animation
|
|
- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, false ); // Entity Action
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- //Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- if ( packetId == 0x0D /* Collect Item */ || packetId == 0x1B /* Attach Entity */ )
|
|
- {
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- } else if ( packetId == 0x13 /* Destroy Entities */ )
|
|
- {
|
|
- int count = packet.getByte( packetIdLength );
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- rewriteInt( packet, oldId, newId, packetIdLength + 1 + i * 4 );
|
|
- }
|
|
- } else if ( packetId == 0x0E /* Spawn Object */ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 )
|
|
- {
|
|
- packet.skipBytes( 14 );
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- int changedId = -1;
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- changedId = newId;
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- changedId = oldId;
|
|
- }
|
|
- if ( changedId != -1 )
|
|
- {
|
|
- if ( changedId == 0 && readId != 0 )
|
|
- { // Trim off the extra data
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( packet.readableBytes() - 6 );
|
|
- } else if ( changedId != 0 && readId == 0 )
|
|
- { // Add on the extra data
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.capacity( packet.readableBytes() + 6 );
|
|
- packet.writerIndex( packet.readableBytes() + 6 );
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
-// FlameCord end - 1.7.x support
|
|
\ No newline at end of file
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
|
deleted file mode 100644
|
|
index cb9174b35..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
|
+++ /dev/null
|
|
@@ -1,62 +0,0 @@
|
|
-// FlameCord start - 1.7.x support
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.connection.LoginResult;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-
|
|
-class EntityMap_1_7_6 extends EntityMap_1_7_2
|
|
-{
|
|
-
|
|
- static final EntityMap_1_7_6 INSTANCE = new EntityMap_1_7_6();
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- if ( packetId == 0x0C /* Spawn Player */ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- String uuid = DefinedPacket.readString( packet );
|
|
- String username = DefinedPacket.readString( packet );
|
|
- int props = DefinedPacket.readVarInt( packet );
|
|
- if ( props == 0 )
|
|
- {
|
|
- UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username );
|
|
- if ( player != null )
|
|
- {
|
|
- LoginResult profile = player.getPendingConnection().getLoginProfile();
|
|
- if ( profile != null && profile.getProperties() != null
|
|
- && profile.getProperties().length >= 1 )
|
|
- {
|
|
- ByteBuf rest = packet.copy();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeString( player.getUniqueId().toString(), packet );
|
|
- DefinedPacket.writeString( username, packet );
|
|
- DefinedPacket.writeVarInt( profile.getProperties().length, packet );
|
|
- for ( net.md_5.bungee.protocol.Property property : profile.getProperties() )
|
|
- {
|
|
- DefinedPacket.writeString( property.getName(), packet );
|
|
- DefinedPacket.writeString( property.getValue(), packet );
|
|
- DefinedPacket.writeString( property.getSignature(), packet );
|
|
- }
|
|
- packet.writeBytes( rest );
|
|
- rest.release();
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
-// FlameCord end - 1.7.x support
|
|
\ No newline at end of file
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java
|
|
deleted file mode 100644
|
|
index 8e2dbe699..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java
|
|
+++ /dev/null
|
|
@@ -1,176 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_8 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_8 INSTANCE = new EntityMap_1_8();
|
|
-
|
|
- EntityMap_1_8()
|
|
- {
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed
|
|
- addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation
|
|
- addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player
|
|
- addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item
|
|
- addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object
|
|
- addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob
|
|
- addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting
|
|
- addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb
|
|
- addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity
|
|
- addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move
|
|
- addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look
|
|
- addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move
|
|
- addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport
|
|
- addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look
|
|
- addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity
|
|
- addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata
|
|
- addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect
|
|
- addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect
|
|
- addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation
|
|
- addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity
|
|
- addRewrite( 0x43, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera
|
|
- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Update Entity NBT
|
|
-
|
|
- addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity
|
|
- addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- //Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- if ( packetId == 0x0D /* Collect Item */ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( packetId == 0x1B /* Attach Entity */ )
|
|
- {
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- } else if ( packetId == 0x13 /* Destroy Entities */ )
|
|
- {
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( readerIndex + packetIdLength );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- } else if ( packetId == 0x0E /* Spawn Object */ )
|
|
- {
|
|
-
|
|
- DefinedPacket.readVarInt( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 )
|
|
- {
|
|
- packet.skipBytes( 14 );
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- int changedId = readId;
|
|
-
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, changedId = newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, changedId = oldId );
|
|
- }
|
|
-
|
|
- if ( readId > 0 && changedId <= 0 )
|
|
- {
|
|
- packet.writerIndex( packet.writerIndex() - 6 );
|
|
- } else if ( changedId > 0 && readId <= 0 )
|
|
- {
|
|
- packet.ensureWritable( 6 );
|
|
- packet.writerIndex( packet.writerIndex() + 6 );
|
|
- }
|
|
- }
|
|
- } else if ( packetId == 0x0C /* Spawn Player */ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- } else if ( packetId == 0x42 /* Combat Event */ )
|
|
- {
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- //Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java
|
|
deleted file mode 100644
|
|
index d61dc0cba..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java
|
|
+++ /dev/null
|
|
@@ -1,182 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_9 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_9 INSTANCE = new EntityMap_1_9();
|
|
-
|
|
- EntityMap_1_9()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount
|
|
- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x49 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x40 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 5 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 12 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java
|
|
deleted file mode 100644
|
|
index bfbc84327..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java
|
|
+++ /dev/null
|
|
@@ -1,182 +0,0 @@
|
|
-package net.md_5.bungee.entitymap;
|
|
-
|
|
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import java.util.UUID;
|
|
-import net.md_5.bungee.BungeeCord;
|
|
-import net.md_5.bungee.UserConnection;
|
|
-import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
-import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-
|
|
-class EntityMap_1_9_4 extends EntityMap
|
|
-{
|
|
-
|
|
- static final EntityMap_1_9_4 INSTANCE = new EntityMap_1_9_4();
|
|
-
|
|
- EntityMap_1_9_4()
|
|
- {
|
|
- addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
|
- addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
|
- addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
|
- addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
|
- addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
|
- addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
|
- addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
|
- addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
|
- addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
|
- addRewrite( 0x26, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
|
- addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
|
- addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
|
- addRewrite( 0x2F, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
|
- addRewrite( 0x31, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
|
- addRewrite( 0x34, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
|
- addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
|
- addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
|
- addRewrite( 0x3A, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
|
- addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
|
- addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
|
- addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, true ); // Attach Entity : PacketPlayOutMount
|
|
- addRewrite( 0x48, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
|
- addRewrite( 0x49, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
|
- addRewrite( 0x4A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
|
- addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
|
-
|
|
- addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
|
- addRewrite( 0x14, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
|
- }
|
|
-
|
|
- @Override
|
|
- @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
- public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteClientbound( packet, oldId, newId );
|
|
-
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
- int jumpIndex = packet.readerIndex();
|
|
- switch ( packetId )
|
|
- {
|
|
- case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */:
|
|
- rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
- break;
|
|
- case 0x48 /* Collect Item : PacketPlayOutCollect */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- break;
|
|
- case 0x40 /* Attach Entity : PacketPlayOutMount */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- jumpIndex = packet.readerIndex();
|
|
- // Fall through on purpose to int array of IDs
|
|
- case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
|
- int count = DefinedPacket.readVarInt( packet );
|
|
- int[] ids = new int[ count ];
|
|
- for ( int i = 0; i < count; i++ )
|
|
- {
|
|
- ids[i] = DefinedPacket.readVarInt( packet );
|
|
- }
|
|
- packet.readerIndex( jumpIndex );
|
|
- packet.writerIndex( jumpIndex );
|
|
- DefinedPacket.writeVarInt( count, packet );
|
|
- for ( int id : ids )
|
|
- {
|
|
- if ( id == oldId )
|
|
- {
|
|
- id = newId;
|
|
- } else if ( id == newId )
|
|
- {
|
|
- id = oldId;
|
|
- }
|
|
- DefinedPacket.writeVarInt( id, packet );
|
|
- }
|
|
- break;
|
|
- case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
|
- DefinedPacket.readVarInt( packet );
|
|
- DefinedPacket.readUUID( packet );
|
|
- int type = packet.readUnsignedByte();
|
|
-
|
|
- if ( type == 60 || type == 90 || type == 91 )
|
|
- {
|
|
- if ( type == 60 || type == 91 )
|
|
- {
|
|
- oldId = oldId + 1;
|
|
- newId = newId + 1;
|
|
- }
|
|
-
|
|
- packet.skipBytes( 26 ); // double, double, double, byte, byte
|
|
- int position = packet.readerIndex();
|
|
- int readId = packet.readInt();
|
|
- if ( readId == oldId )
|
|
- {
|
|
- packet.setInt( position, newId );
|
|
- } else if ( readId == newId )
|
|
- {
|
|
- packet.setInt( position, oldId );
|
|
- }
|
|
- }
|
|
- break;
|
|
- case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
- DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- break;
|
|
- case 0x2C /* Combat Event : PacketPlayOutCombatEvent */:
|
|
- int event = packet.readUnsignedByte();
|
|
- if ( event == 1 /* End Combat*/ )
|
|
- {
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- } else if ( event == 2 /* Entity Dead */ )
|
|
- {
|
|
- int position = packet.readerIndex();
|
|
- rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
|
- packet.readerIndex( position );
|
|
- DefinedPacket.readVarInt( packet );
|
|
- rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
|
- }
|
|
- break;
|
|
- case 0x39 /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
|
- DefinedPacket.readVarInt( packet ); // Entity ID
|
|
- rewriteMetaVarInt( packet, oldId + 1, newId + 1, 5 ); // fishing hook
|
|
- rewriteMetaVarInt( packet, oldId, newId, 12 ); // guardian beam
|
|
- break;
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
|
- {
|
|
- super.rewriteServerbound( packet, oldId, newId );
|
|
- // Special cases
|
|
- int readerIndex = packet.readerIndex();
|
|
- int packetId = DefinedPacket.readVarInt( packet );
|
|
- int packetIdLength = packet.readerIndex() - readerIndex;
|
|
-
|
|
- if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
|
- {
|
|
- UUID uuid = DefinedPacket.readUUID( packet );
|
|
- ProxiedPlayer player;
|
|
- if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
|
- {
|
|
- int previous = packet.writerIndex();
|
|
- packet.readerIndex( readerIndex );
|
|
- packet.writerIndex( readerIndex + packetIdLength );
|
|
- DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
|
- packet.writerIndex( previous );
|
|
- }
|
|
- }
|
|
- packet.readerIndex( readerIndex );
|
|
- }
|
|
-}
|
|
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
|
|
deleted file mode 100644
|
|
index cb81d1dd8..000000000
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_Dummy.java
|
|
+++ /dev/null
|
|
@@ -1,30 +0,0 @@
|
|
-
|
|
-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
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
index caed43849..af4280904 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
@@ -11,7 +11,6 @@ import lombok.Setter;
|
|
import net.md_5.bungee.BungeeCord;
|
|
import net.md_5.bungee.UserConnection;
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
-import net.md_5.bungee.protocol.packet.EntityRemoveEffect;
|
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
|
|
|
/**
|
|
@@ -113,10 +112,6 @@ public class ForgeClientHandler
|
|
}
|
|
|
|
private void resetAllThePotions(UserConnection con) {
|
|
- // Just to be sure
|
|
- for (Map.Entry<Integer, Integer> entry: con.getPotions().entries()) {
|
|
- con.unsafe().sendPacket(new EntityRemoveEffect(entry.getKey(), entry.getValue()));
|
|
- }
|
|
con.getPotions().clear();
|
|
}
|
|
|
|
--
|
|
2.37.3.windows.1
|
|
|