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);
}
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);
}
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;
}
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();
}
}
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;
}
Aggregations