Search in sources :

Example 36 with BlockPosition

use of net.minecraft.server.v1_16_R1.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method removeTileEntity.

@Override
public void removeTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity currentTileEntity = world.getTileEntity(blockPosition);
    if (currentTileEntity instanceof TileEntityWildChest)
        world.s(blockPosition);
}
Also used : TileEntity(net.minecraft.server.v1_12_R1.TileEntity) 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 37 with BlockPosition

use of net.minecraft.server.v1_16_R1.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method updateTileEntity.

@Override
public void updateTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity tileEntity = world.getTileEntity(blockPosition);
    TileEntityWildChest tileEntityWildChest;
    if (tileEntity instanceof TileEntityWildChest) {
        tileEntityWildChest = (TileEntityWildChest) tileEntity;
        ((WChest) chest).setTileEntityContainer(tileEntityWildChest);
    } else {
        tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
    }
    world.setTileEntity(blockPosition, tileEntityWildChest);
}
Also used : TileEntity(net.minecraft.server.v1_12_R1.TileEntity) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) World(net.minecraft.server.v1_12_R1.World) WChest(com.bgsoftware.wildchests.objects.chests.WChest) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Location(org.bukkit.Location)

Example 38 with BlockPosition

use of net.minecraft.server.v1_16_R1.BlockPosition in project THP-Engine by TheHollowPlanetMC.

the class MultiBlockChangePacketHandler 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 {
        ChunkCoordIntPair aValue = (ChunkCoordIntPair) a.get(packet);
        PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] bValue = (PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[]) b.get(packet);
        int chunkX = aValue.x;
        int chunkZ = aValue.z;
        ParallelChunk parallelChunk = parallelWorld.getChunk(chunkX, chunkZ);
        if (parallelChunk == null)
            return packet;
        PacketPlayOutMultiBlockChange newPacket = new PacketPlayOutMultiBlockChange();
        a.set(newPacket, aValue);
        int length = bValue.length;
        PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] newInfo = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[length];
        for (int index = 0; index < length; index++) {
            PacketPlayOutMultiBlockChange.MultiBlockChangeInfo info = bValue[index];
            BlockPosition bp = info.a();
            BlockData blockData = parallelChunk.getBlockData(bp.getX(), bp.getY(), bp.getZ());
            if (blockData == null) {
                newInfo[index] = info;
            } else {
                newInfo[index] = newPacket.new MultiBlockChangeInfo(info.b(), ((CraftBlockData) blockData).getState());
            }
        }
        b.set(newPacket, newInfo);
        return newPacket;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return packet;
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) ChunkCoordIntPair(net.minecraft.server.v1_15_R1.ChunkCoordIntPair) PacketPlayOutMultiBlockChange(net.minecraft.server.v1_15_R1.PacketPlayOutMultiBlockChange) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) BlockData(org.bukkit.block.data.BlockData) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)

Example 39 with BlockPosition

use of net.minecraft.server.v1_16_R1.BlockPosition 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_16_R3.BlockPosition) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) PacketPlayOutBlockChange(net.minecraft.server.v1_16_R3.PacketPlayOutBlockChange) BlockData(org.bukkit.block.data.BlockData) CraftBlockData(org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData)

Example 40 with BlockPosition

use of net.minecraft.server.v1_16_R1.BlockPosition 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_R1.Slot) ItemStack(net.minecraft.server.v1_16_R1.ItemStack)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)57 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)36 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)34 Location (org.bukkit.Location)32 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)30 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)27 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)26 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)24 Chunk (org.bukkit.Chunk)24 ArrayList (java.util.ArrayList)23 List (java.util.List)19 Map (java.util.Map)17 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)17 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)16 Iterator (java.util.Iterator)14 HashMap (java.util.HashMap)12 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)10 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)9 Block (org.bukkit.block.Block)9