2 Commits

Author SHA1 Message Date
Oliver
d6dc456f2a fancynpcs: Wrap packets in Npc#update method in bundle packet (1.12.9+) 2025-11-21 21:10:48 +01:00
Oliver
da7bc075aa Update to 1.21.11-pre2 2025-11-21 20:56:00 +01:00
5 changed files with 23 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ plugins {
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
dependencies {
paperweight.paperDevBundle("1.21.11-pre1-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21.11-pre2-R0.1-SNAPSHOT")
compileOnly(project(":libraries:packets:packets-api"))
testImplementation(project(":libraries:packets"))

View File

@@ -1 +1 @@
2.8.0.311
2.8.0.312

View File

@@ -6,7 +6,7 @@ plugins {
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
dependencies {
paperweight.paperDevBundle("1.21.11-pre1-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21.11-pre2-R0.1-SNAPSHOT")
// compileOnly("com.fancyinnovations:fancymc:1.21.6-pre2")
compileOnly(project(":plugins:fancynpcs:fn-api"))

View File

@@ -231,6 +231,8 @@ public class Npc_1_21_11 extends Npc {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
List<Packet<? super ClientGamePacketListener>> packets = new ArrayList<>();
PlayerTeam team = new PlayerTeam(new Scoreboard(), "npc-" + localName);
team.getPlayers().clear();
team.getPlayers().add(npc instanceof ServerPlayer npcPlayer ? npcPlayer.getGameProfile().name() : npc.getStringUUID());
@@ -268,11 +270,11 @@ public class Npc_1_21_11 extends Npc {
}
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, getEntry(npcPlayer, serverPlayer));
serverPlayer.connection.send(playerInfoPacket);
packets.add(playerInfoPacket);
}
boolean isTeamCreatedForPlayer = this.isTeamCreated.getOrDefault(player.getUniqueId(), false);
serverPlayer.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, !isTeamCreatedForPlayer));
packets.add(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, !isTeamCreatedForPlayer));
isTeamCreated.put(player.getUniqueId(), true);
npc.setGlowingTag(data.isGlowing());
@@ -297,7 +299,7 @@ public class Npc_1_21_11 extends Npc {
if (!equipmentList.isEmpty()) {
ClientboundSetEquipmentPacket setEquipmentPacket = new ClientboundSetEquipmentPacket(npc.getId(), equipmentList);
serverPlayer.connection.send(setEquipmentPacket);
packets.add(setEquipmentPacket);
}
if (npc instanceof ServerPlayer) {
@@ -320,7 +322,7 @@ public class Npc_1_21_11 extends Npc {
} else {
if (sittingVehicle != null) {
ClientboundRemoveEntitiesPacket removeSittingVehiclePacket = new ClientboundRemoveEntitiesPacket(sittingVehicle.getId());
serverPlayer.connection.send(removeSittingVehiclePacket);
packets.add(removeSittingVehiclePacket);
}
}
@@ -333,9 +335,11 @@ public class Npc_1_21_11 extends Npc {
attributeInstance.setBaseValue(data.getScale());
ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);
packets.add(updateAttributesPacket);
}
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(packets);
serverPlayer.connection.send(bundlePacket);
}
@Override

View File

@@ -231,6 +231,8 @@ public class Npc_1_21_9 extends Npc {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
List<Packet<? super ClientGamePacketListener>> packets = new ArrayList<>();
PlayerTeam team = new PlayerTeam(new Scoreboard(), "npc-" + localName);
team.getPlayers().clear();
team.getPlayers().add(npc instanceof ServerPlayer npcPlayer ? npcPlayer.getGameProfile().name() : npc.getStringUUID());
@@ -268,11 +270,11 @@ public class Npc_1_21_9 extends Npc {
}
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, getEntry(npcPlayer, serverPlayer));
serverPlayer.connection.send(playerInfoPacket);
packets.add(playerInfoPacket);
}
boolean isTeamCreatedForPlayer = this.isTeamCreated.getOrDefault(player.getUniqueId(), false);
serverPlayer.connection.send(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, !isTeamCreatedForPlayer));
packets.add(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, !isTeamCreatedForPlayer));
isTeamCreated.put(player.getUniqueId(), true);
npc.setGlowingTag(data.isGlowing());
@@ -297,7 +299,7 @@ public class Npc_1_21_9 extends Npc {
if (!equipmentList.isEmpty()) {
ClientboundSetEquipmentPacket setEquipmentPacket = new ClientboundSetEquipmentPacket(npc.getId(), equipmentList);
serverPlayer.connection.send(setEquipmentPacket);
packets.add(setEquipmentPacket);
}
if (npc instanceof ServerPlayer) {
@@ -320,7 +322,7 @@ public class Npc_1_21_9 extends Npc {
} else {
if (sittingVehicle != null) {
ClientboundRemoveEntitiesPacket removeSittingVehiclePacket = new ClientboundRemoveEntitiesPacket(sittingVehicle.getId());
serverPlayer.connection.send(removeSittingVehiclePacket);
packets.add(removeSittingVehiclePacket);
}
}
@@ -333,9 +335,11 @@ public class Npc_1_21_9 extends Npc {
attributeInstance.setBaseValue(data.getScale());
ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);
packets.add(updateAttributesPacket);
}
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(packets);
serverPlayer.connection.send(bundlePacket);
}
@Override