本文整理匯總了Java中net.minecraftforge.event.entity.player.ArrowLooseEvent類的典型用法代碼示例。如果您正苦於以下問題:Java ArrowLooseEvent類的具體用法?Java ArrowLooseEvent怎麽用?Java ArrowLooseEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ArrowLooseEvent類屬於net.minecraftforge.event.entity.player包,在下文中一共展示了ArrowLooseEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBowFire
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SuppressWarnings("static-access")
@SubscribeEvent
public void onBowFire(ArrowLooseEvent event)
{
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getBow();
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (player != null && stack != null && nbt != null && !player.getEntityWorld().isRemote)
{
if (BowAttribute.BARRAGE.hasAttribute(nbt))
{
for (int i = 0; i < (int) BowAttribute.BARRAGE.getCalculatedValue(nbt, 3, 1.5); i++)
{
EntityArrow entityarrow = new EntityTippedArrow(player.getEntityWorld(), player);
entityarrow.setAim(player, player.rotationPitch, player.rotationYaw, 0, ((ItemBow) event.getBow().getItem()).getArrowVelocity(event.getCharge()) * 3, 20F);
entityarrow.pickupStatus = PickupStatus.DISALLOWED;
player.getEntityWorld().spawnEntity(entityarrow);
}
}
}
}
示例2: fireArrow
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
public void fireArrow(ArrowLooseEvent event)
{
if(MineFantasyBase.isBGLoaded())
{
return;
}
ItemStack bow = event.bow;
float charge = event.charge;
EntityPlayer player = event.entityPlayer;
World world = event.entity.worldObj;
ItemBowMF.loadArrow(player, bow, null, true);
for(ItemStack arrow: ArrowsMF.useableArrows)
{
if(shootSpecificArrow( bow, world, player, charge, arrow))
{
event.setCanceled(true);
return;
}
}
}
示例3: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@ForgeSubscribe
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
if(inv.getCurrentItem().itemID == Item.bow.itemID)
{
if(mod_Rediscovered.QuickBow)
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && itemstack.itemID == mod_Rediscovered.Quiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.LeatherQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.ChainQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.IronQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.GoldQuiver.itemID || itemstack != null && itemstack.itemID == mod_Rediscovered.DiamondQuiver.itemID)
{
event.setCanceled(true);
}
}
}
}
示例4: 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);
}
}
示例5: 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.
}
}
示例6: 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);
}
}
示例7: onArrowLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
public static int onArrowLoose(ItemStack stack, World world, EntityPlayer player, int charge, boolean hasAmmo)
{
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo);
if (MinecraftForge.EVENT_BUS.post(event))
return -1;
return event.getCharge();
}
示例8: handleLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleLoose(ArrowLooseEvent event){
if(event.getEntityPlayer() !=null){
ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(event.getEntityPlayer());
if(exPlayer !=null){
ExtendedPlayerInventory inv = exPlayer.getInventory();
ItemStack backpack = inv.getStackInSlot(ExtendedPlayerInventory.BACKPACK_SLOT_ID);
if(ItemStackTools.isValid(backpack)){
InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(event.getEntityPlayer(), backpack);
if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.BOW)){
InventoryBackpack backpackInv = BackpackUtil.getInventory(event.getEntityPlayer(), backpack);
if(backpackInv !=null){
for(int i = 0; i < backpackInv.getSize(); i++){
ItemStack st = backpackInv.getStackInSlot(i);
if(ItemStackTools.isValid(st) && st.getItem() instanceof ItemArrow){
if(!EntityUtil.shootArrow(event.getWorld(), event.getEntityPlayer(), event.getBow(), st, event.getCharge())){
backpackInv.decrStackSize(i, 1);
backpackInv.markDirty();
backpackInv.guiSave(event.getEntityPlayer());
inv.setChanged(ExtendedPlayerInventory.BACKPACK_SLOT_ID, true);
event.setCanceled(true);
return;
}
}
}
}
}
}
}
}
}
示例9: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
/**
* Event listener for Action.SHOOT_ARROW
*/
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent event) throws IOException
{
EntityPlayer player = event.getEntityPlayer();
List<Action> events = CommonProxy.manager.getActions(player);
if (!player.worldObj.isRemote && events != null)
{
events.add(new ShootArrowAction(event.getCharge()));
}
}
示例10: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack par1ItemStack = inv.getStackInSlot(inv.currentItem);
ItemStack blah = new ItemStack(Items.bow);
ItemStack quiver = new ItemStack(mod_Rediscovered.Quiver);
ItemStack lquiver = new ItemStack(mod_Rediscovered.LeatherQuiver);
ItemStack cquiver = new ItemStack(mod_Rediscovered.ChainQuiver);
ItemStack gquiver = new ItemStack(mod_Rediscovered.GoldQuiver);
ItemStack iquiver = new ItemStack(mod_Rediscovered.IronQuiver);
ItemStack dquiver = new ItemStack(mod_Rediscovered.DiamondQuiver);
ItemStack lcquiver = new ItemStack(mod_Rediscovered.LeatherChainQuiver);
if(inv.getCurrentItem().equals(blah))
{
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
ItemStack itemstack = player.inventory.armorInventory[2];
if (itemstack != null && (itemstack.equals(quiver) || itemstack.equals(lquiver) || itemstack.equals(cquiver) || itemstack.equals(iquiver) || itemstack.equals(gquiver) || itemstack.equals(dquiver) || itemstack.equals(lcquiver)))
{
event.setCanceled(true);
}
}
}
示例11: onArrowLooseEvent
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onArrowLooseEvent(ArrowLooseEvent ev) throws IOException {
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.SERVER) {
List<MocapAction> aList = Mocap.instance
.getActionListForPlayer(ev.entityPlayer);
if (aList != null) {
MocapAction ma = new MocapAction(MocapActionTypes.SHOOTARROW);
ma.arrowCharge = ev.charge;
aList.add(ma);
}
}
}
示例12: 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);
}
}
}
示例13: detectArrow
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SubscribeEvent
public void detectArrow(ArrowLooseEvent event)
{
if (!ConfigHandler.BACKPACK_ABILITIES) return;
if (Wearing.isWearingTheRightBackpack(event.entityPlayer, "Skeleton"))
{
InventoryBackpack backpack = new InventoryBackpack(Wearing.getWearingBackpack(event.entityPlayer));
if (backpack.hasItem(Items.arrow))
{
ServerActions.leakArrow(event.entityPlayer, event.bow, event.charge);
event.setCanceled(true);
}
}
}
示例14: onArrowLoose
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onArrowLoose(ArrowLooseEvent event) {
if (event.entity.worldObj.isRemote) { return; }
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null) {
this.lastBow.put(event.entityPlayer, event.entityPlayer.getHeldItem());
}
}
示例15: fireArrow
import net.minecraftforge.event.entity.player.ArrowLooseEvent; //導入依賴的package包/類
/**
* Called if ArrowLooseEvent was not canceled, so either the player is not using a quiver,
* or Battlegear2 is not loaded.
* Constructs and fires the arrow, if possible, and may consume the appropriate inventory item.
*/
private void fireArrow(ArrowLooseEvent event, ItemStack arrowStack, ItemStack bow, EntityPlayer player) {
boolean flag = (player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) > 0);
if (flag || PlayerUtils.hasItem(player, arrowStack)) {
float charge = (float) event.charge / 20.0F;
charge = Math.min((charge * charge + charge * 2.0F) / 3.0F, 1.0F);
if ((double) charge < 0.1D) {
return;
}
EntityArrow arrowEntity = getArrowEntity(arrowStack, player.worldObj, player, charge * 2.0F);
if (arrowEntity == null && ZSSMain.isBG2Enabled) { // try to construct BG2 arrow
arrowEntity = QuiverArrowRegistry.getArrowType(arrowStack, player.worldObj, player, charge * 2.0F);
}
if (arrowEntity != null && confirmArrowShot(arrowStack, player)) {
applyArrowSettings(arrowEntity, bow, charge);
if (arrowEntity instanceof EntityArrowCustom) {
applyCustomArrowSettings(event.entityPlayer, event.bow, arrowStack, (EntityArrowCustom) arrowEntity, charge);
}
player.worldObj.playSoundAtEntity(player, Sounds.BOW_RELEASE, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + charge * 0.5F);
if (flag) {
arrowEntity.canBePickedUp = 2;
} else {
PlayerUtils.consumeInventoryItem(player, arrowStack, 1);
}
if (!player.worldObj.isRemote) {
player.worldObj.spawnEntityInWorld(arrowEntity);
}
}
}
}