當前位置: 首頁>>代碼示例>>Java>>正文


Java Item.getClass方法代碼示例

本文整理匯總了Java中net.minecraft.item.Item.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java Item.getClass方法的具體用法?Java Item.getClass怎麽用?Java Item.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.item.Item的用法示例。


在下文中一共展示了Item.getClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testIfLegit

import net.minecraft.item.Item; //導入方法依賴的package包/類
@Override
protected boolean testIfLegit(Item componant) {
	boolean legit = componant.getRegistryName() != null;
	if(!legit)
		new NullPointerException("Tried to config a Item with no registry name. Item: " + componant.getClass());
	return super.testIfLegit(componant);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:8,代碼來源:ItemsEnabled.java

示例2: isInMatrix

import net.minecraft.item.Item; //導入方法依賴的package包/類
private boolean isInMatrix(InventoryCrafting matrix, Item item) 
{
	if (item == null) { return false; }	// Can't find what doesn't exist
	
	int counter = 0;
	
	ItemStack stack = matrix.getStackInSlot(counter);
	
	while (counter < matrix.getSizeInventory())	// scouring through the entire thing
	{
		if (stack != null && stack.getItem().getClass() == item.getClass()) // Found one!
		{ 
			if (stack.getItem() instanceof _WeaponBase)	// Is a weapon, so need to ensure that it's empty
			{
				if (stack.getItemDamage() == stack.getMaxDamage()) { return true; }
				// else, isn't empty
			}
			else if (stack.getItem() instanceof _AmmoBase)	// is ammo
			{
				this.metadata = stack.getItemDamage();	// Keeping track of what this is gonna make, so I don't have to constantly recheck
				return true; 
			}
			// else, don't care what this is
		}
		// else, empty. That's fine
		
		// Next!
		counter += 1;
		stack = matrix.getStackInSlot(counter);
	}
	
	return false;	// Fallback. Didn't find what I'm looking for
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:34,代碼來源:Recipe_Ammo.java


注:本文中的net.minecraft.item.Item.getClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。