本文整理汇总了Java中mods.battlegear2.api.quiver.QuiverArrowRegistry.getArrowContainer方法的典型用法代码示例。如果您正苦于以下问题:Java QuiverArrowRegistry.getArrowContainer方法的具体用法?Java QuiverArrowRegistry.getArrowContainer怎么用?Java QuiverArrowRegistry.getArrowContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mods.battlegear2.api.quiver.QuiverArrowRegistry
的用法示例。
在下文中一共展示了QuiverArrowRegistry.getArrowContainer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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()));
}
}
示例2: 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);
}
}
}
示例3: 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);
}
}
示例4: 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();
}
}
示例5: 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);
}
}
}
}
}
示例6: 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;
}
示例7: 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);
}
}
}
}
}
}