Search in sources :

Example 6 with BukkitImplAdapter

use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.

the class PaperweightGetBlocks_Copy method storeEntity.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void storeEntity(Entity entity) {
    BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
    net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag();
    entities.add((CompoundTag) adapter.toNative(entity.save(compoundTag)));
}
Also used : BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) PaperweightLazyCompoundTag(com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1.nbt.PaperweightLazyCompoundTag) CompoundTag(com.sk89q.jnbt.CompoundTag)

Example 7 with BukkitImplAdapter

use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.

the class BukkitWorld method clearContainerBlockContents.

@Override
public boolean clearContainerBlockContents(BlockVector3 pt) {
    checkNotNull(pt);
    BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
    if (adapter != null) {
        try {
            return adapter.clearContainerBlockContents(getWorld(), pt);
        } catch (Exception ignored) {
        }
    }
    if (!getBlock(pt).getBlockType().getMaterial().hasContainer()) {
        return false;
    }
    Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
    BlockState state = PaperLib.getBlockState(block, false).getState();
    if (!(state instanceof InventoryHolder)) {
        return false;
    }
    InventoryHolder chest = (InventoryHolder) state;
    Inventory inven = chest.getInventory();
    if (chest instanceof Chest) {
        inven = ((Chest) chest).getBlockInventory();
    }
    inven.clear();
    return true;
}
Also used : Chest(org.bukkit.block.Chest) BlockState(org.bukkit.block.BlockState) Block(org.bukkit.block.Block) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) InventoryHolder(org.bukkit.inventory.InventoryHolder) UnsupportedVersionEditException(com.sk89q.worldedit.bukkit.adapter.UnsupportedVersionEditException) WorldUnloadedException(com.fastasyncworldedit.bukkit.util.WorldUnloadedException) FaweException(com.fastasyncworldedit.core.internal.exception.FaweException) WorldEditException(com.sk89q.worldedit.WorldEditException) Inventory(org.bukkit.inventory.Inventory)

Example 8 with BukkitImplAdapter

use of com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter in project FastAsyncWorldEdit by IntellectualSites.

the class BukkitPlayer method sendFakeBlock.

@Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
    Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
    if (block == null) {
        player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
    } else {
        player.sendBlockChange(loc, BukkitAdapter.adapt(block));
        BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
        if (adapter != null) {
            if (block.getBlockType() == BlockTypes.STRUCTURE_BLOCK && block instanceof BaseBlock) {
                CompoundBinaryTag nbt = ((BaseBlock) block).getNbt();
                if (nbt != null) {
                    adapter.sendFakeNBT(player, pos, nbt);
                    adapter.sendFakeOP(player);
                }
            }
        }
    }
}
Also used : BukkitImplAdapter(com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) CompoundBinaryTag(com.sk89q.worldedit.util.nbt.CompoundBinaryTag) Location(org.bukkit.Location)

Aggregations

BukkitImplAdapter (com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter)8 CompoundTag (com.sk89q.jnbt.CompoundTag)3 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)2 WorldUnloadedException (com.fastasyncworldedit.bukkit.util.WorldUnloadedException)1 FaweException (com.fastasyncworldedit.core.internal.exception.FaweException)1 WorldEdit (com.sk89q.worldedit.WorldEdit)1 WorldEditException (com.sk89q.worldedit.WorldEditException)1 AdapterLoadException (com.sk89q.worldedit.bukkit.adapter.AdapterLoadException)1 BukkitImplLoader (com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader)1 UnsupportedVersionEditException (com.sk89q.worldedit.bukkit.adapter.UnsupportedVersionEditException)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1.nbt.PaperweightLazyCompoundTag)1 PaperweightLazyCompoundTag (com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag)1 Platform (com.sk89q.worldedit.extension.platform.Platform)1 CompoundBinaryTag (com.sk89q.worldedit.util.nbt.CompoundBinaryTag)1 BiomeType (com.sk89q.worldedit.world.biome.BiomeType)1 BlockMaterial (com.sk89q.worldedit.world.registry.BlockMaterial)1 PassthroughBlockMaterial (com.sk89q.worldedit.world.registry.PassthroughBlockMaterial)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1