本文整理汇总了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
}