Search in sources :

Example 6 with TileEntityEverstone

use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.

the class BlockEverstone method removedByPlayer.

@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
    TileEntityEverstone everstone = getTE(world, x, y, z);
    if (everstone == null) {
        if (player.capabilities.isCreativeMode) {
            world.setTileEntity(x, y, z, null);
            world.setBlockToAir(x, y, z);
            return true;
        }
        return false;
    }
    everstone.onBreak();
    if (player.capabilities.isCreativeMode) {
        world.setTileEntity(x, y, z, null);
        world.setBlockToAir(x, y, z);
        return true;
    }
    return false;
}
Also used : TileEntityEverstone(am2.blocks.tileentities.TileEntityEverstone)

Example 7 with TileEntityEverstone

use of am2.blocks.tileentities.TileEntityEverstone in project ArsMagica2 by Mithion.

the class BlockEverstone method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    if (player.getHeldItem() != null) {
        Block block = null;
        int meta = -1;
        TileEntityEverstone everstone = getTE(world, x, y, z);
        if (everstone == null)
            return false;
        if (player.getHeldItem().getItem() == ItemsCommonProxy.crystalWrench) {
            if (!world.isRemote) {
                if (everstone.getFacade() != null) {
                    everstone.setFacade(null, -1);
                    return true;
                } else {
                    world.setBlockToAir(x, y, z);
                    this.dropBlockAsItem(world, x, y, z, new ItemStack(BlocksCommonProxy.everstone));
                    return true;
                }
            }
        } else if (player.getHeldItem().getItem() instanceof ItemBlock) {
            ItemBlock itemblock = (ItemBlock) player.getHeldItem().getItem();
            block = itemblock.field_150939_a;
            if (block.isOpaqueCube()) {
                meta = itemblock.getMetadata(player.getHeldItem().getItemDamage());
            }
        }
        if (everstone.getFacade() == null && block != null) {
            everstone.setFacade(block, meta);
            world.notifyBlockChange(x, y, z, this);
            return true;
        }
    }
    return false;
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) TileEntityEverstone(am2.blocks.tileentities.TileEntityEverstone) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

TileEntityEverstone (am2.blocks.tileentities.TileEntityEverstone)6 Block (net.minecraft.block.Block)6 ItemBlock (net.minecraft.item.ItemBlock)4 AMParticle (am2.particles.AMParticle)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 EntityDiggingFX (net.minecraft.client.particle.EntityDiggingFX)2 ItemStack (net.minecraft.item.ItemStack)1 ChunkPosition (net.minecraft.world.ChunkPosition)1 IBlockAccess (net.minecraft.world.IBlockAccess)1