Tabnine Logo
DualToolHarvestUtils.shouldUseOffhand
Code IndexAdd Tabnine to your IDE (free)

How to use
shouldUseOffhand
method
in
slimeknights.tconstruct.library.tools.DualToolHarvestUtils

Best Java code snippets using slimeknights.tconstruct.library.tools.DualToolHarvestUtils.shouldUseOffhand (Showing top 8 results out of 315)

origin: SlimeKnights/TinkersConstruct

public static ItemStack getItemstackToUse(EntityLivingBase player, IBlockState blockState) {
 ItemStack mainhand = player.getHeldItemMainhand();
 if(!mainhand.isEmpty() && shouldUseOffhand(player, blockState, mainhand)) {
  return player.getHeldItemOffhand();
 }
 return mainhand;
}
origin: SlimeKnights/TinkersConstruct

public static boolean shouldUseOffhand(EntityLivingBase player, BlockPos pos, ItemStack tool) {
 return shouldUseOffhand(player, player.getEntityWorld().getBlockState(pos), tool);
}
origin: SlimeKnights/TinkersConstruct

if(DualToolHarvestUtils.shouldUseOffhand(player, pos, stack)) {
 ItemStack offhand = player.getHeldItemOffhand();
 return offhand.getItem().onBlockDestroyed(offhand, worldIn, state, pos, player);
origin: SlimeKnights/TinkersConstruct

 @Override
 public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) {
  if(ToolHelper.isBroken(stack)) {
   return -1;
  }
  if(player != null && DualToolHarvestUtils.shouldUseOffhand(player, blockState, stack)) {
   ItemStack offhand = player.getHeldItemOffhand();
   return offhand.getItem().getHarvestLevel(offhand, toolClass, player, blockState);
  }
  return super.getHarvestLevel(stack, toolClass, player, blockState);
 }
}
origin: SlimeKnights/TinkersConstruct

@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
 if(DualToolHarvestUtils.shouldUseOffhand(player, pos, itemstack)) {
  ItemStack offhand = player.getHeldItemOffhand();
  return offhand.getItem().onBlockStartBreak(offhand, pos, player);
 }
 return super.onBlockStartBreak(itemstack, pos, player);
}
origin: SlimeKnights/TinkersConstruct

@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
 if(!ToolHelper.isBroken(itemstack) && this instanceof IAoeTool && ((IAoeTool) this).isAoeHarvestTool()) {
  for(BlockPos extraPos : ((IAoeTool) this).getAOEBlocks(itemstack, player.getEntityWorld(), player, pos)) {
   breakExtraBlock(itemstack, player.getEntityWorld(), player, extraPos, pos);
  }
 }
 // this is a really dumb hack.
 // Basically when something with silktouch harvests a block from the offhand
 // the game can't detect that. so we have to switch around the items in the hands for the break call
 // it's switched back in onBlockDestroyed
 if(DualToolHarvestUtils.shouldUseOffhand(player, pos, player.getHeldItemMainhand())) {
  ItemStack off = player.getHeldItemOffhand();
  switchItemsInHands(player);
  // remember, off is in the mainhand now
  NBTTagCompound tag = TagUtil.getTagSafe(off);
  tag.setLong(TAG_SWITCHED_HAND_HAX, player.getEntityWorld().getTotalWorldTime());
  off.setTagCompound(tag);
 }
 return breakBlock(itemstack, pos, player);
}
origin: SlimeKnights/TinkersConstruct

 @SubscribeEvent
 public void offhandBreakSpeed(PlayerEvent.BreakSpeed event) {
  EntityPlayer player = event.getEntityPlayer();
  if(shouldUseOffhand(player, event.getState(), player.getHeldItemMainhand())) {
   ItemStack main = player.getHeldItemMainhand();
   ItemStack offhand = player.getHeldItemOffhand();

   // we use this instead of player.setItemStackToSlot because that one plays an equip sound ;_;
   player.inventory.mainInventory.set(player.inventory.currentItem, offhand);
   float speed = player.getDigSpeed(event.getState(), event.getPos());
   player.inventory.mainInventory.set(player.inventory.currentItem, main);

   event.setNewSpeed(speed);
  }
 }
}
origin: SlimeKnights/TinkersConstruct

&& rt != null
&& rt.typeOfHit == RayTraceResult.Type.BLOCK
&& DualToolHarvestUtils.shouldUseOffhand(player, rt.getBlockPos(), mainStack)) {
slimeknights.tconstruct.library.toolsDualToolHarvestUtilsshouldUseOffhand

Popular methods of DualToolHarvestUtils

  • getItemstackToUse

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JComboBox (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now