Search in sources :

Example 6 with ParallelUniverse

use of thpmc.vanilla_source.api.world.parallel.ParallelUniverse in project VanillaSource by TheHollowPlanetMC.

the class UniverseGUI method openUniverseGUI.

public static void openUniverseGUI(Player player) {
    EnginePlayer enginePlayer = EnginePlayer.getParallelPlayer(player);
    if (enginePlayer == null)
        return;
    Artist artist = new Artist(() -> {
        ArtButton V = null;
        ArtButton G = new ArtButton(new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE).name("&a").build());
        PageNextButton N = new PageNextButton(new ItemBuilder(Material.ARROW).name("&rNext page &7[{NextPage}/{MaxPage}]").build());
        PageBackButton P = new PageBackButton(new ItemBuilder(Material.ARROW).name("&rPrevious page &7[{PreviousPage}/{MaxPage}]").build());
        MenuBackButton B = new MenuBackButton(new ItemBuilder(Material.OAK_DOOR).name("&7Back to &r{PreviousName}").build());
        ArtButton L = new ArtButton(new ItemBuilder(Material.BARRIER).name("&b&nLeave from current universe").build()).listener((inventoryClickEvent, menu) -> {
            enginePlayer.setUniverse(null);
            player.closeInventory();
        });
        return new ArtButton[] { V, V, V, V, V, V, V, G, G, V, V, V, V, V, V, V, G, N, V, V, V, V, V, V, V, G, P, V, V, V, V, V, V, V, G, G, V, V, V, V, V, V, V, G, L, V, V, V, V, V, V, V, G, B };
    });
    ArtMenu artMenu = artist.createMenu(VanillaSource.getPlugin().getArtGUI(), "&nUniverse list");
    artMenu.asyncCreate(menu -> {
        for (ParallelUniverse universe : VanillaSourceAPI.getInstance().getAllUniverse()) {
            menu.addButton(new ArtButton(new ItemBuilder(Material.END_PORTAL_FRAME).name(universe.getName()).lore("&7Click to join.").build()).listener((inventoryClickEvent, menu1) -> {
                enginePlayer.setUniverse(universe);
                player.closeInventory();
                player.sendMessage("§7Switched to §r" + universe.getName());
            }));
        }
    });
    artMenu.open(player);
}
Also used : Artist(be4rjp.artgui.frame.Artist) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) be4rjp.artgui.button(be4rjp.artgui.button) Artist(be4rjp.artgui.frame.Artist) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) VanillaSource(thpmc.vanilla_source.VanillaSource) VanillaSourceAPI(thpmc.vanilla_source.api.VanillaSourceAPI) Player(org.bukkit.entity.Player) Material(org.bukkit.Material) ArtMenu(be4rjp.artgui.menu.ArtMenu) ArtMenu(be4rjp.artgui.menu.ArtMenu) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer)

Example 7 with ParallelUniverse

use of thpmc.vanilla_source.api.world.parallel.ParallelUniverse in project VanillaSource by TheHollowPlanetMC.

the class ParallelStructure method clearStructureData.

/**
 * 適用されている構造物データを消去します
 * @param EnginePlayer 構造物を変化させて見せるプレイヤー
 * @param chunkUpdate チャンクアップデートのパケットを送信するかどうか
 */
public void clearStructureData(EnginePlayer EnginePlayer, boolean chunkUpdate) {
    ParallelUniverse universe = EnginePlayer.getUniverse();
    if (universe == null)
        return;
    Set<Block> blocks = dataMap.get(universe.getName());
    if (blocks == null)
        return;
    ParallelWorld parallelWorld = universe.getWorld(Objects.requireNonNull(baseLocation.getWorld()).getName());
    for (Block block : blocks) {
        parallelWorld.removeBlockData(block.getX(), block.getY(), block.getZ());
    }
    Set<BlockPosition3i> blockPosition3iSet = new HashSet<>();
    blocks.forEach(block -> blockPosition3iSet.add(new BlockPosition3i(block.getX(), block.getY(), block.getZ())));
    parallelWorld.sendMultiBlockUpdate(blockPosition3iSet);
}
Also used : ParallelWorld(thpmc.vanilla_source.api.world.parallel.ParallelWorld) BlockPosition3i(thpmc.vanilla_source.util.BlockPosition3i) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) Block(org.bukkit.block.Block)

Example 8 with ParallelUniverse

use of thpmc.vanilla_source.api.world.parallel.ParallelUniverse in project VanillaSource by TheHollowPlanetMC.

the class BlockChangePacketHandler method rewrite.

@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
    ParallelUniverse universe = EnginePlayer.getUniverse();
    if (universe == null)
        return packet;
    String worldName = EnginePlayer.getBukkitPlayer().getWorld().getName();
    ParallelWorld parallelWorld = universe.getWorld(worldName);
    try {
        PacketPlayOutBlockChange blockChange = (PacketPlayOutBlockChange) packet;
        BlockPosition bp = (BlockPosition) a.get(blockChange);
        BlockData blockData = parallelWorld.getBlockData(bp.getX(), bp.getY(), bp.getZ());
        if (blockData == null)
            return packet;
        PacketPlayOutBlockChange newPacket = new PacketPlayOutBlockChange();
        a.set(newPacket, bp);
        newPacket.block = ((CraftBlockData) blockData).getState();
        return newPacket;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return packet;
}
Also used : ParallelWorld(thpmc.vanilla_source.api.world.parallel.ParallelWorld) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) PacketPlayOutBlockChange(net.minecraft.server.v1_15_R1.PacketPlayOutBlockChange) BlockData(org.bukkit.block.data.BlockData) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)

Example 9 with ParallelUniverse

use of thpmc.vanilla_source.api.world.parallel.ParallelUniverse in project VanillaSource by TheHollowPlanetMC.

the class PlayerJoinQuitListener method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent event) {
    // Inject packet handler
    Player player = event.getPlayer();
    EnginePlayer enginePlayer = ImplEnginePlayer.onPlayerJoin(player);
    ParallelUniverse universe = VanillaSourceAPI.getInstance().createUniverse(player.getUniqueId().toString());
    universe.addPlayer(enginePlayer);
    Object wrappedParallelPlayer = ChiyogamiManager.getWrappedParallelPlayer(player);
    if (wrappedParallelPlayer != null)
        ChiyogamiManager.setCheckFunction(enginePlayer, wrappedParallelPlayer);
    PacketHandler packetHandler = new PacketHandler(enginePlayer);
    try {
        ChannelPipeline pipeline = NMSManager.getNMSHandler().getChannel(player).pipeline();
        pipeline.addBefore("packet_handler", VanillaSource.getPlugin().getName() + "PacketInjector:" + player.getName(), packetHandler);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ImplEnginePlayer(thpmc.vanilla_source.impl.ImplEnginePlayer) Player(org.bukkit.entity.Player) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) PacketHandler(thpmc.vanilla_source.nms.PacketHandler) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) ImplEnginePlayer(thpmc.vanilla_source.impl.ImplEnginePlayer) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) ChannelPipeline(io.netty.channel.ChannelPipeline) EventHandler(org.bukkit.event.EventHandler)

Example 10 with ParallelUniverse

use of thpmc.vanilla_source.api.world.parallel.ParallelUniverse in project VanillaSource by TheHollowPlanetMC.

the class FlyPacketHandler method rewrite.

@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
    ParallelUniverse universe = EnginePlayer.getUniverse();
    if (universe == null)
        return packet;
    World world = EnginePlayer.getBukkitPlayer().getWorld();
    String worldName = world.getName();
    ParallelWorld parallelWorld = universe.getWorld(worldName);
    EntityPlayer entityPlayer = ((CraftPlayer) EnginePlayer.getBukkitPlayer()).getHandle();
    int x = NumberConversions.floor(entityPlayer.locX());
    int y = NumberConversions.floor(entityPlayer.locY());
    int z = NumberConversions.floor(entityPlayer.locZ());
    int downY = y - 1;
    downY = Math.max(0, downY);
    if (parallelWorld.hasBlockData(x, y, z) || parallelWorld.hasBlockData(x, downY, z)) {
        try {
            PlayerConnection playerConnection = entityPlayer.playerConnection;
            C.set(playerConnection, 0);
            E.set(playerConnection, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return packet;
}
Also used : ParallelWorld(thpmc.vanilla_source.api.world.parallel.ParallelWorld) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) World(org.bukkit.World) ParallelWorld(thpmc.vanilla_source.api.world.parallel.ParallelWorld) PlayerConnection(net.minecraft.server.v1_15_R1.PlayerConnection)

Aggregations

ParallelUniverse (thpmc.vanilla_source.api.world.parallel.ParallelUniverse)16 ParallelWorld (thpmc.vanilla_source.api.world.parallel.ParallelWorld)12 World (org.bukkit.World)7 ParallelChunk (thpmc.vanilla_source.api.world.parallel.ParallelChunk)6 BlockData (org.bukkit.block.data.BlockData)4 Player (org.bukkit.entity.Player)3 EnginePlayer (thpmc.vanilla_source.api.player.EnginePlayer)3 SectionTypeArray (thpmc.vanilla_source.util.SectionTypeArray)3 List (java.util.List)2 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)2 ChunkSnapshot (org.bukkit.ChunkSnapshot)2 Block (org.bukkit.block.Block)2 CraftBlockData (org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)2 VanillaSourceAPI (thpmc.vanilla_source.api.VanillaSourceAPI)2 BlockPosition3i (thpmc.vanilla_source.util.BlockPosition3i)2 SectionLevelArray (thpmc.vanilla_source.util.SectionLevelArray)2 be4rjp.artgui.button (be4rjp.artgui.button)1 Artist (be4rjp.artgui.frame.Artist)1 ArtMenu (be4rjp.artgui.menu.ArtMenu)1 IncompleteRegionException (com.sk89q.worldedit.IncompleteRegionException)1