Search in sources :

Example 1 with EntityPassengersSetS2CPacket

use of net.minecraft.client.network.packet.EntityPassengersSetS2CPacket in project ImmersivePortalsMod by qouteall.

the class MixinThreadedAnvilChunkStorage method sendChunkDataPackets.

/**
 * @author qouteall
 */
@Overwrite
private void sendChunkDataPackets(ServerPlayerEntity player, Packet<?>[] packets_1, WorldChunk worldChunk_1) {
    // vanilla will not manage interdimensional chunk loading
    if (player.dimension != world.dimension.getType()) {
        return;
    }
    DimensionalChunkPos chunkPos = new DimensionalChunkPos(world.dimension.getType(), worldChunk_1.getPos());
    boolean isChunkDataSent = SGlobal.chunkTrackingGraph.isChunkDataSent(player, chunkPos);
    if (isChunkDataSent) {
        return;
    }
    ModMain.serverTaskList.addTask(() -> {
        SGlobal.chunkTrackingGraph.onChunkDataSent(player, chunkPos);
        return true;
    });
    if (packets_1[0] == null) {
        packets_1[0] = MyNetwork.createRedirectedMessage(world.dimension.getType(), new ChunkDataS2CPacket(worldChunk_1, 65535));
        packets_1[1] = MyNetwork.createRedirectedMessage(world.dimension.getType(), new LightUpdateS2CPacket(worldChunk_1.getPos(), this.serverLightingProvider));
    }
    player.sendInitialChunkPackets(worldChunk_1.getPos(), packets_1[0], packets_1[1]);
    DebugRendererInfoManager.method_19775(this.world, worldChunk_1.getPos());
    List<Entity> list_1 = Lists.newArrayList();
    List<Entity> list_2 = Lists.newArrayList();
    ObjectIterator var6 = this.entityTrackers.values().iterator();
    while (var6.hasNext()) {
        IEEntityTracker threadedAnvilChunkStorage$EntityTracker_1 = (IEEntityTracker) var6.next();
        Entity entity_1 = threadedAnvilChunkStorage$EntityTracker_1.getEntity_();
        if (entity_1 != player && entity_1.chunkX == worldChunk_1.getPos().x && entity_1.chunkZ == worldChunk_1.getPos().z) {
            threadedAnvilChunkStorage$EntityTracker_1.updateCameraPosition_(player);
            if (entity_1 instanceof MobEntity && ((MobEntity) entity_1).getHoldingEntity() != null) {
                list_1.add(entity_1);
            }
            if (!entity_1.getPassengerList().isEmpty()) {
                list_2.add(entity_1);
            }
        }
    }
    Iterator var9;
    Entity entity_3;
    if (!list_1.isEmpty()) {
        var9 = list_1.iterator();
        while (var9.hasNext()) {
            entity_3 = (Entity) var9.next();
            player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(world.getDimension().getType(), new EntityAttachS2CPacket(entity_3, ((MobEntity) entity_3).getHoldingEntity())));
        }
    }
    if (!list_2.isEmpty()) {
        var9 = list_2.iterator();
        while (var9.hasNext()) {
            entity_3 = (Entity) var9.next();
            player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(world.getDimension().getType(), new EntityPassengersSetS2CPacket(entity_3)));
        }
    }
}
Also used : MobEntity(net.minecraft.entity.mob.MobEntity) Entity(net.minecraft.entity.Entity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) IEEntityTracker(com.qouteall.immersive_portals.ducks.IEEntityTracker) DimensionalChunkPos(com.qouteall.immersive_portals.chunk_loading.DimensionalChunkPos) EntityPassengersSetS2CPacket(net.minecraft.client.network.packet.EntityPassengersSetS2CPacket) LightUpdateS2CPacket(net.minecraft.client.network.packet.LightUpdateS2CPacket) ChunkDataS2CPacket(net.minecraft.client.network.packet.ChunkDataS2CPacket) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator) Iterator(java.util.Iterator) EntityAttachS2CPacket(net.minecraft.client.network.packet.EntityAttachS2CPacket) MobEntity(net.minecraft.entity.mob.MobEntity) ObjectIterator(it.unimi.dsi.fastutil.objects.ObjectIterator) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

DimensionalChunkPos (com.qouteall.immersive_portals.chunk_loading.DimensionalChunkPos)1 IEEntityTracker (com.qouteall.immersive_portals.ducks.IEEntityTracker)1 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)1 Iterator (java.util.Iterator)1 ChunkDataS2CPacket (net.minecraft.client.network.packet.ChunkDataS2CPacket)1 EntityAttachS2CPacket (net.minecraft.client.network.packet.EntityAttachS2CPacket)1 EntityPassengersSetS2CPacket (net.minecraft.client.network.packet.EntityPassengersSetS2CPacket)1 LightUpdateS2CPacket (net.minecraft.client.network.packet.LightUpdateS2CPacket)1 Entity (net.minecraft.entity.Entity)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1