Search in sources :

Example 1 with Infusable

use of mcjty.lib.api.Infusable in project RFTools by McJty.

the class MachineInfuserTileEntity method getTagCompound.

public static NBTTagCompound getTagCompound(ItemStack stack) {
    if (stack.isEmpty()) {
        return null;
    }
    if (stack.getCount() != 1) {
        return null;
    }
    Item item = stack.getItem();
    if (!(item instanceof ItemBlock)) {
        return null;
    }
    Block block = ((ItemBlock) item).getBlock();
    if (!(block instanceof Infusable)) {
        return null;
    }
    NBTTagCompound tagCompound = stack.getTagCompound();
    if (tagCompound == null) {
        return new NBTTagCompound();
    } else {
        return tagCompound;
    }
}
Also used : Infusable(mcjty.lib.api.Infusable) Item(net.minecraft.item.Item) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock)

Example 2 with Infusable

use of mcjty.lib.api.Infusable in project RFTools by McJty.

the class ShardWandItem method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        Block block = world.getBlockState(pos).getBlock();
        if (block instanceof Infusable) {
            TileEntity te = world.getTileEntity(pos);
            if (te instanceof GenericTileEntity) {
                GenericTileEntity genericTileEntity = (GenericTileEntity) te;
                int infused = genericTileEntity.getInfused();
                if (infused < GeneralConfig.maxInfuse) {
                    infused = GeneralConfig.maxInfuse;
                    Logging.message(player, "Maximized infusion level!");
                } else {
                    infused = 0;
                    Logging.message(player, "Cleared infusion level!");
                }
                genericTileEntity.setInfused(infused);
            } else {
                Logging.message(player, "This block doesn't have the right tile entity!");
            }
        } else {
            Logging.message(player, "This block is not infusable!");
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.SUCCESS;
}
Also used : Infusable(mcjty.lib.api.Infusable) TileEntity(net.minecraft.tileentity.TileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) Block(net.minecraft.block.Block)

Aggregations

Infusable (mcjty.lib.api.Infusable)2 Block (net.minecraft.block.Block)2 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1