Skip to content

Commit

Permalink
Merge pull request #19 from joshuaprince/master
Browse files Browse the repository at this point in the history
Update to 1.19.4
  • Loading branch information
cavallium committed Apr 1, 2023
2 parents 12fc001 + 5e2df87 commit f3d597e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.warp</groupId>
<artifactId>CoordinatesObfuscator</artifactId>
<version>1.4.8</version>
<version>1.4.9</version>
<name>CoordinatesObfuscator</name>
<build>
<resources>
Expand Down Expand Up @@ -58,7 +58,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void onEnable() {
paramsServer.listenerPriority(ListenerPriority.HIGHEST);
paramsServer.gamePhase(GamePhase.PLAYING);

packets.add(PacketType.Play.Server.BUNDLE);
packets.add(PacketType.Play.Server.BLOCK_ACTION);
packets.add(PacketType.Play.Server.BLOCK_BREAK);
packets.add(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
packets.add(PacketType.Play.Server.BLOCK_CHANGE);
packets.add(PacketType.Play.Server.MULTI_BLOCK_CHANGE);
Expand All @@ -93,17 +93,13 @@ public void onEnable() {
packets.add(PacketType.Play.Server.WORLD_EVENT);

packets.add(PacketType.Play.Server.NAMED_SOUND_EFFECT);
packets.add(PacketType.Play.Server.CUSTOM_SOUND_EFFECT);

packets.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
packets.add(PacketType.Play.Server.SPAWN_ENTITY);
packets.add(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
packets.add(PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB);
packets.add(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
packets.add(PacketType.Play.Server.ENTITY_TELEPORT);

packets.add(PacketType.Play.Server.OPEN_SIGN_EDITOR);
packets.add(PacketType.Play.Server.ADD_VIBRATION_SIGNAL);

packets.add(PacketType.Play.Server.ENTITY_METADATA);
packets.add(PacketType.Play.Server.VIEW_CENTRE);
Expand Down Expand Up @@ -139,6 +135,7 @@ public void onPacketSending(final PacketEvent event) {
case "LIGHT_UPDATE" -> packet = event.getPacket().shallowClone();
case "TILE_ENTITY_DATA" -> packet = cloneTileEntityData(event.getPacket());
case "MAP_CHUNK" -> packet = cloneMapChunkEntitiesData(event.getPacket());
case "WORLD_PARTICLES" -> packet = event.getPacket().deepClone();
default -> packet = event.getPacket().shallowClone();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import com.comphenix.protocol.injector.temporary.TemporaryPlayer;
import com.comphenix.protocol.reflect.EquivalentConverter;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.Converters;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand All @@ -27,17 +28,11 @@ public class TranslatorClientbound {
private static final EquivalentConverter<InternalStructure> INTERNAL_STRUCTURE_CONVERTER;

static {
Class<?> blockPositionClass = null;
try {
blockPositionClass = Class.forName("net.minecraft.core.BlockPosition");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
NMS_BLOCK_POSITION_CLASS = blockPositionClass;
NMS_BLOCK_POSITION_CLASS = MinecraftReflection.getBlockPositionClass();

Method blockPositionAddMethod = null;
try {
blockPositionAddMethod = blockPositionClass.getDeclaredMethod("c", int.class, int.class, int.class);
blockPositionAddMethod = NMS_BLOCK_POSITION_CLASS.getDeclaredMethod("c", int.class, int.class, int.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -72,17 +67,12 @@ public static boolean outgoing(Logger logger, final PacketContainer packet, fina
case "SPAWN_POSITION":
case "WORLD_EVENT":
case "UPDATE_SIGN":
case "BLOCK_BREAK":
case "BLOCK_BREAK_ANIMATION":
case "BLOCK_ACTION":
case "BLOCK_CHANGE":
case "SPAWN_ENTITY_PAINTING":
case "OPEN_SIGN_EDITOR":
sendBlockPosition(logger, packet, offset);
break;
case "ADD_VIBRATION_SIGNAL":
fixVibrationSignal(logger, packet, offset);
break;
case "RESPAWN":
logger.fine("[out]Respawning player");
respawn(logger, offset, player);
Expand Down Expand Up @@ -132,13 +122,15 @@ public static boolean outgoing(Logger logger, final PacketContainer packet, fina
Objects.requireNonNull(offset);
sendDouble(logger, packet, offset);
break;
case "SPAWN_ENTITY_LIVING":
case "WORLD_PARTICLES":
case "SPAWN_ENTITY_WEATHER":
case "SPAWN_ENTITY_EXPERIENCE_ORB":
case "ENTITY_TELEPORT":
sendDouble(logger, packet, offset);
break;
case "WORLD_PARTICLES":
sendDouble(logger, packet, offset);
fixVibrationParticle(logger, packet, offset);
break;
case "UNLOAD_CHUNK":
sendChunk(logger, packet, offset, false, false);
break;
Expand All @@ -161,15 +153,14 @@ public static boolean outgoing(Logger logger, final PacketContainer packet, fina
sendExplosion(logger, packet, offset);
break;
case "NAMED_SOUND_EFFECT":
case "CUSTOM_SOUND_EFFECT":
sendInt8(logger, packet, offset);
break;
case "ENTITY_METADATA":
if (packet.getWatchableCollectionModifier().size() > 0) {
packet.getWatchableCollectionModifier().modify(0, wrappedWatchableObjects -> {
if (wrappedWatchableObjects == null) return null;
ArrayList<WrappedWatchableObject> result = new ArrayList<WrappedWatchableObject>(wrappedWatchableObjects.size());
for (WrappedWatchableObject wrappedWatchableObject : wrappedWatchableObjects) {
if (packet.getDataValueCollectionModifier().size() > 0) {
packet.getDataValueCollectionModifier().modify(0, wrappedDataValues -> {
if (wrappedDataValues == null) return null;
ArrayList<WrappedDataValue> result = new ArrayList<WrappedDataValue>(wrappedDataValues.size());
for (WrappedDataValue wrappedWatchableObject : wrappedDataValues) {
if (wrappedWatchableObject == null) {
result.add(null);
continue;
Expand Down Expand Up @@ -413,14 +404,15 @@ private static void sendBlockPosition(Logger logger, final PacketContainer packe
}
}

private static void fixVibrationSignal(Logger logger, final PacketContainer packet, final CoordinateOffset offset) {
if (packet.getBlockPositionModifier().size() >= 1) {
packet.getBlockPositionModifier().modify(0, pos -> offsetPosition(logger, offset, pos));
} else {
logger.severe("Packet size error");
}
if (packet.getBlockPositionModifier().size() >= 2) {
packet.getBlockPositionModifier().modify(1, pos -> offsetPosition(logger, offset, pos));
private static void fixVibrationParticle(Logger logger, final PacketContainer packet, final CoordinateOffset offset) {
if (packet.getStructures().size() > 0) {
InternalStructure outerStructure = packet.getStructures().read(0);
if (outerStructure.getStructures().size() > 0) {
InternalStructure innerStructure = outerStructure.getStructures().read(0);
if (innerStructure.getBlockPositionModifier().size() > 0) {
innerStructure.getBlockPositionModifier().modify(0, p -> offsetPosition(logger, offset, p));
}
}
} else {
logger.severe("Packet size error");
}
Expand Down

0 comments on commit f3d597e

Please sign in to comment.