Skip to content

Commit

Permalink
Update all item tooltips to show current bound keys, rather then usin…
Browse files Browse the repository at this point in the history
…g hard coded "left click", "right click" or "sneak" Fixes #318
  • Loading branch information
AlgorithmX2 committed Nov 30, 2017
1 parent bc55806 commit f588caa
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 23 deletions.
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockSnow;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -65,7 +66,9 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpChiseledBlock, tooltip );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpChiseledBlock, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindSneak ) );

if ( stack.hasTagCompound() )
{
Expand Down
37 changes: 32 additions & 5 deletions src/main/java/mod/chiselsandbits/core/ClientSide.java
Expand Up @@ -1624,12 +1624,8 @@ public TextureAtlasSprite getMissingIcon()

public String getModeKey()
{
if ( modeMenu == null )
{
return "NULL";
}
return getKeyName( modeMenu );

return GameSettings.getKeyDisplayString( modeMenu.getKeyCode() ).replace( "LMENU", LocalStrings.leftAlt.getLocal() ).replace( "RMENU", LocalStrings.rightAlt.getLocal() );
}

public ChiselToolType getDrawnTool()
Expand All @@ -1642,4 +1638,35 @@ public boolean holdingShift()
return Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) || Keyboard.isKeyDown( Keyboard.KEY_RSHIFT );
}

public String getKeyName(
KeyBinding bind )
{
if ( bind == null )
{
return LocalStrings.noBind.getLocal();
}

if ( bind.getKeyCode() == 0 && bind.getKeyCodeDefault() != 0 )
{
return makeMoreFrendly( GameSettings.getKeyDisplayString( bind.getKeyCodeDefault() ) );
}

if ( bind.getKeyCode() == 0 )
{
return '"' + DeprecationHelper.translateToLocal( bind.getKeyDescription() );
}

return makeMoreFrendly( bind.getDisplayName() );
}

private String makeMoreFrendly(
String displayName )
{
return displayName
.replace( "LMENU", LocalStrings.leftAlt.getLocal() )
.replace( "RMENU", LocalStrings.rightAlt.getLocal() )
.replace( "LSHIFT", LocalStrings.leftShift.getLocal() )
.replace( "RSHIFT", LocalStrings.rightShift.getLocal() );
}

}
5 changes: 5 additions & 0 deletions src/main/java/mod/chiselsandbits/helpers/LocalStrings.java
Expand Up @@ -51,6 +51,11 @@ public enum LocalStrings
HelpChisel( "help.chisel" ),
LongHelpChisel( "help.chisel.long" ),

noBind( "help.nobind" ),

leftShift( "help.leftshift" ),
rightShift( "help.rightshift" ),

leftAlt( "help.leftalt" ),
rightAlt( "help.rightalt" ),

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/mod/chiselsandbits/items/ItemChisel.java
Expand Up @@ -35,6 +35,7 @@
import mod.chiselsandbits.network.packets.PacketChisel;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -100,7 +101,9 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpChisel, tooltip, ClientSide.instance.getModeKey() );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpChisel, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindAttack ),
ClientSide.instance.getModeKey() );
}

private static Stopwatch timer;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/mod/chiselsandbits/items/ItemChiseledBit.java
Expand Up @@ -36,6 +36,7 @@
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -80,7 +81,10 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpBit, tooltip, ClientSide.instance.getModeKey() );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpBit, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindAttack ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getModeKey() );
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/mod/chiselsandbits/items/ItemMirrorPrint.java
Expand Up @@ -13,6 +13,7 @@
import mod.chiselsandbits.interfaces.IPatternItem;
import mod.chiselsandbits.render.helpers.SimpleInstanceCache;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -45,7 +46,8 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpMirrorPrint, tooltip );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpMirrorPrint, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ) );

if ( isWritten( stack ) )
{
Expand Down
Expand Up @@ -25,6 +25,7 @@
import mod.chiselsandbits.network.packets.PacketRotateVoxelBlob;
import mod.chiselsandbits.render.helpers.SimpleInstanceCache;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -71,7 +72,9 @@ public void addInformation(
final ITooltipFlag advanced )
{
defaultAddInfo( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpNegativePrint, tooltip );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpNegativePrint, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ) );

if ( isWritten( stack ) )
{
Expand Down
Expand Up @@ -27,6 +27,7 @@
import mod.chiselsandbits.network.packets.PacketAccurateSneakPlace.IItemBlockAccurate;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -52,7 +53,10 @@ public void addInformation(
final ITooltipFlag advanced )
{
defaultAddInfo( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpPositivePrint, tooltip, ClientSide.instance.getModeKey() );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpPositivePrint, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getModeKey() );

if ( stack.hasTagCompound() )
{
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/mod/chiselsandbits/items/ItemTapeMeasure.java
Expand Up @@ -18,6 +18,7 @@
import mod.chiselsandbits.modes.TapeMeasureModes;
import mod.chiselsandbits.network.NetworkRouter;
import mod.chiselsandbits.network.packets.PacketSetColor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
Expand Down Expand Up @@ -52,7 +53,11 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpTapeMeasure, tooltip, ClientSide.instance.getModeKey() );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpTapeMeasure, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ),
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindSneak ),
ClientSide.instance.getModeKey() );
}

@Override
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/mod/chiselsandbits/items/ItemWrench.java
Expand Up @@ -3,9 +3,11 @@
import java.util.List;

import mod.chiselsandbits.core.ChiselsAndBits;
import mod.chiselsandbits.core.ClientSide;
import mod.chiselsandbits.helpers.LocalStrings;
import mod.chiselsandbits.integration.mcmultipart.MCMultipartProxy;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -38,7 +40,8 @@ public void addInformation(
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpWrench, tooltip );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpWrench, tooltip,
ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ) );
}

@Override
Expand Down
22 changes: 12 additions & 10 deletions src/main/resources/assets/chiselsandbits/lang/en_us.lang
Expand Up @@ -83,18 +83,17 @@ mod.chiselsandbits.help.shiftdetails=<Hold Shift For Details>
mod.chiselsandbits.help.empty=Empty
mod.chiselsandbits.help.filled=Filled

mod.chiselsandbits.help.chiseled_block=Left-click to place;Sneak to ignore block grid;Mouse Wheel to cycle placement rotation.
mod.chiselsandbits.help.chiseled_block={} to place;{} to ignore block grid;Mouse Wheel to cycle placement rotation.
mod.chiselsandbits.help.bit_bag=Automatically re-stock, and store bits.
mod.chiselsandbits.help.wrench=Right-click blocks to rotate.
mod.chiselsandbits.help.bit=Left-click to chisel;Right-click to place;Use {} to display menu.
mod.chiselsandbits.help.positiveprint=Right-click to write;Right-click to chisel/place or Craft with bits/bags.;Mouse Wheel to cycle rotation;Use {} to display menu.
mod.chiselsandbits.help.negativeprint=Right-click to write;Right-click to chisel.;Mouse Wheel to cycle rotation.
mod.chiselsandbits.help.mirrorprint=Right-click the face you wish to mirror from;Craft with positive/negative design to transfer.
mod.chiselsandbits.help.chisel=Left-click to chisel;Use {} to display menu.
mod.chiselsandbits.help.wrench={} blocks to rotate.
mod.chiselsandbits.help.bit={} to chisel;{} to place;Use {} to display menu.
mod.chiselsandbits.help.positiveprint={} to write;{} to chisel/place or Craft with bits/bags.;Mouse Wheel to cycle rotation;Use {} to display menu.
mod.chiselsandbits.help.negativeprint={} to write;{} to chisel.;Mouse Wheel to cycle rotation.
mod.chiselsandbits.help.mirrorprint={} the face you wish to mirror from;Craft with positive/negative design to transfer.
mod.chiselsandbits.help.chisel={} to chisel;Use {} to display menu.
mod.chiselsandbits.help.bitsaw=Craft with Blocks or Chiseled blocks;Cut along any of the 3 axis.
mod.chiselsandbits.help.bittank=Fill with fluid and ex
tract bits.
mod.chiselsandbits.help.tape_measure=Right-click and drag to measure;Sneak + right click to clear;Use {} to display menu.
mod.chiselsandbits.help.bittank=Fill with fluid and extract bits.
mod.chiselsandbits.help.tape_measure={} and drag to measure;{} + {} to clear;Use {} to display menu.

mod.chiselsandbits.help.chiseled_block.long=Left-click to place the block. Sneak while placing to ignore block grid. Shift + Mouse Wheel to cycle placement rotation.
mod.chiselsandbits.help.bit_bag.long=Automatically re-stocks, and store bits when you exceed or go under a stack in your inventory.
Expand All @@ -108,6 +107,9 @@ mod.chiselsandbits.help.chisel.long=Left-click any compatible block to chisel. R
mod.chiselsandbits.help.bitsaw.long=Craft this saw with supported blocks, or symmetrical chiseled blocks to cut them in half. The axis of cutting is determined by the position of the saw related the block, cut along the X axis with the saw to the side, along the Y axis if the saw is above or below, and Z is if the saw is diagonal.
mod.chiselsandbits.help.bittank.long=Right-click with a bucket to insert/remove fluid. Right-click without a bucket to extract bits from a filled tank, shift+right click inserts bits in your hand, inserting with an empty hand will attempt to insert as many bits as possible. You can use automation such as hoppers to extract bits from a tank with fluid in it.

mod.chiselsandbits.help.nobind=No Key Bind
mod.chiselsandbits.help.leftshift=Left Shift
mod.chiselsandbits.help.rightshift=Right Shift
mod.chiselsandbits.help.leftalt=Left Alt
mod.chiselsandbits.help.rightalt=Right Alt
mod.chiselsandbits.help.trash=Delete Bag Contents, Hold Item to filter.
Expand Down

0 comments on commit f588caa

Please sign in to comment.