Search in sources :

Example 16 with World

use of net.minecraft.server.v1_12_R1.World in project askyblock by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 17 with World

use of net.minecraft.server.v1_12_R1.World in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 18 with World

use of net.minecraft.server.v1_12_R1.World in project Citizens2 by CitizensDev.

the class NMSImpl method sendPacketsNearby.

public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
    radius *= radius;
    final org.bukkit.World world = location.getWorld();
    for (Player ply : Bukkit.getServer().getOnlinePlayers()) {
        if (ply == null || world != ply.getWorld() || (from != null && !ply.canSee(from))) {
            continue;
        }
        if (location.distanceSquared(ply.getLocation(PACKET_CACHE_LOCATION)) > radius) {
            continue;
        }
        for (Packet<?> packet : packets) {
            NMSImpl.sendPacket(ply, packet);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) World(org.bukkit.World)

Example 19 with World

use of net.minecraft.server.v1_12_R1.World in project Citizens2 by CitizensDev.

the class NMSImpl method updateNavigationWorld.

@Override
public void updateNavigationWorld(org.bukkit.entity.Entity entity, World world) {
    if (NAVIGATION_WORLD_FIELD == null)
        return;
    Entity en = NMSImpl.getHandle(entity);
    if (en == null || !(en instanceof EntityInsentient))
        return;
    EntityInsentient handle = (EntityInsentient) en;
    WorldServer worldHandle = ((CraftWorld) world).getHandle();
    try {
        NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
    } catch (Exception e) {
        Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
    }
}
Also used : PathEntity(net.minecraft.server.v1_12_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_12_R1.Entity) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) ReportedException(net.minecraft.server.v1_12_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 20 with World

use of net.minecraft.server.v1_12_R1.World in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.setPacketListener(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerLook = new PlayerControllerLook(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
    try {
        ADVANCEMENT_DATA_PLAYER.set(this, new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_12_R1.network.EmptySocket) IOException(java.io.IOException) EmptyNetHandler(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_12_R1.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_12_R1.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerJump) EmptyAdvancementDataPlayer(net.citizensnpcs.nms.v1_12_R1.util.EmptyAdvancementDataPlayer) NetworkManager(net.minecraft.server.v1_12_R1.NetworkManager) EmptyNetworkManager(net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager) EmptySocket(net.citizensnpcs.nms.v1_12_R1.network.EmptySocket) Socket(java.net.Socket)

Aggregations

CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)6 Player (org.bukkit.entity.Player)6 PacketPlayOutTitle (net.minecraft.server.v1_12_R1.PacketPlayOutTitle)5 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)4 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)2 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)2 World (net.minecraft.server.v1_7_R4.World)2 IOException (java.io.IOException)1 Socket (java.net.Socket)1 CommandException (net.citizensnpcs.api.command.exception.CommandException)1 EmptyNetHandler (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_12_R1.network.EmptySocket)1 EmptyAdvancementDataPlayer (net.citizensnpcs.nms.v1_12_R1.util.EmptyAdvancementDataPlayer)1 PlayerControllerJump (net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerJump)1 PlayerControllerLook (net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerLook)1 PlayerControllerMove (net.citizensnpcs.nms.v1_12_R1.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_12_R1.util.PlayerNavigation)1 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)1 World (net.minecraft.server.v1_10_R1.World)1