Search in sources :

Example 1 with IAgriDisplayable

use of com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable in project AgriCraft by AgriCraft.

the class ItemMagnifyingGlass method onItemUseFirst.

//this is called when you right click with this item in hand
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (world.isRemote) {
        List<String> list = new ArrayList<>();
        IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        TileEntity te = world.getTileEntity(pos);
        // Add a separator.
        list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");
        // Add lighting information.
        list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");
        // Add block information.
        if (block instanceof IAgriDisplayable) {
            ((IAgriDisplayable) block).addDisplayInfo(list::add);
        }
        // Add tile information.
        if (te instanceof IAgriDisplayable) {
            ((IAgriDisplayable) te).addDisplayInfo(list::add);
        }
        // Display information.
        for (String msg : list) {
            player.addChatComponentMessage(new TextComponentString(msg));
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) IAgriDisplayable(com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable) Block(net.minecraft.block.Block) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with IAgriDisplayable

use of com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable in project AgriCraft by AgriCraft.

the class ItemMagnifyingGlass method onItemUse.

// this is called when you right click with this item in hand
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        List<String> list = new ArrayList<>();
        IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        TileEntity te = world.getTileEntity(pos);
        // Add a separator.
        list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");
        // Add lighting information.
        list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");
        // Add block information.
        if (block instanceof IAgriDisplayable) {
            ((IAgriDisplayable) block).addDisplayInfo(list::add);
        }
        // Add tile information.
        if (te instanceof IAgriDisplayable) {
            ((IAgriDisplayable) te).addDisplayInfo(list::add);
        }
        // Display information.
        for (String msg : list) {
            player.sendMessage(new TextComponentString(msg));
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ArrayList(java.util.ArrayList) IAgriDisplayable(com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable) Block(net.minecraft.block.Block) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 3 with IAgriDisplayable

use of com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable in project AgriCraft by AgriCraft.

the class AgriWailaAdapter method getWailaBody.

@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> list, IWailaDataAccessor dataAccessor, IWailaConfigHandler configHandler) {
    Block b = dataAccessor.getBlock();
    if (b instanceof IAgriDisplayable) {
        ((IAgriDisplayable) b).addDisplayInfo(list::add);
    }
    TileEntity te = dataAccessor.getTileEntity();
    if (te instanceof IAgriDisplayable) {
        ((IAgriDisplayable) te).addDisplayInfo(list::add);
    }
    return list;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAgriDisplayable(com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable) Block(net.minecraft.block.Block)

Aggregations

IAgriDisplayable (com.infinityraider.agricraft.api.v1.misc.IAgriDisplayable)3 Block (net.minecraft.block.Block)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ArrayList (java.util.ArrayList)2 IBlockState (net.minecraft.block.state.IBlockState)2 TextComponentString (net.minecraft.util.text.TextComponentString)2