Skip to content

Commit

Permalink
Add Icons
Browse files Browse the repository at this point in the history
Also, Add a button to mode menu to pick pit, might help with #321
  • Loading branch information
AlgorithmX2 committed Dec 4, 2017
1 parent 64fa3fa commit b27e582
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 44 deletions.
Expand Up @@ -4,6 +4,7 @@ public enum ButtonAction
{
UNDO,
REDO,
PICK_BIT,

REPLACE_TOGGLE,

Expand Down
Expand Up @@ -190,6 +190,11 @@ public void drawScreen(
final ArrayList<MenuRegion> modes = new ArrayList<MenuRegion>();
final ArrayList<MenuButton> btns = new ArrayList<MenuButton>();

if ( tool == ChiselToolType.BIT || tool == ChiselToolType.CHISEL )
{
btns.add( new MenuButton( LocalStrings.BitPickBit.toString(), ButtonAction.PICK_BIT, text_distnace, 28, ClientSide.pickIcon, EnumFacing.EAST ) );
}

if ( tool == ChiselToolType.BIT )
{
if ( ChiselsAndBits.getConfig().replaceingBits )
Expand Down
90 changes: 46 additions & 44 deletions src/main/java/mod/chiselsandbits/core/ClientSide.java
Expand Up @@ -98,6 +98,7 @@
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -417,6 +418,7 @@ public Map<IBlockState, ModelResourceLocation> putStateModelLocations(
public static TextureAtlasSprite redoIcon;
public static TextureAtlasSprite trashIcon;

public static TextureAtlasSprite pickIcon;
public static TextureAtlasSprite swapIcon;
public static TextureAtlasSprite placeIcon;

Expand All @@ -425,6 +427,7 @@ void registerIconTextures(
final TextureStitchEvent.Pre ev )
{
final TextureMap map = ev.getMap();
pickIcon = map.registerSprite( new ResourceLocation( "chiselsandbits", "icons/pick_bit" ) );
swapIcon = map.registerSprite( new ResourceLocation( "chiselsandbits", "icons/swap" ) );
placeIcon = map.registerSprite( new ResourceLocation( "chiselsandbits", "icons/place" ) );
undoIcon = map.registerSprite( new ResourceLocation( "chiselsandbits", "icons/undo" ) );
Expand Down Expand Up @@ -545,6 +548,10 @@ public void onRenderGUI(
ClientSide.instance.playRadialMenu();
switch ( ChiselsAndBitsMenu.instance.doAction )
{
case PICK_BIT:
doPickPit();
break;

case REPLACE_TOGGLE:
ChiselsAndBits.getConfig().replaceingBits = !ChiselsAndBits.getConfig().replaceingBits;
ReflectionWrapper.instance.clearHighlightedStack();
Expand Down Expand Up @@ -657,28 +664,7 @@ public void onRenderGUI(

if ( pickBit.isPressed() )
{
final Minecraft mc = Minecraft.getMinecraft();
if ( mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK )
{
try
{
final BitLocation bl = new BitLocation( mc.objectMouseOver, true, BitOperation.CHISEL );
final IBitAccess access = ChiselsAndBits.getApi().getBitAccess( mc.theWorld, bl.getBlockPos() );
final IBitBrush brush = access.getBitAt( bl.getBitX(), bl.getBitY(), bl.getBitZ() );
if ( brush != null )
{
final ItemStack is = brush.getItemStack( 1 );
if ( is != null )
{
doPick( is );
}
}
}
catch ( final CannotBeChiseled e )
{
// nope.
}
}
doPickPit();
}

if ( type == ElementType.HOTBAR && ChiselsAndBits.getConfig().enableToolbarIcons )
Expand Down Expand Up @@ -719,6 +705,32 @@ public void onRenderGUI(
}
}

public void doPickPit()
{
final Minecraft mc = Minecraft.getMinecraft();
if ( mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK )
{
try
{
final BitLocation bl = new BitLocation( mc.objectMouseOver, true, BitOperation.CHISEL );
final IBitAccess access = ChiselsAndBits.getApi().getBitAccess( mc.theWorld, bl.getBlockPos() );
final IBitBrush brush = access.getBitAt( bl.getBitX(), bl.getBitY(), bl.getBitZ() );
if ( brush != null )
{
final ItemStack is = brush.getItemStack( 1 );
if ( is != null )
{
doPick( is );
}
}
}
catch ( final CannotBeChiseled e )
{
// nope.
}
}
}

public void playRadialMenu()
{
final float volume = ChiselsAndBits.getConfig().radialMenuVolume;
Expand All @@ -734,35 +746,25 @@ private boolean doPick(
{
final EntityPlayer player = getPlayer();

for ( int x = 0; x < 9; x++ )
if ( player.capabilities.isCreativeMode )
{
final ItemStack stack = player.inventory.getStackInSlot( x );
if ( stack != null && stack.isItemEqual( result ) && ItemStack.areItemStackTagsEqual( stack, result ) )
{
player.inventory.currentItem = x;
return true;
}
player.inventory.setPickedItemStack( result );
Minecraft.getMinecraft().playerController.sendSlotPacket( player.getHeldItem( EnumHand.MAIN_HAND ), 36 + player.inventory.currentItem );
return true;
}

if ( !player.capabilities.isCreativeMode )
int slot = player.inventory.getSlotFor( result );
if ( slot != -1 )
{
return false;
}
if ( InventoryPlayer.isHotbar( slot ) )
player.inventory.currentItem = slot;
else
Minecraft.getMinecraft().playerController.pickItem( slot );

int slot = player.inventory.getFirstEmptyStack();
if ( slot < 0 || slot >= 9 )
{
slot = player.inventory.currentItem;
return true;
}

// update inventory..
player.inventory.setInventorySlotContents( slot, result );
player.inventory.currentItem = slot;

// update server...
final int j = player.inventoryContainer.inventorySlots.size() - 9 + player.inventory.currentItem;
Minecraft.getMinecraft().playerController.sendSlotPacket( player.inventory.getStackInSlot( player.inventory.currentItem ), j );
return true;
return false;
}

public ChiselToolType getHeldToolType(
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mod/chiselsandbits/helpers/LocalStrings.java
Expand Up @@ -93,6 +93,7 @@ public enum LocalStrings
BlueprintCannotMove( "blueprint.cannotmove" ),
BlueprintFinished( "blueprint.finished" ),

BitPickBit( "bitoption.pick" ),
BitOptionPlace( "bitoption.place" ),
BitOptionReplace( "bitoption.replace" ),

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/chiselsandbits/lang/en_us.lang
Expand Up @@ -56,6 +56,7 @@ mod.chiselsandbits.chiselmode.same_material=Same Material

mod.chiselsandbits.bitoption.place=Place
mod.chiselsandbits.bitoption.replace=Replace
mod.chiselsandbits.bitoption.pick=Pick Bit

mod.chiselsandbits.positivepatternmode.replace=Replace
mod.chiselsandbits.positivepatternmode.additive=Additive
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b27e582

Please sign in to comment.