Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke 2022-06-09 11:57:19 +02:00
parent 2514a4d5ca
commit 5dc0509d47
2 changed files with 3 additions and 16 deletions

View file

@ -2709,22 +2709,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Override
+ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
+ if (getHandle().connection == null) return;
+ // TODO this needs to be checked
+ final net.minecraft.core.Registry<net.minecraft.network.chat.ChatType> chatTypeRegistry = this.getHandle().level.registryAccess().registryOrThrow(net.minecraft.core.Registry.CHAT_TYPE_REGISTRY);
+ final net.minecraft.network.protocol.Packet<?> packet;
+ if (identity.equals(net.kyori.adventure.identity.Identity.nil()) || type == net.kyori.adventure.audience.MessageType.SYSTEM) {
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(message, chatTypeRegistry.getId(chatTypeRegistry.get(net.minecraft.network.chat.ChatType.SYSTEM)));
+ } else {
+ final @Nullable Player source = this.getServer().getPlayer(identity.uuid());
+ final ChatSender sender;
+ if (source != null) {
+ sender = ((CraftPlayer) source).getHandle().asChatSender();
+ } else {
+ sender = new ChatSender(identity.uuid(), Component.empty(), null);
+ }
+ packet = new net.minecraft.network.protocol.game.ClientboundPlayerChatPacket(message, chatTypeRegistry.getId(chatTypeRegistry.get(net.minecraft.network.chat.ChatType.CHAT)), sender, java.time.Instant.now());
+ }
+ this.getHandle().connection.send(packet);
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(message, chatTypeRegistry.getId(chatTypeRegistry.get(net.minecraft.network.chat.ChatType.SYSTEM))));
+ }
+
+ @Override

View file

@ -229,7 +229,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final PoiManager.Occupancy occupancy,
+ final boolean load,
+ final List<PoiRecord> ret) {
+ findClosestPoiDataRecords(poiStorage, villagePlaceType, (type, pos) -> positionPredicate.test(pos), sourcePosition, range, maxDistance, occupancy, load, ret);
+ final BiPredicate<Holder<PoiType>, BlockPos> predicate = positionPredicate != null ? (type, pos) -> positionPredicate.test(pos) : null;
+ findClosestPoiDataRecords(poiStorage, villagePlaceType, predicate, sourcePosition, range, maxDistance, occupancy, load, ret);
+ }
+
+ public static void findClosestPoiDataRecords(final PoiManager poiStorage,