Search in sources :

Example 11 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class ItemArcaneAshes method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    BlockPos newPos = blockPos.offset(side);
    if (world.isAirBlock(newPos)) {
        if (!world.isRemote) {
            EnumFacing rotation = EnumFacing.fromAngle(player.getRotationYawHead());
            world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState());
            TileEntity tile = world.getTileEntity(newPos);
            if (tile instanceof TileAlchemyArray) {
                ((TileAlchemyArray) tile).setRotation(rotation);
            }
            stack.damageItem(1, player);
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.FAIL;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray)

Aggregations

TileAlchemyArray (WayofTime.bloodmagic.tile.TileAlchemyArray)11 EnumFacing (net.minecraft.util.EnumFacing)7 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)6 Tessellator (net.minecraft.client.renderer.Tessellator)6 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)3 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AlchemyArrayEffect (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect)1 AlchemyArrayEffectArrowTurret (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectArrowTurret)1 TeleposeEvent (WayofTime.bloodmagic.event.TeleposeEvent)1 Block (net.minecraft.block.Block)1