Search in sources :

Example 76 with World

use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method getTileEntity.

private static TileEntityWildChest getTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    return (TileEntityWildChest) world.getTileEntity(blockPosition);
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Location(org.bukkit.Location)

Example 77 with World

use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) world.getTileEntity(blockPosition);
    if (tileChest != null)
        world.playBlockAction(blockPosition, tileChest.getBlock().getBlock(), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.server.v1_16_R3.TileEntityChest) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 78 with World

use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) world.getTileEntity(blockPosition);
    if (tileChest != null)
        world.playBlockAction(blockPosition, world.getType(blockPosition).getBlock(), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.server.v1_8_R3.TileEntityChest) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 79 with World

use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method getNearbyItems.

@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    List<Entity> entityList = new ArrayList<>();
    if (onlyChunk) {
        Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
        for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
        entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
    } else {
        AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
        entityList = world.a((Entity) null, boundingBox, entity -> entity instanceof EntityItem);
    }
    return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) NBTTagList(net.minecraft.server.v1_8_R3.NBTTagList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Item(org.bukkit.entity.Item) EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) EntityItem(net.minecraft.server.v1_8_R3.EntityItem) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) Inventory(org.bukkit.inventory.Inventory) ArrayList(java.util.ArrayList) Effect(org.bukkit.Effect) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTCompressedStreamTools(net.minecraft.server.v1_8_R3.NBTCompressedStreamTools) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) HumanEntity(org.bukkit.entity.HumanEntity) DataOutput(java.io.DataOutput) TileEntityChest(net.minecraft.server.v1_8_R3.TileEntityChest) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Collectors(java.util.stream.Collectors) World(net.minecraft.server.v1_8_R3.World) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) Chunk(net.minecraft.server.v1_8_R3.Chunk) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) Entity(net.minecraft.server.v1_8_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Entity(net.minecraft.server.v1_8_R3.Entity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_8_R3.EntityItem) ArrayList(java.util.ArrayList) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) Chunk(net.minecraft.server.v1_8_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_8_R3.CraftChunk) EntityItem(net.minecraft.server.v1_8_R3.EntityItem)

Example 80 with World

use of net.minecraft.server.v1_16_R2.World in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method shiftClick.

// Overrides 1.15.1
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.b;
    Slot slot = (Slot) this.slots.get(i);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            this.containerAccess.a((world, blockposition) -> {
                itemstack1.getItem().b(itemstack1, world, entityhuman);
            });
            if (!this.a(itemstack1, 10, 46, true)) {
                return ItemStack.b;
            }
            slot.a(itemstack1, itemstack);
        } else if (i >= 10 && i < 46 ? !this.a(itemstack1, 1, 10, false) && (i < 37 ? !this.a(itemstack1, 37, 46, false) : !this.a(itemstack1, 10, 37, false)) : !this.a(itemstack1, 10, 46, false)) {
            return ItemStack.b;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.b);
        } else {
            slot.d();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.b;
        }
        ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack2, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_16_R2.Slot) ItemStack(net.minecraft.server.v1_16_R2.ItemStack)

Aggregations

Location (org.bukkit.Location)27 World (net.minecraft.server.v1_16_R3.World)16 World (net.minecraft.server.v1_12_R1.World)14 World (net.minecraft.server.v1_8_R3.World)14 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)14 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)14 ArrayList (java.util.ArrayList)12 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)11 List (java.util.List)10 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)10 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)10 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8