Search in sources :

Example 56 with CraftWorld

use of org.bukkit.craftbukkit.v1_7_R4.CraftWorld in project MyPet by xXKeyleXx.

the class CustomInventory method dropContentAt.

public void dropContentAt(Location loc) {
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    for (int i = 0; i < this.getSize(); i++) {
        ItemStack is = this.splitWithoutUpdate(i);
        if (is != null) {
            is = is.cloneItemStack();
            EntityItem itemEntity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), is);
            itemEntity.pickupDelay = 20;
            world.addEntity(itemEntity);
        }
    }
}
Also used : CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld) CraftItemStack(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Example 57 with CraftWorld

use of org.bukkit.craftbukkit.v1_7_R4.CraftWorld 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_11_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_11_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_11_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_11_R1.IBlockData) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 58 with CraftWorld

use of org.bukkit.craftbukkit.v1_7_R4.CraftWorld 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 59 with CraftWorld

use of org.bukkit.craftbukkit.v1_7_R4.CraftWorld in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_7_R3.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_7_R3.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    try {
        Field f = chunk.getClass().getDeclaredField("sections");
        f.setAccessible(true);
        ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
        ChunkSection chunksection = sections[b.getY() >> 4];
        if (chunksection == null) {
            chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
        }
        net.minecraft.server.v1_7_R3.Block mb = net.minecraft.server.v1_7_R3.Block.e(blockId);
        chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
        chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
        if (applyPhysics) {
            w.update(b.getX(), b.getY(), b.getZ(), mb);
        }
    } catch (Exception e) {
        // Bukkit.getLogger().info("Error");
        b.setTypeIdAndData(blockId, data, applyPhysics);
    }
}
Also used : Field(java.lang.reflect.Field) CraftWorld(org.bukkit.craftbukkit.v1_7_R3.CraftWorld) ChunkSection(net.minecraft.server.v1_7_R3.ChunkSection)

Example 60 with CraftWorld

use of org.bukkit.craftbukkit.v1_7_R4.CraftWorld in project acidisland by tastybento.

the class NMSHandler method setFlowerPotBlock.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
     * Credis: Mister_Frans (THANK YOU VERY MUCH !)
     */
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
    Location loc = block.getLocation();
    CraftWorld cw = (CraftWorld) block.getWorld();
    TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    Bukkit.getLogger().info("Debug: flowerpot materialdata = " + itemStack.toString());
    net.minecraft.server.v1_7_R3.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
    te.a(cis.getItem(), cis.getData());
    te.update();
}
Also used : TileEntityFlowerPot(net.minecraft.server.v1_7_R3.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_7_R3.CraftWorld) Location(org.bukkit.Location)

Aggregations

Location (org.bukkit.Location)13 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)10 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_9_R2.CraftWorld)9 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_8_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_8_R2.CraftWorld)5 GameProfile (com.mojang.authlib.GameProfile)4 Property (com.mojang.authlib.properties.Property)4 BigInteger (java.math.BigInteger)4 MessageDigest (java.security.MessageDigest)4 UUID (java.util.UUID)4 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)4 CraftWorld (org.bukkit.craftbukkit.v1_9_R1.CraftWorld)4 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3 Team (org.bukkit.scoreboard.Team)3 Field (java.lang.reflect.Field)2 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)2