net.minecraft.item.SwordItem Java Examples

The following examples show how to use net.minecraft.item.SwordItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoToolHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private int getBestSlot(BlockPos pos, boolean useSwords, boolean repairMode)
{
	ClientPlayerEntity player = MC.player;
	PlayerInventory inventory = player.inventory;
	ItemStack heldItem = MC.player.getMainHandStack();
	
	BlockState state = BlockUtils.getState(pos);
	float bestSpeed = getMiningSpeed(heldItem, state);
	int bestSlot = -1;
	
	for(int slot = 0; slot < 9; slot++)
	{
		if(slot == inventory.selectedSlot)
			continue;
		
		ItemStack stack = inventory.getStack(slot);
		
		float speed = getMiningSpeed(stack, state);
		if(speed <= bestSpeed)
			continue;
		
		if(!useSwords && stack.getItem() instanceof SwordItem)
			continue;
		
		if(repairMode && isTooDamaged(stack))
			continue;
		
		bestSpeed = speed;
		bestSlot = slot;
	}
	
	return bestSlot;
}