Java 类org.bukkit.craftbukkit.CraftWorld 实例源码

项目:Uranium    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:Uranium    文件:CraftBlockState.java   
public CraftBlockState(final Block block) {
    this.world = (CraftWorld) block.getWorld();
    this.x = block.getX();
    this.y = block.getY();
    this.z = block.getZ();
    this.type = block.getTypeId();
    this.light = block.getLightLevel();
    this.chunk = (CraftChunk) block.getChunk();
    this.flag = 3;
    // Cauldron start - save TE data
    TileEntity te = world.getHandle().getTileEntity(x, y, z);
    if (te != null)
    {
        nbt = new NBTTagCompound();
        te.writeToNBT(nbt);
    }
    else nbt = null;
    // Cauldron end

    createData(block.getData());
}
项目:Uranium    文件:VanillaCommandWrapper.java   
private static net.minecraft.command.ICommandSender getListener(CommandSender sender)
{
    if ( sender instanceof CraftPlayer )
    {
        return new PlayerListener( ( (CraftPlayer) sender ).getHandle() );
    }
    if ( sender instanceof CraftBlockCommandSender )
    {
        CraftBlockCommandSender commandBlock = (CraftBlockCommandSender) sender;
        Block block = commandBlock.getBlock();
        return ( (net.minecraft.tileentity.TileEntityCommandBlock) ( (CraftWorld) block.getWorld() ).getTileEntityAt( block.getX(), block.getY(), block.getZ() ) ).func_145993_a();
    }
    if ( sender instanceof CraftMinecartCommand )
    {
        return ( (net.minecraft.entity.EntityMinecartCommandBlock) ( (CraftMinecartCommand) sender ).getHandle() ).func_145822_e();
    }
    return new ConsoleListener(sender); // Assume console/rcon
}
项目:ThermosRebased    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:ThermosRebased    文件:CraftBlockState.java   
public CraftBlockState(final Block block) {
    this.world = (CraftWorld) block.getWorld();
    this.x = block.getX();
    this.y = block.getY();
    this.z = block.getZ();
    this.type = block.getTypeId();
    this.light = block.getLightLevel();
    this.chunk = (CraftChunk) block.getChunk();
    this.flag = 3;
    // Cauldron start - save TE data
    TileEntity te = world.getHandle().getTileEntity(x, y, z);
    if (te != null)
    {
        nbt = new NBTTagCompound();
        te.writeToNBT(nbt);
    }
    else nbt = null;
    // Cauldron end

    createData(block.getData());
}
项目:ThermosRebased    文件:VanillaCommandWrapper.java   
private static net.minecraft.command.ICommandSender getListener(CommandSender sender)
{
    if ( sender instanceof CraftPlayer )
    {
        return new PlayerListener( ( (CraftPlayer) sender ).getHandle() );
    }
    if ( sender instanceof CraftBlockCommandSender )
    {
        CraftBlockCommandSender commandBlock = (CraftBlockCommandSender) sender;
        Block block = commandBlock.getBlock();
        return ( (net.minecraft.tileentity.TileEntityCommandBlock) ( (CraftWorld) block.getWorld() ).getTileEntityAt( block.getX(), block.getY(), block.getZ() ) ).func_145993_a();
    }
    if ( sender instanceof CraftMinecartCommand )
    {
        return ( (net.minecraft.entity.EntityMinecartCommandBlock) ( (CraftMinecartCommand) sender ).getHandle() ).func_145822_e();
    }
    return new ConsoleListener(sender); // Assume console/rcon
}
项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);

    boolean canBuild = true;
    for (int i = 0; i < blockStates.size(); i++) {
        if (!canBuild(craftWorld, player, blockStates.get(i).getX(), blockStates.get(i).getZ())) {
            canBuild = false;
            break;
        }
    }

    BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:KCauldron    文件:VanillaCommandWrapper.java   
private static net.minecraft.command.ICommandSender getListener(CommandSender sender)
{
    if ( sender instanceof CraftPlayer )
    {
        return new PlayerListener( ( (CraftPlayer) sender ).getHandle() );
    }
    if ( sender instanceof CraftBlockCommandSender )
    {
        CraftBlockCommandSender commandBlock = (CraftBlockCommandSender) sender;
        Block block = commandBlock.getBlock();
        return ( (net.minecraft.tileentity.TileEntityCommandBlock) ( (CraftWorld) block.getWorld() ).getTileEntityAt( block.getX(), block.getY(), block.getZ() ) ).func_145993_a();
    }
    if ( sender instanceof CraftMinecartCommand )
    {
        return ( (net.minecraft.entity.EntityMinecartCommandBlock) ( (CraftMinecartCommand) sender ).getHandle() ).func_145822_e();
    }
    return new ConsoleListener(sender); // Assume console/rcon
}
项目:Craftbukkit    文件:CraftEventFactory.java   
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
    CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
    EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
    CraftWorld world = (CraftWorld) entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    victim.expToDrop = event.getDroppedExp();

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
        if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;

        world.dropItemNaturally(entity.getLocation(), stack);
    }

    return event;
}
项目:Cauldron-Old    文件:VanillaCommandWrapper.java   
private static net.minecraft.command.ICommandSender getListener(CommandSender sender)
{
    if ( sender instanceof CraftPlayer )
    {
        return new PlayerListener( ( (CraftPlayer) sender ).getHandle() );
    }
    if ( sender instanceof CraftBlockCommandSender )
    {
        CraftBlockCommandSender commandBlock = (CraftBlockCommandSender) sender;
        Block block = commandBlock.getBlock();
        return ( (net.minecraft.tileentity.TileEntityCommandBlock) ( (CraftWorld) block.getWorld() ).getTileEntityAt( block.getX(), block.getY(), block.getZ() ) ).func_145993_a();
    }
    if ( sender instanceof CraftMinecartCommand )
    {
        return ( (net.minecraft.entity.EntityMinecartCommandBlock) ( (CraftMinecartCommand) sender ).getHandle() ).func_145822_e();
    }
    return new ConsoleListener(sender); // Assume console/rcon
}
项目:Cauldron-Old    文件:CraftBlockState.java   
public CraftBlockState(final Block block) {
    this.world = (CraftWorld) block.getWorld();
    this.x = block.getX();
    this.y = block.getY();
    this.z = block.getZ();
    this.type = block.getTypeId();
    this.light = block.getLightLevel();
    this.chunk = (CraftChunk) block.getChunk();
    this.flag = 3;
    // Cauldron start - save TE data
    TileEntity te = world.getHandle().getTileEntity(x, y, z);
    if (te != null)
    {
        nbt = new NBTTagCompound();
        te.writeToNBT(nbt);
    }
    else nbt = null;
    // Cauldron end

    createData(block.getData());
}
项目:Uranium    文件:CraftPlayer.java   
@Override
public void sendBlockChange(Location loc, int material, byte data) {
    if (getHandle().playerNetServerHandler == null) return;

    S23PacketBlockChange packet = new S23PacketBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());

    packet.field_148883_d = CraftMagicNumbers.getBlock(material);
    packet.field_148884_e = data;
    getHandle().playerNetServerHandler.sendPacket(packet);
}
项目:Uranium    文件:CraftPlayer.java   
public Location getBedSpawnLocation() {
    World world = getServer().getWorld(getHandle().spawnWorld);
    net.minecraft.util.ChunkCoordinates bed = getHandle().getBedLocation();

    if (world != null && bed != null) {
        bed = net.minecraft.entity.player.EntityPlayer.verifyRespawnCoordinates(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced());
        if (bed != null) {
            return new Location(world, bed.posX, bed.posY, bed.posZ);
        }
    }
    return null;
}
项目:Uranium    文件:CraftPainting.java   
private void update() {
    net.minecraft.world.WorldServer world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.item.EntityPainting painting = new net.minecraft.entity.item.EntityPainting(world);
    painting.field_146063_b = getHandle().field_146063_b;
    painting.field_146064_c = getHandle().field_146064_c;
    painting.field_146062_d = getHandle().field_146062_d;
    painting.art = getHandle().art;
    painting.setDirection(getHandle().hangingDirection);
    getHandle().setDead();
    getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important
    world.spawnEntityInWorld(painting);
    this.entity = painting;
}
项目:Uranium    文件:CraftItemFrame.java   
public boolean setFacingDirection(BlockFace face, boolean force) {
    if (!super.setFacingDirection(face, force)) {
        return false;
    }

    net.minecraft.world.WorldServer world = ((CraftWorld) this.getWorld()).getHandle();
    world.getEntityTracker().removeEntityFromAllTrackingPlayers(this.getHandle());
    world.getEntityTracker().addEntityToTracker(this.getHandle());
    return true;
}
项目:Uranium    文件:CraftMapView.java   
public World getWorld() {
    int dimension = worldMap.dimension; // Cauldron - byte -> int for Forge
    for (World world : Bukkit.getServer().getWorlds()) {
        if (((CraftWorld) world).getHandle().provider.dimensionId == dimension) {
            return world;
        }
    }
    return null;
}
项目:Uranium    文件:CraftBlock.java   
public boolean isEmpty() {
    // Cauldron start - support custom air blocks (Railcraft player aura tracking block)
    //return getType() == Material.AIR;
    if (getType() == Material.AIR) return true;
    if (!(getWorld() instanceof CraftWorld)) return false;
    return ((CraftWorld) getWorld()).getHandle().isAirBlock(getX(), getY(), getZ());
    // Cauldron end
}
项目:Uranium    文件:CraftCommandBlock.java   
public CraftCommandBlock(Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    commandBlock = (TileEntityCommandBlock) world.getTileEntityAt(getX(), getY(), getZ());
    command = commandBlock.func_145993_a().field_145763_e;
    name = commandBlock.func_145993_a().getCommandSenderName();
}
项目:Uranium    文件:CraftSign.java   
public CraftSign(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    sign = (net.minecraft.tileentity.TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
    // Spigot start
    if (sign == null) {
        lines = new String[]{"", "", "", ""};
        return;
    }
    // Spigot end
    lines = new String[sign.signText.length];
    System.arraycopy(sign.signText, 0, lines, 0, lines.length);
}
项目:Uranium    文件:CraftSkull.java   
public CraftSkull(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
    profile = skull.func_152108_a();
    skullType = getSkullType(skull.func_145904_a());
    rotation = (byte) skull.getRotation();
}
项目:Uranium    文件:CraftEventFactory.java   
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
    net.minecraft.world.WorldServer worldServer = world.getHandle();
    int spawnSize = Bukkit.getServer().getSpawnRadius();

    if (world.getHandle().provider.dimensionId != 0) return true;
    if (spawnSize <= 0) return true;
    if (((CraftServer) Bukkit.getServer()).getHandle().func_152603_m().func_152690_d()) return true;
    if (player.isOp()) return true;

    net.minecraft.util.ChunkCoordinates chunkcoordinates = worldServer.getSpawnPoint();

    int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.posX), Math.abs(z - chunkcoordinates.posZ));
    return distanceFromSpawn > spawnSize;
}
项目:ProjectAres    文件:NMSHacks.java   
public FakeArmorStand(World world, @Nullable String name, boolean invisible, boolean marker, boolean small) {
    super(new EntityArmorStand(((CraftWorld) world).getHandle()));

    entity.setInvisible(invisible);
    entity.setMarker(marker);
    entity.setSmall(small);
    entity.setBasePlate(false);
    entity.setArms(false);

    if(name != null) {
        entity.setCustomName(name);
        entity.setCustomNameVisible(true);
    }
}
项目:ThermosRebased    文件:CraftPlayer.java   
@Override
public void sendBlockChange(Location loc, int material, byte data) {
    if (getHandle().playerNetServerHandler == null) return;

    S23PacketBlockChange packet = new S23PacketBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());

    packet.field_148883_d = CraftMagicNumbers.getBlock(material);
    packet.field_148884_e = data;
    getHandle().playerNetServerHandler.sendPacket(packet);
}
项目:ThermosRebased    文件:CraftPlayer.java   
public Location getBedSpawnLocation() {
    World world = getServer().getWorld(getHandle().spawnWorld);
    net.minecraft.util.ChunkCoordinates bed = getHandle().getBedLocation();

    if (world != null && bed != null) {
        bed = net.minecraft.entity.player.EntityPlayer.verifyRespawnCoordinates(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced());
        if (bed != null) {
            return new Location(world, bed.posX, bed.posY, bed.posZ);
        }
    }
    return null;
}
项目:ThermosRebased    文件:CraftPainting.java   
private void update() {
    net.minecraft.world.WorldServer world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.item.EntityPainting painting = new net.minecraft.entity.item.EntityPainting(world);
    painting.field_146063_b = getHandle().field_146063_b;
    painting.field_146064_c = getHandle().field_146064_c;
    painting.field_146062_d = getHandle().field_146062_d;
    painting.art = getHandle().art;
    painting.setDirection(getHandle().hangingDirection);
    getHandle().setDead();
    getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important
    world.spawnEntityInWorld(painting);
    this.entity = painting;
}
项目:ThermosRebased    文件:CraftItemFrame.java   
public boolean setFacingDirection(BlockFace face, boolean force) {
    if (!super.setFacingDirection(face, force)) {
        return false;
    }

    net.minecraft.world.WorldServer world = ((CraftWorld) this.getWorld()).getHandle();
    world.getEntityTracker().removeEntityFromAllTrackingPlayers(this.getHandle());
    world.getEntityTracker().addEntityToTracker(this.getHandle());
    return true;
}
项目:ThermosRebased    文件:CraftMapView.java   
public World getWorld() {
    int dimension = worldMap.dimension; // Cauldron - byte -> int for Forge
    for (World world : Bukkit.getServer().getWorlds()) {
        if (((CraftWorld) world).getHandle().provider.dimensionId == dimension) {
            return world;
        }
    }
    return null;
}
项目:ThermosRebased    文件:CraftBlock.java   
public boolean isEmpty() {
    // Cauldron start - support custom air blocks (Railcraft player aura tracking block)
    //return getType() == Material.AIR;
    if (getType() == Material.AIR) return true;
    if (!(getWorld() instanceof CraftWorld)) return false;
    return ((CraftWorld) getWorld()).getHandle().isAirBlock(getX(), getY(), getZ());
    // Cauldron end
}
项目:ThermosRebased    文件:CraftCommandBlock.java   
public CraftCommandBlock(Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    commandBlock = (TileEntityCommandBlock) world.getTileEntityAt(getX(), getY(), getZ());
    command = commandBlock.func_145993_a().field_145763_e;
    name = commandBlock.func_145993_a().getCommandSenderName();
}
项目:ThermosRebased    文件:CraftSign.java   
public CraftSign(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    sign = (net.minecraft.tileentity.TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
    // Spigot start
    if (sign == null) {
        lines = new String[]{"", "", "", ""};
        return;
    }
    // Spigot end
    lines = new String[sign.signText.length];
    System.arraycopy(sign.signText, 0, lines, 0, lines.length);
}
项目:ThermosRebased    文件:CraftSkull.java   
public CraftSkull(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
    profile = skull.func_152108_a();
    skullType = getSkullType(skull.func_145904_a());
    rotation = (byte) skull.getRotation();
}
项目:ThermosRebased    文件:CraftEventFactory.java   
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
    net.minecraft.world.WorldServer worldServer = world.getHandle();
    int spawnSize = Bukkit.getServer().getSpawnRadius();

    if (world.getHandle().provider.dimensionId != 0) return true;
    if (spawnSize <= 0) return true;
    if (((CraftServer) Bukkit.getServer()).getHandle().func_152603_m().func_152690_d()) return true;
    if (player.isOp()) return true;

    net.minecraft.util.ChunkCoordinates chunkcoordinates = worldServer.getSpawnPoint();

    int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.posX), Math.abs(z - chunkcoordinates.posZ));
    return distanceFromSpawn > spawnSize;
}
项目:Thermos    文件:CraftPlayer.java   
@Override
public void sendBlockChange(Location loc, int material, byte data) {
    if (getHandle().playerNetServerHandler == null) return;

    S23PacketBlockChange packet = new S23PacketBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());

    packet.field_148883_d = CraftMagicNumbers.getBlock(material);
    packet.field_148884_e = data;
    getHandle().playerNetServerHandler.sendPacket(packet);
}
项目:Thermos    文件:CraftPlayer.java   
public Location getBedSpawnLocation() {
    World world = getServer().getWorld(getHandle().spawnWorld);
    net.minecraft.util.ChunkCoordinates bed = getHandle().getBedLocation();

    if (world != null && bed != null) {
        bed = net.minecraft.entity.player.EntityPlayer.verifyRespawnCoordinates(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced());
        if (bed != null) {
            return new Location(world, bed.posX, bed.posY, bed.posZ);
        }
    }
    return null;
}
项目:Thermos    文件:CraftItemFrame.java   
public boolean setFacingDirection(BlockFace face, boolean force) {
    if (!super.setFacingDirection(face, force)) {
        return false;
    }

    net.minecraft.world.WorldServer world = ((CraftWorld) this.getWorld()).getHandle();
    world.getEntityTracker().removeEntityFromAllTrackingPlayers(this.getHandle());
    world.getEntityTracker().addEntityToTracker(this.getHandle());
    return true;
}
项目:Thermos    文件:CraftBlock.java   
public boolean isEmpty() {
    // Cauldron start - support custom air blocks (Railcraft player aura tracking block)
    //return getType() == Material.AIR;
    if (getType() == Material.AIR) return true;
    if (!(getWorld() instanceof CraftWorld)) return false;
    return ((CraftWorld) getWorld()).getHandle().isAirBlock(getX(), getY(), getZ());
    // Cauldron end
}
项目:Thermos    文件:CraftCommandBlock.java   
public CraftCommandBlock(Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    commandBlock = (TileEntityCommandBlock) world.getTileEntityAt(getX(), getY(), getZ());
    command = commandBlock.func_145993_a().field_145763_e;
    name = commandBlock.func_145993_a().getCommandSenderName();
}
项目:Thermos    文件:CraftSign.java   
public CraftSign(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    sign = (net.minecraft.tileentity.TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
    // Spigot start
    if (sign == null) {
        lines = new String[]{"", "", "", ""};
        return;
    }
    // Spigot end
    lines = new String[sign.signText.length];
    System.arraycopy(sign.signText, 0, lines, 0, lines.length);
}
项目:CraftBukkit    文件:CraftPainting.java   
private void update() {
    WorldServer world = ((CraftWorld) getWorld()).getHandle();
    EntityPainting painting = new EntityPainting(world);
    painting.x = getHandle().x;
    painting.y = getHandle().y;
    painting.z = getHandle().z;
    painting.art = getHandle().art;
    painting.setDirection(getHandle().direction);
    getHandle().die();
    getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important
    world.addEntity(painting);
    this.entity = painting;
}
项目:Thermos    文件:CraftEventFactory.java   
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
    net.minecraft.world.WorldServer worldServer = world.getHandle();
    int spawnSize = Bukkit.getServer().getSpawnRadius();

    if (world.getHandle().provider.dimensionId != 0) return true;
    if (spawnSize <= 0) return true;
    if (((CraftServer) Bukkit.getServer()).getHandle().func_152603_m().func_152690_d()) return true;
    if (player.isOp()) return true;

    net.minecraft.util.ChunkCoordinates chunkcoordinates = worldServer.getSpawnPoint();

    int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.posX), Math.abs(z - chunkcoordinates.posZ));
    return distanceFromSpawn > spawnSize;
}