@SideOnly(Side.CLIENT) @Override public void addInformation( ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) { super.addInformation(itemStack, player, list, whatIsThis); GlobalCoordinate b = getCurrentBlock(itemStack); if (b != null) { list.add( EnumChatFormatting.GREEN + "Block: " + b.getCoordinate().toString() + " at dimension " + b.getDimension()); } SmartWrenchMode mode = getCurrentMode(itemStack); list.add(EnumChatFormatting.WHITE + "Right-click on air to change mode."); list.add(EnumChatFormatting.GREEN + "Mode: " + mode.getName()); if (mode == SmartWrenchMode.MODE_WRENCH) { list.add(EnumChatFormatting.WHITE + "Use as a normal wrench:"); list.add(EnumChatFormatting.WHITE + " Sneak-right-click to pick up machines."); list.add(EnumChatFormatting.WHITE + " Right-click to rotate machines."); } else if (mode == SmartWrenchMode.MODE_SELECT) { list.add(EnumChatFormatting.WHITE + "Use as a block selector:"); list.add(EnumChatFormatting.WHITE + " Sneak-right-click select master block."); list.add(EnumChatFormatting.WHITE + " Right-click to associate blocks with master."); } }
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; }
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { 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, EnumChatFormatting.YELLOW + "Smart wrench is now in " + mode.getName() + " mode."); } return super.onItemRightClick(stack, world, player); }