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


Java QuiverArrowRegistry类代码示例

本文整理汇总了Java中mods.battlegear2.api.quiver.QuiverArrowRegistry的典型用法代码示例。如果您正苦于以下问题:Java QuiverArrowRegistry类的具体用法?Java QuiverArrowRegistry怎么用?Java QuiverArrowRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: assignArrows

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
private void assignArrows()
{
	if(ArrowType.arrows.isEmpty())
	{
		return;
	}
	
	for(int a = 0; a < ArrowType.arrows.size(); a ++)
	{
		ArrowType arrow = ArrowType.arrows.get(a);
		
		ArrowsMF.addArrow(new ItemStack(itemID, 1, arrow.meta));
		CrossbowAmmo.addArrow(new ItemStack(itemID, 1, arrow.meta));
		Arrows.addArrow(new ItemStack(itemID, 1, arrow.meta));
		QuiverArrowRegistry.addArrowToRegistry(new ItemStack(itemID, 1, arrow.meta), null);
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:18,代码来源:ItemArrowMF.java

示例2: canShootArrow

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
/**
 * Returns true if this bow's level is capable of shooting the given arrow
 */
public boolean canShootArrow(EntityPlayer player, ItemStack bow, ItemStack arrowStack) {
	Item arrowItem = (arrowStack == null ? null : arrowStack.getItem());
	if (arrowMap.containsKey(arrowItem)) {
		if (player.capabilities.isCreativeMode) {
			return true;
		} else if (arrowItem instanceof IMagicArrow) {
			if (!ZSSPlayerInfo.get(player).canUseMagic() || ZSSPlayerInfo.get(player).getCurrentMagic() < ((IMagicArrow) arrowItem).getMagicCost(arrowStack, player)) {
				return false;
			}
		}
		if (elementalArrowMap.containsKey(arrowItem)) {
			int n = getLevel(bow);
			if (n < 3) {
				return (n == 2 && elementalArrowMap.get(arrowItem) != ElementType.LIGHT);
			}
		}
		return true;
	}
	// allow hero's bow to fire arrows registered with BG2
	return ZSSMain.isBG2Enabled && QuiverArrowRegistry.isKnownArrow(arrowStack);
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:25,代码来源:ItemHeroBow.java

示例3: onBowUse

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@SubscribeEvent
public void onBowUse(ArrowNockEvent event){
	// change to use Result: DENY (cannot fire), DEFAULT (attempt standard nocking algorithm), ALLOW (nock without further checks)
	Result canDrawBow = Result.DEFAULT;
	// insert special bow check here:
	if (event.getBow().getItem() instanceof ISpecialBow) {
		canDrawBow = ((ISpecialBow) event.getBow().getItem()).canDrawBow(event.getBow(), event.getEntityPlayer());
	}
	// Special bow did not determine a result, so use standard algorithms instead:
	if (canDrawBow == Result.DEFAULT && (event.hasAmmo() || event.getEntityPlayer().capabilities.isCreativeMode)) {
		canDrawBow = Result.ALLOW;
	}
	if (canDrawBow == Result.DEFAULT) {
		ItemStack quiver = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer());
		if (!quiver.isEmpty() && ((IArrowContainer2)quiver.getItem()).
			hasArrowFor(quiver, event.getBow(), event.getEntityPlayer(), ((IArrowContainer2) quiver.getItem()).getSelectedSlot(quiver))) {
			canDrawBow = Result.ALLOW;
		}
	}
	// only nock if allowed
	if (canDrawBow == Result.ALLOW) {
		event.getEntityPlayer().setActiveHand(event.getHand());
		event.setAction(ActionResult.newResult(EnumActionResult.SUCCESS, event.getBow()));
	}
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:26,代码来源:BowHookContainerClass2.java

示例4: tickEnd

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
private void tickEnd(EntityPlayer entityPlayer) {
    int timer = ((IBattlePlayer)entityPlayer).getSpecialActionTimer();
    if(timer > 0){
        ((IBattlePlayer)entityPlayer).setSpecialActionTimer(timer-1);
        int targetTime = -1;
        ItemStack offhand = entityPlayer.getHeldItemOffhand();
        if(offhand.getItem() instanceof IShield){
            targetTime = ((IShield) offhand.getItem()).getBashTimer(offhand) / 2;
        }else{
            offhand = QuiverArrowRegistry.getArrowContainer(entityPlayer);
            if(!offhand.isEmpty()) {
                targetTime = 0;
            }
        }
        if(timer-1 == targetTime){
            Battlegear.proxy.doSpecialAction(entityPlayer, offhand);
        }
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:20,代码来源:BattlegearTickHandeler.java

示例5: preInit

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@EventHandler
public void preInit(FMLPreInitializationEvent event) 
{ 
	addModFlags();
	Configuration config = new Configuration(
			event.getSuggestedConfigurationFile());
	new cfg().setConfig(config);
	
	if(isDebug())
	{
		System.out.println("MineFantasy: Debug mode ACTIVE");
		HeatableItem.requiresHeating = false;
	}
	removeRecipes();
	GameRegistry.registerFuelHandler(new MineFantasyFuels());
	TickRegistry.registerTickHandler(new ArmourTickHandlerMF(), FMLCommonHandler.instance().getSide());
	TickRegistry.registerTickHandler(new ArmourTickHandlerMF(), Side.SERVER);
	TickRegistry.registerTickHandler(new HotItemTickHandler(), FMLCommonHandler.instance().getSide());
	TickRegistry.registerTickHandler(new HotItemTickHandler(), Side.SERVER);
	
	proxy.registerTickHandlers();
	proxy.registerRenderInformation();
	NetworkRegistry.instance().registerGuiHandler(instance, proxy);
	if (client) {
		MinecraftForge.EVENT_BUS.register(new SoundManagerMF());
		StatListMF.init();
	}
	CrossbowAmmo.addCrossbowHandler(new CrossbowAmmoMF());
	
	rebuildRecipes();
	
	QuiverArrowRegistry.addArrowFireHandler(new QuiverArrowsMF());
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:34,代码来源:MineFantasyBase.java

示例6: fireArrow

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的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);
			}
		}
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:38,代码来源:ItemHeroBow.java

示例7: registerBG2

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
/**
 * Registers {@link HeroBowFireHandler} and all arrows required for use with
 * Battlegear2's quiver system
 */
@Method(modid="battlegear2")
public static void registerBG2() {
	fireHandlers.add(new HeroBowFireHandler());
	fireHandlers.add(new DefaultArrowFire());
	QuiverArrowRegistry.addArrowFireHandler(new HeroBowFireHandler());
	// registering as null prevents default fire handler from handling these arrows:
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowBomb, null);
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowBombFire, null);
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowBombWater, null);
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowFire, null);
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowIce, null);
	QuiverArrowRegistry.addArrowToRegistry(ZSSItems.arrowLight, null);
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:18,代码来源:ItemHeroBow.java

示例8: preInit

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    logger = event.getModLog();
    knightArmourMaterial = EnumHelper.addArmorMaterial("knights.armour", "battlegear2:knight", 25, new int[]{3, 5, 7, 3}, 15, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.5F);
    ResourceLocation sound = new ResourceLocation(MODID, "shield");
    shieldSound = GameRegistry.register(new SoundEvent(sound).setRegistryName(sound));
    BattlegearConfig.getConfig(new Configuration(event.getSuggestedConfigurationFile()));

    if((event.getSourceFile().getName().endsWith(".jar") || debug) && event.getSide().isClient()){
        try {
            Class.forName("mods.mud.ModUpdateDetector").getDeclaredMethod("registerMod", ModContainer.class, String.class, String.class).invoke(null,
                    FMLCommonHandler.instance().findContainerFor(this),
                    "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/battlegear_update.xml",
                    "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/changelog.md"
            );
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    proxy.registerHandlers();
    QuiverArrowRegistry.addArrowToRegistry(Items.ARROW, EntityTippedArrow.class);
    QuiverArrowRegistry.addArrowToRegistry(Items.TIPPED_ARROW, EntityTippedArrow.class);
    QuiverArrowRegistry.addArrowToRegistry(Items.SPECTRAL_ARROW, EntitySpectralArrow.class);
    //Fetch early messages
    IMCEvent imc = new IMCEvent();
    imc.applyModContainer(FMLCommonHandler.instance().findContainerFor(MODID));
    onMessage(imc);
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:29,代码来源:Battlegear.java

示例9: renderPlayerOffhand

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
/**
    * Render the offhand arm and shield swing in first person
    * @param event Fired right before player arm are rendered in first person
    */
@SubscribeEvent
   public void renderPlayerOffhand(RenderSpecificHandEvent event){
       final AbstractClientPlayer player = Minecraft.getMinecraft().player;
    if(event.getHand() == EnumHand.OFF_HAND){
        if(event.getItemStack().isEmpty()){
               if(!player.isInvisible() && BattlegearUtils.isPlayerInBattlemode(player)) {
                   GlStateManager.pushMatrix();
                   Minecraft.getMinecraft().getItemRenderer().renderArmFirstPerson(event.getEquipProgress(), event.getSwingProgress(), player.getPrimaryHand().opposite());
                   GlStateManager.popMatrix();
               }
               return;
        }else if(event.getItemStack().getItem() instanceof IShield){
               BattlegearRenderHelper.renderItemInFirstPerson(event.getEquipProgress(), player, Minecraft.getMinecraft().getItemRenderer());
               event.setCanceled(true);
               return;
           }
       }
       if(event.getItemStack().getItem() instanceof IArrowContainer2 && ((IArrowContainer2) event.getItemStack().getItem()).renderDefaultQuiverModel(event.getItemStack())) {
           if (BattlegearConfig.hasRender("quiver")) {
               ItemStack quiverStack = QuiverArrowRegistry.getArrowContainer(player);
               if (event.getItemStack() == quiverStack) {
                   int slot = ((IArrowContainer2) event.getItemStack().getItem()).getSelectedSlot(event.getItemStack());
                   ItemStack arrowStack = ((IArrowContainer2) event.getItemStack().getItem()).getStackInSlot(event.getItemStack(), slot);
                   Minecraft.getMinecraft().getItemRenderer().renderItemInFirstPerson(player, event.getPartialTicks(), event.getInterpolatedPitch(), event.getHand(), event.getSwingProgress(), arrowStack, event.getEquipProgress());
                   event.setCanceled(true);
                   return;
               }
           }
       }
       ItemStack inUse = player.getActiveItemStack();
       if(event.getHand() != player.getActiveHand() && event.getItemStack() != inUse && !inUse.isEmpty() && BattlegearUtils.isBow(inUse.getItem())) {
           event.setCanceled(true);
       }
   }
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:39,代码来源:BattlegearClientEvents.java

示例10: doRender

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@Override
protected void doRender(EntityPlayer player, float partialTicks, float scale) {
    ItemStack quiverStack = QuiverArrowRegistry.getArrowContainer(player);
    if (!quiverStack.isEmpty() && ((IArrowContainer2) quiverStack.getItem()).renderDefaultQuiverModel(quiverStack)) {

        IArrowContainer2 quiver = (IArrowContainer2) quiverStack.getItem();
        int maxStack = quiver.getSlotCount(quiverStack);
        int arrowCount = 0;
        for (int i = 0; i < maxStack; i++) {
            arrowCount += quiver.getStackInSlot(quiverStack, i).isEmpty()? 0 : 1;
        }
        GlStateManager.pushMatrix();
        GlStateManager.color(1, 1, 1);
        Minecraft.getMinecraft().getTextureManager().bindTexture(BattlegearClientEvents.INSTANCE.quiverDetails);
        if (player.isSneaking()){//sneaking
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }
        if(player.hasItemInSlot(EntityEquipmentSlot.CHEST)){//chest armor
            GlStateManager.translate(0, 0, scale);
        }
        renderer.getMainModel().bipedBody.postRender(scale);
        GlStateManager.scale(1.05F, 1.05F, 1.05F);
        BattlegearClientEvents.INSTANCE.quiverModel.render(arrowCount, scale);

        Minecraft.getMinecraft().getTextureManager().bindTexture(BattlegearClientEvents.INSTANCE.quiverBase);
        if(quiverStack.getItem() instanceof IDyable){
            int col = ((IDyable)quiver).getColor(quiverStack);
            float red = (float) (col >> 16 & 255) / 255.0F;
            float green = (float) (col >> 8 & 255) / 255.0F;
            float blue = (float) (col & 255) / 255.0F;
            GlStateManager.color(red, green, blue);
        }
        BattlegearClientEvents.INSTANCE.quiverModel.render(0, scale);
        GlStateManager.color(1, 1, 1);

        GlStateManager.popMatrix();
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:39,代码来源:LayerQuiver.java

示例11: getArrowType

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@Override
public EntityArrow getArrowType(ItemStack stack, World world, EntityPlayer player, float charge) {
    ItemStack selected = getStackInSlot(stack, getSelectedSlot(stack));
    if(selected.isEmpty())
        return null;
    else
        return QuiverArrowRegistry.getArrowType(selected, world, player, charge);
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:9,代码来源:ItemQuiver.java

示例12: BowHookContainerClass2

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
private BowHookContainerClass2(){
    QuiverArrowRegistry.addQuiverSelection(new OffhandQuiverSelection());
    QuiverArrowRegistry.addQuiverSelection(new MainQuiverSelection());
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:5,代码来源:BowHookContainerClass2.java

示例13: onBowFiring

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@SubscribeEvent
public void onBowFiring(ArrowLooseEvent event) {
    //Check if bow is charged enough
    float f = new PlayerEventChild.QuiverArrowEvent.ChargeCalculations(event).getCharge();
    if(f>=0.1F){
        ItemStack stack = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer());
        if(stack.getItem() instanceof IArrowContainer2){
            IArrowContainer2 quiver = (IArrowContainer2) stack.getItem();
            World world = event.getEntityPlayer().world;
            EntityArrow entityarrow = quiver.getArrowType(stack, world, event.getEntityPlayer(), f*3.0F);
            if(entityarrow!=null){
                PlayerEventChild.QuiverArrowEvent.Firing arrowEvent = new PlayerEventChild.QuiverArrowEvent.Firing(event, stack, entityarrow);
                if(!MinecraftForge.EVENT_BUS.post(arrowEvent)){
                    quiver.onPreArrowFired(arrowEvent);
                    entityarrow.setAim(arrowEvent.getArcher(), arrowEvent.getArcher().rotationPitch, arrowEvent.getArcher().rotationYaw, 0, f*3F, 1F);
                    if (arrowEvent.isCritical || f == 1.0F)
                        entityarrow.setIsCritical(true);
                    if(arrowEvent.addEnchantments){
                        int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, event.getBow());
                        if (k > 0){
                            entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);
                        }
                        int l = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, event.getBow());
                        if (l > 0){
                            entityarrow.setKnockbackStrength(l);
                        }
                        if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, event.getBow()) > 0){
                            entityarrow.setFire(100);
                        }
                    }
                    if(arrowEvent.bowDamage>0) {
                        event.getBow().damageItem(arrowEvent.bowDamage, event.getEntityPlayer());
                        event.getEntityPlayer().addStat(StatList.getObjectUseStats(event.getBow().getItem()));
                    }
                    if(arrowEvent.bowSoundVolume>0)
                        world.playSound(null, arrowEvent.getArcher().posX, arrowEvent.getArcher().posY, arrowEvent.getArcher().posZ, arrowEvent.bowSound, SoundCategory.PLAYERS, arrowEvent.bowSoundVolume, 1.0F / (arrowEvent.getPlayer().getRNG().nextFloat() * 0.4F + 1.2F) + f * 0.5F);
                    if (!world.isRemote)
                        world.spawnEntity(entityarrow);
                    quiver.onArrowFired(world, arrowEvent.getPlayer(), stack, event.getBow(), entityarrow);
                    //Canceling the event, since we successfully fired our own arrow
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:47,代码来源:BowHookContainerClass2.java

示例14: doKey

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
private boolean doKey(int key) {
    if(Battlegear.battlegearEnabled){
        //null checks to prevent any crash outside the world (and to make sure we have no screen open)
        if (mc.player != null && mc.world != null && mc.currentScreen == null) {
            if(key == mc.gameSettings.keyBindPickBlock.getKeyCode()){
                if(!mc.player.isSpectator() && ((IBattlePlayer) mc.player).isBattlemode()){
                    KeyBinding.setKeyBindState(key, false);
                    while(mc.gameSettings.keyBindPickBlock.isPressed());//Exhaust key press to prevent pick block
                    return true;
                }
            }
            else if(key == mc.gameSettings.keyBindSwapHands.getKeyCode()){
                ItemStack quiver = QuiverArrowRegistry.getArrowContainer(mc.player);
                if (((IBattlePlayer) mc.player).getSpecialActionTimer() == 0) {
                    if (!quiver.isEmpty()) {
                        /*FMLProxyPacket p = new BattlegearAnimationPacket(EnumBGAnimations.SpecialAction, mc.player).generatePacket();
                        Battlegear.packetHandler.sendPacketToServer(p);*/
                        ((IBattlePlayer) mc.player).setSpecialActionTimer(2);
                    } else if (((IBattlePlayer) mc.player).isBattlemode()) {
                        ItemStack offhand = mc.player.getHeldItemOffhand();

                        if (offhand.getItem() instanceof IShield) {
                            float shieldBashPenalty = 0.33F - 0.06F * EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bashWeight, offhand);

                            if (BattlegearClientTickHandeler.getBlockTime() >= shieldBashPenalty) {
                                FMLProxyPacket p = new BattlegearAnimationPacket(EnumBGAnimations.SpecialAction, mc.player).generatePacket();
                                Battlegear.packetHandler.sendPacketToServer(p);
                                ((IBattlePlayer) mc.player).setSpecialActionTimer(((IShield) offhand.getItem()).getBashTimer(offhand));
                                BattlegearClientTickHandeler.reduceBlockTime(shieldBashPenalty);
                            }
                        }
                    }
                }
                if (!quiver.isEmpty() || ((IBattlePlayer) mc.player).isBattlemode()) {
                    KeyBinding.setKeyBindState(key, false);
                    while (mc.gameSettings.keyBindSwapHands.isPressed()) ;//Exhaust key press to prevent swap hand
                    return true;
                }
            }
            else if(BattlegearConfig.enableGUIKeys){
                if (key == battleInv.getKeyCode()) {
                    BattleEquipGUI.open(mc.player);
                } else if (key == openSigilEditor.getKeyCode()) {
                    BattlegearSigilGUI.open(mc.player);
                }
            }
        }
    }
    return false;
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:51,代码来源:BattlegearClientTickHandeler.java

示例15: process

import mods.battlegear2.api.quiver.QuiverArrowRegistry; //导入依赖的package包/类
@Override
public void process(ByteBuf inputStream, EntityPlayer player) {
    try {
        this.player = player.world.getPlayerEntityByUUID(UUID.fromString(ByteBufUtils.readUTF8String(inputStream)));
        if (inputStream.readBoolean()) {
            entityHit = player.world.getPlayerEntityByUUID(UUID.fromString(ByteBufUtils.readUTF8String(inputStream)));
        } else {
            entityHit = player.world.getEntityByID(inputStream.readInt());
        }
    }catch (Exception e){
        e.printStackTrace();
        return;
    }

    if(this.player!=null){
        if (entityHit instanceof EntityLivingBase) {
            ItemStack offhand = this.player.getHeldItemOffhand();
            if (offhand.getItem() instanceof IShield) {
                if (entityHit.canBePushed()) {
                    double d0 = entityHit.posX - this.player.posX;
                    double d1;
                    for (d1 = entityHit.posZ - this.player.posZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
                        d0 = (Math.random() - Math.random()) * 0.01D;
                    }
                    float pow = 0.5F + EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bashPower, offhand) * 0.1F;
                    ((EntityLivingBase) entityHit).knockBack(this.player, pow, -d0, -d1);
                }
                if (entityHit.getDistanceToEntity(this.player) < 2) {
                    float dam = EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bashDamage, offhand) * 2F;
                    if (dam > 0) {
                        entityHit.attackEntityFrom(DamageSource.causeThornsDamage(this.player), dam);
                        entityHit.playSound(SoundEvents.ENCHANT_THORNS_HIT, 0.5F, 1.0F);
                    }
                }
                if (!this.player.world.isRemote && entityHit instanceof EntityPlayerMP) {
                    Battlegear.packetHandler.sendPacketToPlayer(this.generatePacket(), (EntityPlayerMP) entityHit);
                }
            }
        }else{
            ItemStack quiver = QuiverArrowRegistry.getArrowContainer(this.player);
            if(!quiver.isEmpty()){
                SwapArrowEvent swapEvent = new SwapArrowEvent(this.player, quiver);
                if(!MinecraftForge.EVENT_BUS.post(swapEvent) && swapEvent.slotStep!=0) {
                    ((IArrowContainer2) quiver.getItem()).setSelectedSlot(quiver, swapEvent.getNextSlot());
                    if (this.player instanceof EntityPlayerMP) {
                        Battlegear.packetHandler.sendPacketToPlayer(this.generatePacket(), (EntityPlayerMP) this.player);
                    }
                }
            }
        }
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:53,代码来源:SpecialActionPacket.java


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