Search in sources :

Example 26 with PacketPlayOutBlockChange

use of net.minecraft.server.v1_9_R1.PacketPlayOutBlockChange in project TheAPI by TheDevTec.

the class v1_7_R4 method packetBlockChange.

@Override
public Object packetBlockChange(World world, Position position) {
    PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange();
    Object chunk = getChunk(world, position.getBlockX() >> 4, position.getBlockZ() >> 4);
    packet.data = getData(chunk, position.getBlockX(), position.getBlockY(), position.getBlockZ());
    packet.block = (Block) getBlock(chunk, position.getBlockX(), position.getBlockY(), position.getBlockZ());
    try {
        posX.set(packet, position.getBlockX());
        posY.set(packet, position.getBlockY());
        posZ.set(packet, position.getBlockZ());
    } catch (Exception e) {
    }
    return packet;
}
Also used : PacketPlayOutBlockChange(net.minecraft.server.v1_7_R4.PacketPlayOutBlockChange)

Example 27 with PacketPlayOutBlockChange

use of net.minecraft.server.v1_9_R1.PacketPlayOutBlockChange in project TheAPI by TheDevTec.

the class v1_8_R1 method packetBlockChange.

@Override
public Object packetBlockChange(World world, Position position) {
    PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange();
    packet.block = (IBlockData) position.getIBlockData();
    try {
        pos.set(packet, position.getBlockPosition());
    } catch (Exception e) {
    }
    return packet;
}
Also used : PacketPlayOutBlockChange(net.minecraft.server.v1_8_R1.PacketPlayOutBlockChange)

Example 28 with PacketPlayOutBlockChange

use of net.minecraft.server.v1_9_R1.PacketPlayOutBlockChange in project THP-Engine 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.engine.api.world.parallel.ParallelWorld) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) ParallelUniverse(thpmc.engine.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 29 with PacketPlayOutBlockChange

use of net.minecraft.server.v1_9_R1.PacketPlayOutBlockChange in project L2X9RebootCore by 254nm.

the class NoCom method outgoing.

@Override
public void outgoing(PacketEvent.Outgoing event) throws Throwable {
    PacketPlayOutBlockChange packet = (PacketPlayOutBlockChange) event.getPacket();
    BlockPosition position = (BlockPosition) outPosF.get(packet);
    Player player = event.getPlayer();
    Point packetP = new Point(position.getX(), position.getZ());
    Point playerP = new Point((int) player.getLocation().getX(), (int) player.getLocation().getZ());
    if (playerP.distance(packetP) > Bukkit.getServer().getViewDistance() * 16) {
        event.setCancelled(true);
    }
}
Also used : Player(org.bukkit.entity.Player) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) PacketPlayOutBlockChange(net.minecraft.server.v1_12_R1.PacketPlayOutBlockChange)

Aggregations

PacketPlayOutBlockChange (net.minecraft.server.v1_12_R1.PacketPlayOutBlockChange)3 PacketPlayOutBlockChange (net.minecraft.server.v1_15_R1.PacketPlayOutBlockChange)3 PacketPlayOutBlockChange (net.minecraft.server.v1_10_R1.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_11_R1.PacketPlayOutBlockChange)2 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)2 PacketPlayOutBlockChange (net.minecraft.server.v1_13_R1.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_13_R2.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_14_R1.PacketPlayOutBlockChange)2 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)2 PacketPlayOutBlockChange (net.minecraft.server.v1_16_R1.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_7_R4.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_8_R1.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_8_R2.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_8_R3.PacketPlayOutBlockChange)2 PacketPlayOutBlockChange (net.minecraft.server.v1_9_R1.PacketPlayOutBlockChange)2 BlockData (org.bukkit.block.data.BlockData)2 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)2 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)2 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)1 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)1