本文整理匯總了Java中net.minecraftforge.event.ForgeEventFactory.getBreakSpeed方法的典型用法代碼示例。如果您正苦於以下問題:Java ForgeEventFactory.getBreakSpeed方法的具體用法?Java ForgeEventFactory.getBreakSpeed怎麽用?Java ForgeEventFactory.getBreakSpeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.ForgeEventFactory
的用法示例。
在下文中一共展示了ForgeEventFactory.getBreakSpeed方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: blockStrength
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public static float blockStrength(Block block, EntityPlayer player, World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
float hardness = block.getBlockHardness(world, x, y, z);
if (hardness < 0.0F)
{
return 0.0F;
}
if (!canHarvestBlock(block, player, metadata))
{
float speed = ForgeEventFactory.getBreakSpeed(player, block, metadata, 1.0f);
return (speed < 0 ? 0 : speed) / hardness / 100F;
}
else
{
return player.getCurrentPlayerStrVsBlock(block, false, metadata) / hardness / 30F;
}
}
示例2: getBreakSpeed
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z)
{
ItemStack stack = this.inventory.getCurrentItem();
float f = stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, p_146096_1_, meta);
if (f > 1.0F)
{
int i = EnchantmentHelper.getEfficiencyModifier(this);
ItemStack itemstack = this.inventory.getCurrentItem();
if ((i > 0) && (itemstack != null))
{
float f1 = i * i + 1;
boolean canHarvest = ForgeHooks.canToolHarvestBlock(p_146096_1_, meta, itemstack);
if ((!canHarvest) && (f <= 1.0F)) {
f += f1 * 0.08F;
} else {
f += f1;
}
}
}
if (isPotionActive(Potion.digSpeed)) {
f *= (1.0F + (getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F);
}
if (isPotionActive(Potion.digSlowdown)) {
f *= (1.0F - (getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F);
}
if ((isInsideOfMaterial(Material.water)) && (!EnchantmentHelper.getAquaAffinityModifier(this))) {
f /= 5.0F;
}
if (!this.onGround) {
f /= 5.0F;
}
f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z);
return f < 0.0F ? 0.0F : f;
}
示例3: getBreakSpeed
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
/**
* Adapted from {@link net.minecraft.entity.player.EntityPlayer#getBreakSpeed
* (Block, boolean, int, int, int, int)}. Uses given item rather than player
* held item.
*
* @param player Current player.
* @param block To be broken.
* @param metadata Extra nibble.
* @param x X-axis coordinate of block.
* @param y Y-axis coordinate of block.
* @param z Z-axis coordinate of block.
* @param stack Item breaking block.
* @return Relative break speed.
*/
public static float getBreakSpeed(EntityPlayer player, Block block
, int metadata, int x, int y, int z, ItemStack stack) {
float f = (stack == null ? 1.0F
: stack.getItem().getDigSpeed(stack, block, metadata));
if(f > 1.0F) {
int mod = EnchantmentHelper.getEnchantmentLevel
(Enchantment.efficiency.effectId, stack);
if(mod > 0 && stack != null) {
float f1 = (float)(mod * mod + 1);
if(!ForgeHooks.canToolHarvestBlock(block, metadata, stack)
&& f <= 1.0F) {
f += f1 * 0.08F;
}
else {
f += f1;
}
}
}
if(player.isPotionActive(Potion.digSpeed)) {
f *= 1.0F + (float)(player.getActivePotionEffect(Potion.digSpeed)
.getAmplifier() + 1) * 0.2F;
}
if(player.isPotionActive(Potion.digSlowdown)) {
f *= 1.0F - (float)(player.getActivePotionEffect(Potion.digSlowdown)
.getAmplifier() + 1) * 0.2F;
}
if(player.isInsideOfMaterial(Material.water)
&& !EnchantmentHelper.getAquaAffinityModifier(player)) {
f /= 5.0F;
}
if(!player.onGround) {
f /= 5.0F;
}
f = ForgeEventFactory.getBreakSpeed(player, block, metadata, f, x, y, z);
return (f < 0 ? 0 : f);
}
示例4: getPlayerRelativeBlockHardness
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
float hardness = getBlockHardness(world, x, y, z);
if(hardness < 0.0F) {
return 0.0F;
}
if(!canHarvestBlock(player, meta)) {
float speed = ForgeEventFactory.getBreakSpeed(player, this, meta, 1.0f, x, y, z);
return (speed < 0 ? 0 : speed) / hardness / 100F;
} else {
return player.getBreakSpeed(this, false, meta, x, y, z) / hardness / 30F;
}
}
示例5: getBreakSpeed
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z)
{
ItemStack stack = inventory.getCurrentItem();
float f = (stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, p_146096_1_, meta));
if (f > 1.0F)
{
int i = EnchantmentHelper.getEfficiencyModifier(this);
ItemStack itemstack = this.inventory.getCurrentItem();
if (i > 0 && itemstack != null)
{
float f1 = (float)(i * i + 1);
boolean canHarvest = ForgeHooks.canToolHarvestBlock(p_146096_1_, meta, itemstack);
if (!canHarvest && f <= 1.0F)
{
f += f1 * 0.08F;
}
else
{
f += f1;
}
}
}
if (this.isPotionActive(Potion.digSpeed))
{
f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
}
if (this.isPotionActive(Potion.digSlowdown))
{
f *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
}
if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this))
{
f /= 5.0F;
}
if (!this.onGround)
{
f /= 5.0F;
}
f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z);
return (f < 0 ? 0 : f);
}
示例6: getCurrentPlayerStrVsBlock
import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
public float getCurrentPlayerStrVsBlock(Block par1Block, boolean par2, int meta)
{
ItemStack stack = inventory.getCurrentItem();
float f = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta));
if (f > 1.0F)
{
int i = EnchantmentHelper.getEfficiencyModifier(this);
ItemStack itemstack = this.inventory.getCurrentItem();
if (i > 0 && itemstack != null)
{
float f1 = (float)(i * i + 1);
boolean canHarvest = ForgeHooks.canToolHarvestBlock(par1Block, meta, itemstack);
if (!canHarvest && f <= 1.0F)
{
f += f1 * 0.08F;
}
else
{
f += f1;
}
}
}
if (this.isPotionActive(Potion.digSpeed))
{
f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
}
if (this.isPotionActive(Potion.digSlowdown))
{
f *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F;
}
if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this))
{
f /= 5.0F;
}
if (!this.onGround)
{
f /= 5.0F;
}
f = ForgeEventFactory.getBreakSpeed(this, par1Block, meta, f);
return (f < 0 ? 0 : f);
}