use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.
the class SmartWrenchItem method getCurrentMode.
public static SmartWrenchMode getCurrentMode(ItemStack itemStack) {
SmartWrenchMode mode = SmartWrenchMode.MODE_WRENCH;
NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound != null) {
String modeString = tagCompound.getString("mode");
if (modeString != null && !modeString.isEmpty()) {
mode = SmartWrenchMode.getMode(modeString);
}
}
return mode;
}
use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.
the class SmartWrenchItem method initModel.
@SideOnly(Side.CLIENT)
public void initModel() {
ModelResourceLocation selectedModel = new ModelResourceLocation(getRegistryName() + "_select", "inventory");
ModelResourceLocation normalModel = new ModelResourceLocation(getRegistryName(), "inventory");
ModelBakery.registerItemVariants(this, selectedModel, normalModel);
ModelLoader.setCustomMeshDefinition(this, stack -> {
SmartWrenchMode mode = getCurrentMode(stack);
if (mode == SmartWrenchMode.MODE_SELECT) {
return selectedModel;
} else {
return normalModel;
}
});
}
use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.
the class SmartWrenchItem method getMode.
@Override
public SmartWrenchMode getMode(ItemStack itemStack) {
SmartWrenchMode mode = SmartWrenchMode.MODE_WRENCH;
NBTTagCompound tagCompound = itemStack.getTagCompound();
if (tagCompound != null) {
String modeString = tagCompound.getString("mode");
if (modeString != null && !modeString.isEmpty()) {
mode = SmartWrenchMode.getMode(modeString);
}
}
return mode;
}
use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.
the class SmartWrenchItem method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
if (player.isSneaking()) {
// Make sure the block get activated if it is a GenericBlock
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof GenericBlock) {
if (DimensionalShardBlock.activateBlock(block, world, pos, state, player, hand, facing, hitX, hitY, hitZ)) {
return EnumActionResult.SUCCESS;
}
}
}
SmartWrenchMode mode = getCurrentMode(stack);
if (mode == SmartWrenchMode.MODE_SELECT) {
GlobalCoordinate b = getCurrentBlock(stack);
if (b != null) {
if (b.getDimension() != world.provider.getDimension()) {
Logging.message(player, TextFormatting.RED + "The selected block is in another dimension!");
return EnumActionResult.FAIL;
}
TileEntity te = world.getTileEntity(b.getCoordinate());
if (te instanceof SmartWrenchSelector) {
SmartWrenchSelector smartWrenchSelector = (SmartWrenchSelector) te;
smartWrenchSelector.selectBlock(player, pos);
}
}
}
}
return EnumActionResult.SUCCESS;
}
use of mcjty.lib.api.smartwrench.SmartWrenchMode in project RFTools by McJty.
the class SmartWrenchItem method addInformation.
// @Override
// public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) {
// return true;
// }
//
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag whatIsThis) {
super.addInformation(itemStack, player, list, whatIsThis);
GlobalCoordinate b = getCurrentBlock(itemStack);
if (b != null) {
list.add(TextFormatting.GREEN + "Block: " + BlockPosTools.toString(b.getCoordinate()) + " at dimension " + b.getDimension());
}
SmartWrenchMode mode = getCurrentMode(itemStack);
list.add(TextFormatting.WHITE + "Right-click on air to change mode.");
list.add(TextFormatting.GREEN + "Mode: " + mode.getName());
if (mode == SmartWrenchMode.MODE_WRENCH) {
list.add(TextFormatting.WHITE + "Use as a normal wrench:");
list.add(TextFormatting.WHITE + " Sneak-right-click to pick up machines.");
list.add(TextFormatting.WHITE + " Right-click to rotate machines.");
} else if (mode == SmartWrenchMode.MODE_SELECT) {
list.add(TextFormatting.WHITE + "Use as a block selector:");
list.add(TextFormatting.WHITE + " Sneak-right-click select master block.");
list.add(TextFormatting.WHITE + " Right-click to associate blocks with master.");
}
}
Aggregations