本文整理匯總了Java中net.minecraftforge.event.entity.player.ArrowLooseEvent.isCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrowLooseEvent.isCanceled方法的具體用法?Java ArrowLooseEvent.isCanceled怎麽用?Java ArrowLooseEvent.isCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.ArrowLooseEvent
的用法示例。
在下文中一共展示了ArrowLooseEvent.isCanceled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack bow, World world, EntityPlayer player, int ticksRemaining) {
ZSSPlayerInfo.get(player).hasAutoBombArrow = false;
int ticksInUse = getMaxItemUseDuration(bow) - ticksRemaining;
ArrowLooseEvent event = new ArrowLooseEvent(player, bow, ticksInUse);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
if (getArrow(player) != null) {
setArrow(player, null); // nocked from inventory from empty quiver slot, then hot-swapped
}
return;
}
// Default behavior found usable arrow in standard player inventory
ItemStack arrowStack = getArrow(player);
if (arrowStack != null) { // can be null when hot-swapping to an empty quiver slot
if (canShootArrow(player, bow, arrowStack)) {
fireArrow(event, arrowStack, bow, player);
}
setArrow(player, null);
}
}
示例2: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int par4)
{
int chargeTime = this.getMaxItemUseDuration(stack) - par4;
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, chargeTime);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) { return; } // Not having it
chargeTime = event.charge;
// Either creative mode or infinity enchantment is higher than 0. Not using arrows
boolean freeShot = player.capabilities.isCreativeMode;
if (freeShot || player.inventory.hasItemStack(new ItemStack(Items.arrow)) )
{
float f = (float) chargeTime / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D) { return; }
if (f > 1.0F) { f = 1.0F; }
EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F);
if (f == 1.0F) { entityarrow.setIsCritical(true); }
stack.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (freeShot) { entityarrow.canBePickedUp = 2; }
else { player.inventory.consumeInventoryItem(Items.arrow); }
if (!world.isRemote) { world.spawnEntityInWorld(entityarrow); } // pew.
}
}
示例3: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
if (!par2World.isRemote)
{
int j = this.getMaxItemUseDuration(stack) - par4; // Reduces the durability by the ItemInUseCount (probably 1 for anything that isn't a tool)
ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, stack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) { return; }
j = event.charge;
if (this.getDamage(stack) == this.getMaxDamage()) { return; } // No arrows in the quiver? Getting out of here early
float f = j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if (f < 0.1D) { return; }
if (f > 1.0F) { f = 1.0F; }
EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
if (f == 1.0F) { entityarrow.setIsCritical(true); }
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (par3EntityPlayer.capabilities.isCreativeMode) { entityarrow.canBePickedUp = 0; }
else
{
entityarrow.canBePickedUp = 1;
stack.setItemDamage(this.getDamage(stack) + 1); // Reversed. MORE Damage for a shorter durability bar
}
par2World.spawnEntityInWorld(entityarrow);
}
}
示例4: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
int j = this.getMaxItemUseDuration(par1ItemStack) - par4;
ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
if (par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.hasItem(IlluminatedItems.illuminatedArrow)) {
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityIlluminatedArrow arrow = new EntityIlluminatedArrow(par2World, par3EntityPlayer, f*2.0F);
arrow.setBlockToSet(IlluminatedBlocks.illuminatedBlock);
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (Config.bowTakesDamage)
par1ItemStack.damageItem(1, par3EntityPlayer);
if (!par3EntityPlayer.capabilities.isCreativeMode)
par3EntityPlayer.inventory.consumeInventoryItem(IlluminatedItems.illuminatedArrow);
if (!par2World.isRemote) {
par2World.spawnEntityInWorld(arrow);
}
}
}
示例5: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
{
int maxItemUse = getMaxItemUseDuration(stack) - time;
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, maxItemUse);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) return;
maxItemUse = event.charge;
boolean infiniteAmmo = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (infiniteAmmo || player.inventory.hasItem(ammo)) {
float scaledItemUse = (float) maxItemUse / 20.0F;
scaledItemUse = (scaledItemUse * scaledItemUse + scaledItemUse * 2) / 3;
if ((double) scaledItemUse < 0.1) return;
if (scaledItemUse > 1) scaledItemUse = 1;
EntityROCArrow entityarrow = new EntityROCArrow(world, player, scaledItemUse*2, damage, ammo.getUnlocalizedName().replace("item.arrow", ""));
entityarrow.setAmmoItem(ammo);
if (scaledItemUse == 1) entityarrow.setIsCritical(true);
int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (powerLevel > 0) entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5 + 0.5);
int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (punchLevel > 0) entityarrow.setKnockbackStrength(punchLevel);
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) entityarrow.setFire(100);
stack.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + scaledItemUse * 0.5F);
if (infiniteAmmo) entityarrow.canBePickedUp = 2;
else player.inventory.consumeInventoryItem(ammo);
if (!world.isRemote) world.spawnEntityInWorld(entityarrow);
}
}
示例6: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack is, World world, EntityPlayer player, int inUseCount)
{
int j = this.getMaxItemUseDuration(is) - inUseCount;
ArrowLooseEvent event = new ArrowLooseEvent(player, is, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
return;
j = event.charge;
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, is) > 0;
boolean hasAmmo = flag || player.inventory.hasItem(ModItems.itemSharpStone) || player.inventory.hasItem(ModItems.itemHardStone) || player.inventory.hasItem(ModItems.itemSoftStone);
if (hasAmmo)
{
float forceMult = j / getUseSpeed(player);
//f = (f * f + f * 2.0F) / 3.0F;
if (forceMult < 0.25D)
return;
if (forceMult > 1.25F)
forceMult = 1.25F;
EntityProjectileSharpStone entitysharpstone = new EntityProjectileSharpStone(world, player, forceMult * 1.2F);
EntityProjectileHardStone entityhardstone = new EntityProjectileHardStone(world, player, forceMult * 1.5F);
EntityProjectileSoftStone entitysoftstone = new EntityProjectileSoftStone(world, player, forceMult * 0.8F);
entitysharpstone.setDamage(forceMult * 40.0);
entityhardstone.setDamage(forceMult * 50.0);
entitysoftstone.setDamage(forceMult * 30.0);
is.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + forceMult * 0.5F);
if (flag)
{
// entitysharpstone.canBePickedUp = 2;
entityhardstone.canBePickedUp = 2;
// entitysoftstone.canBePickedUp = 2;
if (!world.isRemote)
world.spawnEntityInWorld(entityhardstone);
}
else if(hasAmmo)
{
if (player.inventory.hasItem(ModItems.itemHardStone))
{
player.inventory.consumeInventoryItem(ModItems.itemHardStone);
if (!world.isRemote)
world.spawnEntityInWorld(entityhardstone);
}
else if (player.inventory.hasItem(ModItems.itemSharpStone))
{
player.inventory.consumeInventoryItem(ModItems.itemSharpStone);
if (!world.isRemote)
world.spawnEntityInWorld(entitysharpstone);
}
else
{
player.inventory.consumeInventoryItem(ModItems.itemSoftStone);
if (!world.isRemote)
world.spawnEntityInWorld(entitysoftstone);
}
}
}
}
示例7: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
{
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
if (flag || p_77615_3_.inventory.hasItem(ItemLoader.itemPatArrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntilyPatArrow entitypatarrow = new EntilyPatArrow(p_77615_2_, p_77615_3_, f * 2.0F);
if (f == 1.0F)
{
entitypatarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_);
if (k > 0)
{
entitypatarrow.setDamage(entitypatarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_);
if (l > 0)
{
entitypatarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0)
{
entitypatarrow.setFire(100);
}
p_77615_1_.damageItem(1, p_77615_3_);
p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
entitypatarrow.canBePickedUp = 2;
}
else
{
p_77615_3_.inventory.consumeInventoryItem(ItemLoader.itemPatArrow);
}
if (!p_77615_2_.isRemote)
{
p_77615_2_.spawnEntityInWorld(entitypatarrow);
}
}
}
示例8: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
{
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
if (flag || p_77615_3_.inventory.hasItem(ItemLoader.itemJenArrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntilyJenArrow entityjenarrow = new EntilyJenArrow(p_77615_2_, p_77615_3_, f * 2.0F);
if (f == 1.0F)
{
entityjenarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_);
if (k > 0)
{
entityjenarrow.setDamage(entityjenarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_);
if (l > 0)
{
entityjenarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0)
{
entityjenarrow.setFire(100);
}
p_77615_1_.damageItem(1, p_77615_3_);
p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
entityjenarrow.canBePickedUp = 2;
}
else
{
p_77615_3_.inventory.consumeInventoryItem(ItemLoader.itemJenArrow);
}
if (!p_77615_2_.isRemote)
{
p_77615_2_.spawnEntityInWorld(entityjenarrow);
}
}
}
示例9: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
{
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
if (flag || p_77615_3_.inventory.hasItem(Items.arrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityArrow entityarrow = new EntityArrow(p_77615_2_, p_77615_3_, f * 2.0F);
if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_);
if (k > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_);
if (l > 0)
{
entityarrow.setKnockbackStrength(l);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0)
{
entityarrow.setFire(100);
}
p_77615_1_.damageItem(1, p_77615_3_);
p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
entityarrow.canBePickedUp = 2;
}
else
{
p_77615_3_.inventory.consumeInventoryItem(Items.arrow);
}
if (!p_77615_2_.isRemote)
{
p_77615_2_.spawnEntityInWorld(entityarrow);
}
}
}
示例10: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int useDur )
{
// Ammo check and stuff
Ammo ammo = getActiveArrow( player );
if ( ammo == null || ammo.inv == null || ammo.stack == null || ammo.slot == -1 )
{
return;
}
boolean ignoreArrows = EnchantmentHelper.getEnchantmentLevel( Enchantment.infinity.effectId, stack ) > 0 && Arrow.getData( ArrowItem.getHeadMaterial( ammo.stack ) ).affectedByInfinity();
ignoreArrows = player.capabilities.isCreativeMode || ignoreArrows;
// Charge
int charge = getMaxItemUseDuration( stack ) - useDur;
ArrowLooseEvent event = new ArrowLooseEvent( player, stack, charge );
MinecraftForge.EVENT_BUS.post( event );
if ( event.isCanceled() || charge < 5 )
{
return;
}
charge = event.charge;
// Shoot arrow
float f = (float) charge / 20.0F;
f = ( f * f + f * 2.0F ) / 3.0F;
if ( f > 1.0F )
{
f = 1.0F;
}
ArrowEntity arrow = new ArrowEntity( world, player, f * 2.0F );
arrow.setHeadMaterial( ArrowItem.getHeadMaterial( ammo.stack ) );
arrow.setFeathered( ArrowItem.getFeathered( ammo.stack ) );
if (f == 1.0F)
{
arrow.setIsCritical( true );
}
// TODO: Detect TConstruct and double damage?
int powerLevel = EnchantmentHelper.getEnchantmentLevel( Enchantment.power.effectId, stack );
if ( powerLevel > 0 )
{
arrow.setDamage( arrow.getDamage() + (double) powerLevel * 0.5D + 0.5D );
}
int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if ( punchLevel > 0 )
{
arrow.setKnockbackStrength( punchLevel );
}
if ( EnchantmentHelper.getEnchantmentLevel( Enchantment.flame.effectId, stack ) > 0 )
{
arrow.setFire( 100 );
}
if ( !player.capabilities.isCreativeMode )
{
damageItemStack( player, stack, 1 );
}
world.playSoundAtEntity( player, "random.bow", 1.0F, 1.0F / ( itemRand.nextFloat() * 0.4F + 1.2F ) + f * 0.5F );
if ( ignoreArrows )
{
arrow.canBePickedUp = 2;
}
else
{
ammo.inv.decrStackSize( ammo.slot, 1 );
}
if ( !world.isRemote )
{
world.spawnEntityInWorld( arrow );
}
}
示例11: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemUse) {
int j = getMaxItemUseDuration(stack) - itemUse;
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
return;
}
j = event.charge;
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || player.inventory.hasItem(TDEWeapons.daedric_arrow)) {
float f = (float) j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double) f < 0.1D) {
return;
}
if (f > 1.0F) {
f = 1.0F;
}
EntityDragonArrow entityarrow = new EntityDragonArrow(world, player, f * 2.0F);
entityarrow.setFire(100);
entityarrow.setDamage(entityarrow.getDamage() + 1.0D + 1.0D);
if (f == 1.0F) {
entityarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0) {
entityarrow.setDamage(entityarrow.getDamage() + (double) k * 1.0D + 1.0D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0) {
entityarrow.setKnockbackStrength(l);
}
/*if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) {
entityarrow.setFire(100);
}*/
stack.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag) {
entityarrow.canBePickedUp = 2;
} else {
player.inventory.consumeInventoryItem(TDEWeapons.daedric_arrow);
}
if (!world.isRemote) {
world.spawnEntityInWorld(entityarrow);
}
}
}
示例12: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemUse) {
int j = getMaxItemUseDuration(stack) - itemUse;
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
return;
}
j = event.charge;
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || player.inventory.hasItem(TDEWeapons.dragon_arrow)) {
float f = (float) j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double) f < 0.1D) {
return;
}
if (f > 1.0F) {
f = 1.0F;
}
EntityDaedricArrow entityarrow = new EntityDaedricArrow(world, player, f * 2.0F);
entityarrow.setFire(100);
entityarrow.setDamage(entityarrow.getDamage() + 1.0D + 1.0D);
if (f == 1.0F) {
entityarrow.setIsCritical(true);
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0) {
entityarrow.setDamage(entityarrow.getDamage() + (double) k * 1.0D + 1.0D);
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0) {
entityarrow.setKnockbackStrength(l);
}
/*if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) {
entityarrow.setFire(100);
}*/
stack.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag) {
entityarrow.canBePickedUp = 2;
} else {
player.inventory.consumeInventoryItem(TDEWeapons.dragon_arrow);
}
if (!world.isRemote) {
world.spawnEntityInWorld(entityarrow);
}
}
}
示例13: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
public void onPlayerStoppedUsing(ItemStack item, World world, EntityPlayer player, int time)
{
int power = (this.getMaxItemUseDuration(item) - time);
power *= model.speed; // Speeds up the power in relation to ticks used
power = (int)((float)power / 20F * getMaxPower());//scales the power down from full
if(power > getMaxPower())power = (int)getMaxPower();//limits the power to max
ArrowLooseEvent event = new ArrowLooseEvent(player, item, power);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
power = event.charge;
boolean var5 = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, item) > 0;
if (var5 || player.inventory.hasItem(Item.arrow.itemID))
{
float var7 = (float)power / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(world, player, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, item);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, item);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, item) > 0)
{
var8.setFire(100);
}
item.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (var5)
{
var8.canBePickedUp = 2;
}
else
{
player.inventory.consumeInventoryItem(Item.arrow.itemID);
}
if (!world.isRemote)
{
world.spawnEntityInWorld(var8);
}
}
}
示例14: onPlayerStoppedUsing
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack item, World world, EntityPlayer player, int time)
{
int power = (this.getMaxItemUseDuration(item) - time);
power *= model.speed; // Speeds up the power in relation to ticks used
power = (int)((float)power / 20F * getMaxPower());//scales the power down from full
if(power > getMaxPower())power = (int)getMaxPower();//limits the power to max
ArrowLooseEvent event = new ArrowLooseEvent(player, item, power);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
power = event.charge;
boolean var5 = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, item) > 0;
if (var5 || player.inventory.hasItem(Item.arrow.itemID))
{
float var7 = (float)power / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(world, player, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, item);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, item);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, item) > 0)
{
var8.setFire(100);
}
item.damageItem(1, player);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (var5)
{
var8.canBePickedUp = 2;
}
else
{
player.inventory.consumeInventoryItem(Item.arrow.itemID);
}
if (!world.isRemote)
{
world.spawnEntityInWorld(var8);
}
}
}
示例15: onPlayerStoppedUsingFocus
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入方法依賴的package包/類
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world,
EntityPlayer player, int count) {
int j = 72000 - count;
ArrowLooseEvent event = new ArrowLooseEvent(player, itemstack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
if (player.capabilities.isCreativeMode||ThaumcraftApiHelper.consumeVisFromWand(itemstack, player, visCost, true,false))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityIlluminatedArrow arrow = new EntityIlluminatedArrow(world, player, 2.0F*f);
arrow.setDamage(0);
arrow.setDeadOnLand(true);
arrow.isMagic(true);
world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (!world.isRemote) {
world.spawnEntityInWorld(arrow);
}
}
else
{
world.playSoundAtEntity(player, "thaumcraft:craftfail", 1.0F, 1.0F);
}
}