Search in sources :

Example 6 with SmartWrenchMode

use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.

the class PowerCellBlock method wrenchSneakSelect.

@Override
protected boolean wrenchSneakSelect(World world, BlockPos pos, EntityPlayer player) {
    if (!world.isRemote) {
        SmartWrenchMode currentMode = SmartWrenchItem.getCurrentMode(player.getHeldItem(EnumHand.MAIN_HAND));
        if (currentMode == SmartWrenchMode.MODE_SELECT) {
            TileEntity te = world.getTileEntity(pos);
            if (te instanceof PowerCellTileEntity) {
                PowerCellTileEntity powerCellTileEntity = (PowerCellTileEntity) te;
                PowerCellTileEntity.dumpNetwork(player, powerCellTileEntity);
            }
        }
    }
    return true;
}
Also used : SmartWrenchMode(mcjty.lib.api.smartwrench.SmartWrenchMode) TileEntity(net.minecraft.tileentity.TileEntity)

Example 7 with SmartWrenchMode

use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.

the class SmartWrenchItem method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        SmartWrenchMode mode = getCurrentMode(stack);
        if (mode == SmartWrenchMode.MODE_WRENCH) {
            mode = SmartWrenchMode.MODE_SELECT;
        } else {
            mode = SmartWrenchMode.MODE_WRENCH;
        }
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null) {
            tagCompound = new NBTTagCompound();
            stack.setTagCompound(tagCompound);
        }
        tagCompound.setString("mode", mode.getCode());
        Logging.message(player, TextFormatting.YELLOW + "Smart wrench is now in " + mode.getName() + " mode.");
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : SmartWrenchMode(mcjty.lib.api.smartwrench.SmartWrenchMode) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SmartWrenchMode (mcjty.lib.api.smartwrench.SmartWrenchMode)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 SmartWrenchSelector (mcjty.lib.api.smartwrench.SmartWrenchSelector)1 GenericBlock (mcjty.lib.container.GenericBlock)1 DimensionalShardBlock (mcjty.rftools.blocks.ores.DimensionalShardBlock)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1