use of com.comphenix.protocol.wrappers.BlockPosition in project BetterRTP by SuperRonanCraft.
the class PortalsCache method cachePortal.
public void cachePortal(Player p, Location loc, boolean loc2) {
PortalsRegionInfo portal;
if (portalsBeingCreated.containsKey(p)) {
portal = portalsBeingCreated.get(p);
} else {
portal = new PortalsRegionInfo();
portalsBeingCreated.put(p, portal);
}
Location old_loc1 = portal.loc_1;
Location old_loc2 = portal.loc_2;
if (loc2)
portal.loc_2 = loc;
else
portal.loc_1 = loc;
if (portal.loc_1 != null && portal.loc_2 != null)
if (old_loc1 == null || old_loc2 == null)
addonPortals.msgs.getLocation_Ready(p);
if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
// if (portal.loc_1 != null && portal.loc_2 != null) {
// if (Math.abs(portal.loc_1.getBlockX() - portal.loc_2.getBlockX()) <= 10)
// if (Math.abs(portal.loc_1.getBlockZ() - portal.loc_2.getBlockZ()) <= 10)
// if (Math.abs(portal.loc_1.getBlockY() - portal.loc_2.getBlockY()) <= 10) {
// preview(portal.loc_1, portal.loc_2);
// }
/*Location max = portal.loc_1;
Location min = portal.loc_2;
for (int x = Math.max(max.getBlockX(), min.getBlockX()); x >= Math.min(min.getBlockX(), max.getBlockX()); x--) {
for (int y = Math.max(max.getBlockY(), min.getBlockY()); y >= Math.min(min.getBlockY(), max.getBlockY()); y--) {
for (int z = Math.max(max.getBlockZ(), min.getBlockZ()); z >= Math.min(min.getBlockZ(), max.getBlockZ()); z--) {
WrapperPlayServerBlockChange packet = new WrapperPlayServerBlockChange(pm.createPacket(PacketType.Play.Server.BLOCK_CHANGE));
packet.setBlockData(WrappedBlockData.createData(Material.REDSTONE_BLOCK));
packet.setLocation(new BlockPosition(new Location(max.getWorld(), x, y, z).toVector()));
packet.sendPacket(p);
//Block block = max.getWorld().getBlockAt(x, y, z);
//block.setType(Material.GLOWSTONE);
}
}
}*/
// } else {
WrapperPlayServerBlockChange packet = new WrapperPlayServerBlockChange(pm.createPacket(PacketType.Play.Server.BLOCK_CHANGE));
packet.setBlockData(WrappedBlockData.createData(Material.GLOWSTONE));
packet.setLocation(new BlockPosition(loc.toVector()));
packet.sendPacket(p);
// }
} else {
try {
if (loc2)
p.sendBlockChange(portal.loc_2, Material.GLOWSTONE.createBlockData());
else
p.sendBlockChange(portal.loc_1, Material.GLOWSTONE.createBlockData());
} catch (Exception e) {
// Not 1.13+ (dont show block changes)
}
}
}
use of com.comphenix.protocol.wrappers.BlockPosition in project CriticalMiningTech by CriticalGameEror.
the class BlockDamage method configureBreakingPacket.
protected void configureBreakingPacket(double hardness, Player player, Block block) {
PacketContainer breakingAnimation = manager.createPacket(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
// this enusres that the player wont conflict with another player's breaking animation
int entityId = player.getEntityId() + 1;
entityId = entityId * 1000;
breakingAnimation.getIntegers().write(0, entityId);
breakingAnimation.getBlockPositionModifier().write(0, new BlockPosition(block.getX(), block.getY(), block.getZ()));
breakingTimeCheck(hardness, player, block, breakingAnimation);
}
use of com.comphenix.protocol.wrappers.BlockPosition in project WheelCore by Plugindustry.
the class PlayerUtil method sendBlockCrack.
public static void sendBlockCrack(@Nonnull Player player, @Nonnull Location location, int level) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
packet.getIntegers().write(0, 0);
packet.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
packet.getIntegers().write(1, level);
try {
WheelCore.protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
use of com.comphenix.protocol.wrappers.BlockPosition in project WheelCore by Plugindustry.
the class TextureManager method generatePacket.
private static PacketContainer generatePacket(Location loc, ItemStack item) {
PacketContainer packet = templatePacket.shallowClone();
packet.getBlockPositionModifier().write(0, new BlockPosition(loc.toVector()));
NbtCompound compound = NbtFactory.ofCompound(null);
compound.put("Delay", (short) 160);
compound.put("MaxNearbyEntities", (short) 0);
compound.put("MaxSpawnDelay", (short) 800);
compound.put("MinSpawnDelay", (short) 200);
compound.put("RequiredPlayerRange", (short) 0);
compound.put("SpawnCount", (short) 0);
compound.put("SpawnRange", (short) 0);
NbtCompound spawnDataCompound = NbtFactory.ofCompound(null);
NbtCompound entityCompound = NbtFactory.ofCompound(null);
entityCompound.put("id", "minecraft:item");
entityCompound.put("Item", NbtFactory.fromNMS(ShadowManager.shadowUnpack(CraftItemStack.asNMSCopy(item).save(new NBTTagCompound())), null));
spawnDataCompound.put("entity", entityCompound);
compound.put("SpawnData", spawnDataCompound);
packet.getNbtModifier().write(0, compound);
return packet;
}
use of com.comphenix.protocol.wrappers.BlockPosition in project WheelCore by Plugindustry.
the class PlayerUtil method broadcastBlockCrack.
public static void broadcastBlockCrack(@Nonnull Location location, int level) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
packet.getIntegers().write(0, 0);
packet.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
packet.getIntegers().write(1, level);
WheelCore.protocolManager.broadcastServerPacket(packet);
}
Aggregations