本文整理匯總了Java中net.minecraft.enchantment.Enchantment.getEnchantmentID方法的典型用法代碼示例。如果您正苦於以下問題:Java Enchantment.getEnchantmentID方法的具體用法?Java Enchantment.getEnchantmentID怎麽用?Java Enchantment.getEnchantmentID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.enchantment.Enchantment
的用法示例。
在下文中一共展示了Enchantment.getEnchantmentID方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getShortName
import net.minecraft.enchantment.Enchantment; //導入方法依賴的package包/類
public String getShortName() {
int id = Enchantment.getEnchantmentID(enchantment);
if(SHORT_ENCHANT_NAMES.containsKey(id)) {
if(enchantment.getMaxLevel() <= 1)
return SHORT_ENCHANT_NAMES.get(id);
else
return SHORT_ENCHANT_NAMES.get(id) + this.level;
}
else return toString();
}
示例2: onCraftMatrixChanged
import net.minecraft.enchantment.Enchantment; //導入方法依賴的package包/類
@Override
public void onCraftMatrixChanged(IInventory inventoryIn) {
if (inventoryIn == this.tableInventory) {
net.minecraft.item.ItemStack itemstack = inventoryIn.getStackInSlot(0);
if (itemstack != null && itemstack.isItemEnchantable()) {
if (!this.worldPointer.isRemote) {
int l = 0;
this.rand.setSeed((long) this.xpSeed);
for (int i1 = 0; i1 < 3; ++i1) {
this.enchantLevels[i1] = EnchantmentHelper.calcItemStackEnchantability(this.rand, i1, (int) this.power, itemstack);
this.enchantClue[i1] = -1;
this.worldClue[i1] = -1;
if (this.enchantLevels[i1] < i1 + 1) {
this.enchantLevels[i1] = 0;
}
}
for (int j1 = 0; j1 < 3; ++j1) {
if (this.enchantLevels[j1] > 0) {
List<EnchantmentData> list = this.getEnchantmentList(itemstack, j1, this.enchantLevels[j1]);
if (list != null && !list.isEmpty()) {
EnchantmentData enchantmentdata = (EnchantmentData) list.get(this.rand.nextInt(list.size()));
this.enchantClue[j1] = Enchantment.getEnchantmentID(enchantmentdata.enchantmentobj);
this.worldClue[j1] = enchantmentdata.enchantmentLevel;
}
}
}
this.detectAndSendChanges();
}
} else {
for (int i = 0; i < 3; ++i) {
this.enchantLevels[i] = 0;
this.enchantClue[i] = -1;
this.worldClue[i] = -1;
}
}
}
}
示例3: parse
import net.minecraft.enchantment.Enchantment; //導入方法依賴的package包/類
public int parse(String p_parse_1_, int p_parse_2_)
{
Enchantment enchantment = Enchantment.getEnchantmentByLocation(p_parse_1_);
return enchantment == null ? p_parse_2_ : Enchantment.getEnchantmentID(enchantment);
}
示例4: onCraftMatrixChanged
import net.minecraft.enchantment.Enchantment; //導入方法依賴的package包/類
/**
* Callback for when the crafting matrix is changed.
*/
public void onCraftMatrixChanged(IInventory inventoryIn)
{
if (inventoryIn == this.tableInventory)
{
ItemStack itemstack = inventoryIn.getStackInSlot(0);
if (itemstack != null && itemstack.isItemEnchantable())
{
if (!this.worldPointer.isRemote)
{
int l = 0;
float power = 0;
for (int j = -1; j <= 1; ++j)
{
for (int k = -1; k <= 1; ++k)
{
if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.position.add(k, 0, j)) && this.worldPointer.isAirBlock(this.position.add(k, 1, j)))
{
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 0, j * 2));
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 1, j * 2));
if (k != 0 && j != 0)
{
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 0, j));
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k * 2, 1, j));
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k, 0, j * 2));
power += net.minecraftforge.common.ForgeHooks.getEnchantPower(worldPointer, position.add(k, 1, j * 2));
}
}
}
}
this.rand.setSeed((long)this.xpSeed);
for (int i1 = 0; i1 < 3; ++i1)
{
this.enchantLevels[i1] = EnchantmentHelper.calcItemStackEnchantability(this.rand, i1, (int)power, itemstack);
this.enchantClue[i1] = -1;
this.worldClue[i1] = -1;
if (this.enchantLevels[i1] < i1 + 1)
{
this.enchantLevels[i1] = 0;
}
}
for (int j1 = 0; j1 < 3; ++j1)
{
if (this.enchantLevels[j1] > 0)
{
List<EnchantmentData> list = this.getEnchantmentList(itemstack, j1, this.enchantLevels[j1]);
if (list != null && !list.isEmpty())
{
EnchantmentData enchantmentdata = (EnchantmentData)list.get(this.rand.nextInt(list.size()));
this.enchantClue[j1] = Enchantment.getEnchantmentID(enchantmentdata.enchantmentobj);
this.worldClue[j1] = enchantmentdata.enchantmentLevel;
}
}
}
this.detectAndSendChanges();
}
}
else
{
for (int i = 0; i < 3; ++i)
{
this.enchantLevels[i] = 0;
this.enchantClue[i] = -1;
this.worldClue[i] = -1;
}
}
}
}