当前位置: 首页>>代码示例>>Java>>正文


Java ForgeHooks.getEnchantPower方法代码示例

本文整理汇总了Java中net.minecraftforge.common.ForgeHooks.getEnchantPower方法的典型用法代码示例。如果您正苦于以下问题:Java ForgeHooks.getEnchantPower方法的具体用法?Java ForgeHooks.getEnchantPower怎么用?Java ForgeHooks.getEnchantPower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.common.ForgeHooks的用法示例。


在下文中一共展示了ForgeHooks.getEnchantPower方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPower

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
void setPower(Observation observation) {
    int power = 0;
    for (int j = -1; j <= 1; ++j)
    {
        for (int k = -1; k <= 1; ++k)
        {
            if ((j != 0 || k != 0) && world.isAirBlock(position.add(k, 0, j)) && world.isAirBlock(position.add(k, 1, j)))
            {
                power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 0, j * 2));
                power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 1, j * 2));
                if (k != 0 && j != 0)
                {
                    power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 0, j));
                    power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 1, j));
                    power += ForgeHooks.getEnchantPower(world, position.add(k, 0, j * 2));
                    power += ForgeHooks.getEnchantPower(world, position.add(k, 1, j * 2));
                }
            }
        }
    }
    observation.power = power;
}
 
开发者ID:d0sboots,项目名称:EnchantmentRevealer,代码行数:23,代码来源:ContainerEnchantmentWrapper.java

示例2: getEnchantPower

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
private float getEnchantPower() {
  float power = 0;

  for (int j = -1; j <= 1; ++j) {
    for (int k = -1; k <= 1; ++k) {
      if ((j != 0 || k != 0) && getWorldObj().isAirBlock(xCoord + k, yCoord, zCoord + j) && getWorldObj().isAirBlock(xCoord + k, yCoord + 1, zCoord + j)) {
        power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord, zCoord + j * 2);
        power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord + 1, zCoord + j * 2);

        if (k != 0 && j != 0) {
          power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord, zCoord + j);
          power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord + 1, zCoord + j);
          power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k, yCoord, zCoord + j * 2);
          power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k, yCoord + 1, zCoord + j * 2);
        }
      }
    }
  }

  return power;
}
 
开发者ID:HenryLoenwind,项目名称:EnderIOAddons,代码行数:22,代码来源:TileTcom.java

示例3: getEnchantingPower

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/**
 * Gets the enchantment power for a given position in a world. This uses the enchantment
 * table logic, so it searches for blocks that are two blocks out from the position passed.
 *
 * @param world The world to check in.
 * @param pos The position to get the enchanting power of.
 * @return The enchantment power for a given position in the world.
 */
public static float getEnchantingPower (World world, BlockPos pos) {

    final int x = pos.getX();
    final int y = pos.getY();
    final int z = pos.getZ();

    float power = 0;

    for (int zOffset = -1; zOffset <= 1; zOffset++) {

        for (int xOffset = -1; xOffset <= 1; xOffset++) {

            if ((zOffset != 0 || xOffset != 0) && world.isAirBlock(new BlockPos(x + xOffset, y, z + zOffset)) && world.isAirBlock(new BlockPos(x + xOffset, y + 1, z + zOffset))) {

                power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset * 2, y, z + zOffset * 2));
                power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset * 2, y + 1, z + zOffset * 2));

                if (xOffset != 0 && zOffset != 0) {

                    power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset * 2, y, z + zOffset));
                    power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset * 2, y + 1, z + zOffset));
                    power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset, y, z + zOffset * 2));
                    power += ForgeHooks.getEnchantPower(world, new BlockPos(x + xOffset, y + 1, z + zOffset * 2));
                }
            }
        }
    }

    return power;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:39,代码来源:EnchantmentUtils.java

示例4: onCraftMatrixChanged

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/**
 * Callback for when the crafting matrix is changed.
 */
@Override
public void onCraftMatrixChanged(IInventory p_75130_1_) {
	if (p_75130_1_ == tableInventory) {
		ItemStack var2 = p_75130_1_.getStackInSlot(0);
		int power;

		if (var2 != null && var2.isItemEnchantable()) {
			if (!world.isRemote) {
				power = 0;
				int j;

				for (j = -1; j <= 1; ++j)
					for (int k = -1; k <= 1; ++k)
						if ((j != 0 || k != 0) && world.isAirBlock(posX + k, posY, posZ + j) && world.isAirBlock(posX + k, posY + 1, posZ + j)) {
							power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY, posZ + j * 2);
							power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY + 1, posZ + j * 2);

							if (k != 0 && j != 0) {
								power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY, posZ + j);
								power += ForgeHooks.getEnchantPower(world, posX + k * 2, posY + 1, posZ + j);
								power += ForgeHooks.getEnchantPower(world, posX + k, posY, posZ + j * 2);
								power += ForgeHooks.getEnchantPower(world, posX + k, posY + 1, posZ + j * 2);
							}
						}

				rand.setSeed(enchantmentSeed);

				for (j = 0; j < 3; ++j) {
					enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(rand, j, power, var2);
					field_178151_h[j] = -1;

					if (enchantLevels[j] < j + 1)
						enchantLevels[j] = 0;
				}

				for (j = 0; j < 3; ++j)
					if (enchantLevels[j] > 0) {
						List<EnchantmentData> var7 = func_178148_a(var2, j, enchantLevels[j]);

						if (var7 != null && !var7.isEmpty()) {
							EnchantmentData var6 = var7.get(rand.nextInt(var7.size()));
							field_178151_h[j] = var6.enchantmentobj.effectId | var6.enchantmentLevel << 8;
						}
					}

				detectAndSendChanges();
			}
		} else
			for (power = 0; power < 3; ++power) {
				enchantLevels[power] = 0;
				field_178151_h[power] = -1;
			}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:58,代码来源:ContainerEnchantment.java

示例5: onCraftMatrixChanged

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public void onCraftMatrixChanged(IInventory p_75130_1_)
{
    if (p_75130_1_ == this.tableInventory)
    {
        ItemStack itemstack = p_75130_1_.getStackInSlot(0);
        int i;

        if (itemstack != null)   // CraftBukkit - relax condition
        {
            this.nameSeed = this.rand.nextLong();

            if (!this.worldPointer.isRemote)
            {
                i = 0;
                int j;
                float power = 0;

                for (j = -1; j <= 1; ++j)
                {
                    for (int k = -1; k <= 1; ++k)
                    {
                        if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.posX + k, this.posY, this.posZ + j) && this.worldPointer.isAirBlock(this.posX + k, this.posY + 1, this.posZ + j))
                        {
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j * 2);
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j * 2);

                            if (k != 0 && j != 0)
                            {
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY,     posZ + j * 2);
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY + 1, posZ + j * 2);
                            }
                        }
                    }
                }

                for (j = 0; j < 3; ++j)
                {
                    this.enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(this.rand, j, (int)power, itemstack);
                }

                // CraftBukkit start
                CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
                PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.worldPointer.getWorld().getBlockAt(this.posX, this.posY, this.posZ), item, this.enchantLevels, i);
                event.setCancelled(!itemstack.isItemEnchantable());
                if (this.getBukkitView() != null) this.worldPointer.getServer().getPluginManager().callEvent(event); // Cauldron - allow vanilla mods to byp

                if (event.isCancelled())
                {
                    for (i = 0; i < 3; ++i)
                    {
                        this.enchantLevels[i] = 0;
                    }

                    return;
                }

                // CraftBukkit end
                this.detectAndSendChanges();
            }
        }
        else
        {
            for (i = 0; i < 3; ++i)
            {
                this.enchantLevels[i] = 0;
            }
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:72,代码来源:ContainerEnchantment.java

示例6: onCraftMatrixChanged

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public void onCraftMatrixChanged(IInventory p_75130_1_)
{
    if (p_75130_1_ == this.tableInventory)
    {
        ItemStack itemstack = p_75130_1_.getStackInSlot(0);
        int i;

        if (itemstack != null && itemstack.isItemEnchantable())
        {
            this.nameSeed = this.rand.nextLong();

            if (!this.worldPointer.isRemote)
            {
                i = 0;
                int j;
                float power = 0;

                for (j = -1; j <= 1; ++j)
                {
                    for (int k = -1; k <= 1; ++k)
                    {
                        if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.posX + k, this.posY, this.posZ + j) && this.worldPointer.isAirBlock(this.posX + k, this.posY + 1, this.posZ + j))
                        {
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j * 2);
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j * 2);

                            if (k != 0 && j != 0)
                            {
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY,     posZ + j * 2);
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY + 1, posZ + j * 2);
                            }
                        }
                    }
                }

                for (j = 0; j < 3; ++j)
                {
                    this.enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(this.rand, j, (int)power, itemstack);
                }

                this.detectAndSendChanges();
            }
        }
        else
        {
            for (i = 0; i < 3; ++i)
            {
                this.enchantLevels[i] = 0;
            }
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:55,代码来源:ContainerEnchantment.java

示例7: onCraftMatrixChanged

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/**
 * Callback for when the crafting matrix is changed.
 */
public void onCraftMatrixChanged(IInventory par1IInventory)
{
    if (par1IInventory == this.tableInventory)
    {
        ItemStack itemstack = par1IInventory.getStackInSlot(0);
        int i;

        if (itemstack != null && itemstack.isItemEnchantable())
        {
            this.nameSeed = this.rand.nextLong();

            if (!this.worldPointer.isRemote)
            {
                i = 0;
                int j;
                float power = 0;

                for (j = -1; j <= 1; ++j)
                {
                    for (int k = -1; k <= 1; ++k)
                    {
                        if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.posX + k, this.posY, this.posZ + j) && this.worldPointer.isAirBlock(this.posX + k, this.posY + 1, this.posZ + j))
                        {
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j * 2);
                            power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j * 2);

                            if (k != 0 && j != 0)
                            {
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY,     posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j    );
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY,     posZ + j * 2);
                                power += ForgeHooks.getEnchantPower(worldPointer, posX + k,     posY + 1, posZ + j * 2);
                            }
                        }
                    }
                }

                for (j = 0; j < 3; ++j)
                {
                    this.enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(this.rand, j, (int)power, itemstack);
                }

                this.detectAndSendChanges();
            }
        }
        else
        {
            for (i = 0; i < 3; ++i)
            {
                this.enchantLevels[i] = 0;
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:58,代码来源:ContainerEnchantment.java


注:本文中的net.minecraftforge.common.ForgeHooks.getEnchantPower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。