Search in sources :

Example 1 with GlobalTrackedPortal

use of com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal in project ImmersivePortalsMod by qouteall.

the class MyNetworkClient method processGlobalPortalUpdate.

private static void processGlobalPortalUpdate(PacketContext context, PacketByteBuf buf) {
    DimensionType dimensionType = DimensionType.byRawId(buf.readInt());
    CompoundTag compoundTag = buf.readCompoundTag();
    MinecraftClient.getInstance().execute(() -> {
        ClientWorld world = CGlobal.clientWorldLoader.getOrCreateFakedWorld(dimensionType);
        List<GlobalTrackedPortal> portals = GlobalPortalStorage.getPortalsFromTag(compoundTag, world);
        ((IEClientWorld) world).setGlobalPortals(portals);
    });
}
Also used : DimensionType(net.minecraft.world.dimension.DimensionType) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) CompoundTag(net.minecraft.nbt.CompoundTag) GlobalTrackedPortal(com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal)

Example 2 with GlobalTrackedPortal

use of com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal in project ImmersivePortalsMod by qouteall.

the class CHelper method getClientNearbyPortals.

public static Stream<Portal> getClientNearbyPortals(double range) {
    ClientPlayerEntity player = MinecraftClient.getInstance().player;
    List<GlobalTrackedPortal> globalPortals = ((IEClientWorld) player.world).getGlobalPortals();
    Stream<Portal> nearbyPortals = McHelper.getEntitiesNearby(player, Portal.class, range);
    if (globalPortals == null) {
        return nearbyPortals;
    } else {
        return Streams.concat(globalPortals.stream().filter(p -> p.getDistanceToNearestPointInPortal(player.getPos()) < range * 2), nearbyPortals);
    }
}
Also used : MyRenderHelper(com.qouteall.immersive_portals.render.MyRenderHelper) World(net.minecraft.world.World) Environment(net.fabricmc.api.Environment) Streams(com.google.common.collect.Streams) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) GlobalTrackedPortal(com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal) List(java.util.List) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) Stream(java.util.stream.Stream) DimensionType(net.minecraft.world.dimension.DimensionType) Portal(com.qouteall.immersive_portals.portal.Portal) EnvType(net.fabricmc.api.EnvType) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) GlobalTrackedPortal(com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal) Portal(com.qouteall.immersive_portals.portal.Portal) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) GlobalTrackedPortal(com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal)

Aggregations

IEClientWorld (com.qouteall.immersive_portals.ducks.IEClientWorld)2 GlobalTrackedPortal (com.qouteall.immersive_portals.portal.global_portals.GlobalTrackedPortal)2 DimensionType (net.minecraft.world.dimension.DimensionType)2 Streams (com.google.common.collect.Streams)1 Portal (com.qouteall.immersive_portals.portal.Portal)1 MyRenderHelper (com.qouteall.immersive_portals.render.MyRenderHelper)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 EnvType (net.fabricmc.api.EnvType)1 Environment (net.fabricmc.api.Environment)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 PlayerListEntry (net.minecraft.client.network.PlayerListEntry)1 ClientWorld (net.minecraft.client.world.ClientWorld)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 World (net.minecraft.world.World)1