Remove more reflection calls

This commit is contained in:
2026-05-16 21:41:50 +02:00
parent ba4ee08489
commit cfa650bcf4
5 changed files with 18 additions and 59 deletions
@@ -243,7 +243,7 @@ public class TinyProtocol {
}
}
public <T> void addTypedFilter(Class<T> packetType, BiFunction<Player, T, Object> filter) {
public <T> void addTypedFilter(Class<T> packetType, BiFunction<Player, ? super T, Object> filter) {
packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add((BiFunction) filter);
}
@@ -41,9 +41,7 @@ public class BountifulWrapper {
}
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
if(type == ChatMessageType.CHAT)
type = ChatMessageType.SYSTEM;
if(type == ChatMessageType.CHAT) type = ChatMessageType.SYSTEM;
player.spigot().sendMessage(type, msg);
}
@@ -62,9 +60,7 @@ public class BountifulWrapper {
Reflection.Field<PositionMoveRotation> field = Reflection.getField(packetClass, PositionMoveRotation.class, 0);
return (packet, x, y, z, pitch, yaw) -> {
PositionMoveRotation pos = field.get(packet);
field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), pos.deltaMovement(), yaw, pitch));
field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), field.get(packet).deltaMovement(), yaw, pitch));
};
} catch (IllegalArgumentException e) {
Reflection.Field<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
@@ -82,6 +82,7 @@ public class REntity {
private boolean bowDrawn;
@Getter
private boolean noGravity;
@Getter
private boolean isGlowing;
private int fireTick;
@@ -245,10 +246,6 @@ public class REntity {
server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus()));
}
public boolean isGlowing() {
return isGlowing;
}
private static final Function<REntity, Object> spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, 2);
private static final Reflection.Field<Integer> additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 4);