Search in sources :

Example 6 with TileEntity

use of org.spongepowered.api.block.tileentity.TileEntity in project ClearMob by axle2005.

the class ClearTileEntity method run.

public static void run(ClearMob plugin, List<TileEntityType> list, Collection<World> worlds, CommandSource src) {
    int removedentities = 0;
    Collection<TileEntity> e = new ArrayList<TileEntity>();
    for (World world : worlds) {
        for (TileEntity entity : world.getTileEntities()) {
            e.add(entity);
        }
    }
    if (!e.isEmpty()) {
        for (TileEntity entity : e) {
            for (int i = 0; i <= list.size() - 1; i++) {
                if ((entity.getType().equals(list.get(i)))) {
                    entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
                    removedentities++;
                }
            }
        }
    }
    feedback(plugin, src, removedentities);
}
Also used : TileEntity(org.spongepowered.api.block.tileentity.TileEntity) ArrayList(java.util.ArrayList) World(org.spongepowered.api.world.World)

Example 7 with TileEntity

use of org.spongepowered.api.block.tileentity.TileEntity in project Skree by Skelril.

the class GoldRushInstance method findChestAndKeys.

private void findChestAndKeys() {
    keyRoom.forAll((pt) -> {
        BlockState block = getRegion().getExtent().getBlock(pt);
        if (block.getType() == BlockTypes.CHEST) {
            // TODO Sponge port
            Optional<TileEntity> optTileEnt = getRegion().getExtent().getTileEntity(pt);
            if (optTileEnt.isPresent() && optTileEnt.get() instanceof IInventory) {
                ((IInventory) optTileEnt.get()).clear();
            }
            chestBlocks.add(new Location<>(getRegion().getExtent(), pt));
        } else if (block.getType() == BlockTypes.WALL_SIGN) {
            Optional<org.spongepowered.api.block.tileentity.TileEntity> optTileEnt = getRegion().getExtent().getTileEntity(pt);
            if (!optTileEnt.isPresent()) {
                return;
            }
            locks.add(new Location<>(getRegion().getExtent(), pt));
        }
    });
}
Also used : TileEntity(org.spongepowered.api.block.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) BlockState(org.spongepowered.api.block.BlockState) Location(org.spongepowered.api.world.Location)

Example 8 with TileEntity

use of org.spongepowered.api.block.tileentity.TileEntity in project ClearMob by axle2005.

the class ClearTileEntity method run.

public static void run(ClearMob plugin, TileEntityType tile, Collection<World> worlds, CommandSource src) {
    int removedentities = 0;
    Collection<TileEntity> e = new ArrayList<TileEntity>();
    for (World world : worlds) {
        for (TileEntity entity : world.getTileEntities()) {
            e.add(entity);
        }
    }
    if (!e.isEmpty()) {
        for (TileEntity entity : e) {
            if ((entity.getType().equals(tile))) {
                entity.getLocation().removeBlock(Cause.source(Sponge.getPluginManager().fromInstance(plugin).get()).build());
                removedentities++;
            }
        }
    }
    feedback(plugin, src, removedentities);
}
Also used : TileEntity(org.spongepowered.api.block.tileentity.TileEntity) ArrayList(java.util.ArrayList) World(org.spongepowered.api.world.World)

Aggregations

TileEntity (org.spongepowered.api.block.tileentity.TileEntity)8 World (org.spongepowered.api.world.World)6 ArrayList (java.util.ArrayList)4 IInventory (net.minecraft.inventory.IInventory)2 BlockState (org.spongepowered.api.block.BlockState)2 Listener (org.spongepowered.api.event.Listener)2 Text (org.spongepowered.api.text.Text)2 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 ItemStack (net.minecraft.item.ItemStack)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 Sign (org.spongepowered.api.block.tileentity.Sign)1 SignData (org.spongepowered.api.data.manipulator.mutable.tileentity.SignData)1 Entity (org.spongepowered.api.entity.Entity)1 Player (org.spongepowered.api.entity.living.player.Player)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 Location (org.spongepowered.api.world.Location)1