}
private void sendToPlayer(int playerId, ServerPlayer player) {
- BoundingBoxCache boundingBoxCache = getCache(player.getDimensionId());
- if (boundingBoxCache == null) return;
+ for (Map.Entry<Integer, BoundingBoxCache> entry : dimensionCache.entrySet()) {
+ int dimensionId = entry.getKey();
+ BoundingBoxCache boundingBoxCache = entry.getValue();
+ if (boundingBoxCache == null) return;
- Set<AbstractBoundingBox> playerBoundingBoxes = playerBoundingBoxesCache.computeIfAbsent(playerId, k -> new HashSet<>());
+ Set<AbstractBoundingBox> playerBoundingBoxes = playerBoundingBoxesCache.computeIfAbsent(playerId, k -> new HashSet<>());
- Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxMap = boundingBoxCache.getBoundingBoxes();
- for (AbstractBoundingBox key : boundingBoxMap.keySet()) {
- if (playerBoundingBoxes.contains(key)) {
- continue;
- }
+ Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxMap = boundingBoxCache.getBoundingBoxes();
+ for (AbstractBoundingBox key : boundingBoxMap.keySet()) {
+ if (playerBoundingBoxes.contains(key)) {
+ continue;
+ }
- Set<AbstractBoundingBox> boundingBoxes = boundingBoxMap.get(key);
- PayloadBuilder payload = AddBoundingBox.getPayload(player.getDimensionId(), key, boundingBoxes);
- if (payload != null)
- player.sendPacket(payload);
+ Set<AbstractBoundingBox> boundingBoxes = boundingBoxMap.get(key);
+ PayloadBuilder payload = AddBoundingBox.getPayload(dimensionId, key, boundingBoxes);
+ if (payload != null)
+ player.sendPacket(payload);
- playerBoundingBoxes.add(key);
+ playerBoundingBoxes.add(key);
+ }
}
}
EventBus.publish(new PlayerLoggedOut(player.getEntityId()));
}
+ public static void playerSubscribed(EntityPlayerMP player) {
+ EventBus.publish(new PlayerSubscribed(player.getEntityId(), new ServerPlayer(player)));
+ }
+
public static void tryHarvestBlock(Block block, BlockPos pos, World world) {
if (block instanceof BlockMobSpawner) {
EventBus.publish(new MobSpawnerBroken(world.dimension.getType().getId(), new Coords(pos)));
package com.irtimaled.bbor.mixin.network.play.client;
-import com.irtimaled.bbor.common.EventBus;
-import com.irtimaled.bbor.common.events.PlayerSubscribed;
+import com.irtimaled.bbor.common.interop.CommonInterop;
import com.irtimaled.bbor.common.messages.SubscribeToServer;
-import com.irtimaled.bbor.common.models.ServerPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.INetHandlerPlayServer;
import net.minecraft.network.play.client.CPacketCustomPayload;
@Redirect(method = "processPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/INetHandlerPlayServer;processCustomPayload(Lnet/minecraft/network/play/client/CPacketCustomPayload;)V"))
private void processPacket(INetHandlerPlayServer netHandlerPlayServer, CPacketCustomPayload packet) {
if (this.channel.toString().equals(SubscribeToServer.NAME)) {
- EntityPlayerMP player = ((NetHandlerPlayServer) netHandlerPlayServer).player;
- EventBus.publish(new PlayerSubscribed(player.getEntityId(), new ServerPlayer(player)));
+ CommonInterop.playerSubscribed(((NetHandlerPlayServer) netHandlerPlayServer).player);
} else {
netHandlerPlayServer.processCustomPayload(packet);
}