本文整理匯總了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);
}
示例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
}