Search in sources :

Example 1 with MixinForgeChunkManager$Ticket

use of org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket in project SpongeForge by SpongePowered.

the class SpongeChunkTicketManager method createPlayerEntityTicket.

@Override
public Optional<PlayerEntityLoadingTicket> createPlayerEntityTicket(Object plugin, World world, UUID player) {
    Optional<Player> spongePlayer = SpongeImpl.getGame().getServer().getPlayer(player);
    if (!spongePlayer.isPresent()) {
        return Optional.empty();
    }
    Ticket forgeTicket = ForgeChunkManager.requestPlayerTicket(plugin, spongePlayer.get().getName(), (net.minecraft.world.World) world, ForgeChunkManager.Type.ENTITY);
    if (forgeTicket == null) {
        return Optional.empty();
    }
    return Optional.of((PlayerEntityLoadingTicket) new SpongePlayerEntityLoadingTicket(forgeTicket));
}
Also used : MixinForgeChunkManager$Ticket(org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket) Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) Player(org.spongepowered.api.entity.living.player.Player)

Example 2 with MixinForgeChunkManager$Ticket

use of org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket in project SpongeForge by SpongePowered.

the class SpongeChunkTicketManager method getForcedChunks.

@Override
public ImmutableSetMultimap<Vector3i, LoadingTicket> getForcedChunks(World world) {
    ImmutableSetMultimap<ChunkPos, Ticket> forgeForcedChunks = ForgeChunkManager.getPersistentChunksFor((net.minecraft.world.World) world);
    ImmutableSetMultimap.Builder<Vector3i, LoadingTicket> spongeForcedChunks = ImmutableSetMultimap.builder();
    for (Map.Entry<ChunkPos, Ticket> ticketPair : forgeForcedChunks.entries()) {
        spongeForcedChunks.put(new Vector3i(ticketPair.getKey().x, 0, ticketPair.getKey().z), new SpongeLoadingTicket(ticketPair.getValue()));
    }
    return spongeForcedChunks.build();
}
Also used : MixinForgeChunkManager$Ticket(org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket) Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) ImmutableSetMultimap(com.google.common.collect.ImmutableSetMultimap) Vector3i(com.flowpowered.math.vector.Vector3i) ChunkPos(net.minecraft.util.math.ChunkPos) Map(java.util.Map)

Example 3 with MixinForgeChunkManager$Ticket

use of org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket in project SpongeForge by SpongePowered.

the class SpongeChunkTicketManager method createPlayerTicket.

@Override
public Optional<PlayerLoadingTicket> createPlayerTicket(Object plugin, World world, UUID player) {
    Optional<Player> spongePlayer = SpongeImpl.getGame().getServer().getPlayer(player);
    if (!spongePlayer.isPresent()) {
        return Optional.empty();
    }
    Ticket forgeTicket = ForgeChunkManager.requestPlayerTicket(plugin, spongePlayer.get().getName(), (net.minecraft.world.World) world, ForgeChunkManager.Type.NORMAL);
    if (forgeTicket == null) {
        return Optional.empty();
    }
    return Optional.of((PlayerLoadingTicket) new SpongePlayerLoadingTicket(forgeTicket));
}
Also used : MixinForgeChunkManager$Ticket(org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket) Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) Player(org.spongepowered.api.entity.living.player.Player)

Aggregations

Ticket (net.minecraftforge.common.ForgeChunkManager.Ticket)3 MixinForgeChunkManager$Ticket (org.spongepowered.mod.mixin.core.forge.common.MixinForgeChunkManager$Ticket)3 Player (org.spongepowered.api.entity.living.player.Player)2 Vector3i (com.flowpowered.math.vector.Vector3i)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 Map (java.util.Map)1 ChunkPos (net.minecraft.util.math.ChunkPos)1