diff --git a/src/main/java/com/hbm/items/armor/ArmorNCRPAMelee.java b/src/main/java/com/hbm/items/armor/ArmorNCRPAMelee.java index d0db8b15c..5a586c8f3 100644 --- a/src/main/java/com/hbm/items/armor/ArmorNCRPAMelee.java +++ b/src/main/java/com/hbm/items/armor/ArmorNCRPAMelee.java @@ -2,15 +2,85 @@ package com.hbm.items.armor; import org.lwjgl.opengl.GL11; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; +import com.hbm.items.weapon.sedna.factory.ConfettiUtil; +import com.hbm.items.weapon.sedna.factory.XFactoryPA; import com.hbm.main.ResourceManager; +import com.hbm.render.anim.BusAnimation; +import com.hbm.render.anim.BusAnimationSequence; +import com.hbm.render.anim.HbmAnimations; +import com.hbm.render.anim.AnimationEnums.GunAnimation; +import com.hbm.render.anim.BusAnimationKeyframe.IType; +import com.hbm.util.EntityDamageUtil; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; public class ArmorNCRPAMelee implements IPAMelee { - public void setupFirstPerson(ItemStack stack) { } + @Override public void clickPrimary(ItemStack stack, LambdaContext ctx) { XFactoryPA.doSwing(stack, ctx, GunAnimation.CYCLE, 30); } + @Override public void clickSecondary(ItemStack stack, LambdaContext ctx) { XFactoryPA.doSwing(stack, ctx, GunAnimation.ALT_CYCLE, 40); } + @Override + public void orchestra(ItemStack stack, LambdaContext ctx) { + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; + GunAnimation type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); + int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); + + boolean swings = type == GunAnimation.CYCLE && (timer == 5 || timer == 15); + boolean sweep = type == GunAnimation.ALT_CYCLE && timer == 5; + + if((swings || sweep) && ctx.getPlayer() != null) { + MovingObjectPosition mop = EntityDamageUtil.getMouseOver(ctx.getPlayer(), 3.0D); + + if(mop != null) { + if(mop.typeOfHit == mop.typeOfHit.ENTITY) { + float damage = swings ? 15F : 35F; + float knockback = swings ? 0F : 1.5F; + float dt = swings ? 5F : 15F; + float pierce = swings ? 0.1F : 0.25F; + + if(mop.entityHit instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) mop.entityHit; + EntityDamageUtil.attackEntityFromNT((EntityLivingBase) mop.entityHit, DamageSource.causePlayerDamage(ctx.getPlayer()), damage, true, false, knockback, dt, pierce); + if(!living.isEntityAlive()) ConfettiUtil.gib(living); + } else { + mop.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(ctx.getPlayer()), damage); + } + + entity.worldObj.playSoundAtEntity(mop.entityHit, "hbm:weapon.fire.stab", 1F, 0.9F + entity.getRNG().nextFloat() * 0.2F); + } + if(mop.typeOfHit == mop.typeOfHit.BLOCK) { + Block b = entity.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ); + entity.worldObj.playSoundEffect(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, b.stepSound.getStepResourcePath(), 2F, 0.9F + entity.getRNG().nextFloat() * 0.2F); + } + } + } + } + + @Override + public BusAnimation playAnim(ItemStack stack, GunAnimation type) { + if(type == GunAnimation.EQUIP) return new BusAnimation() + .addBus("EQUIP", new BusAnimationSequence().setPos(-1, 0, 0).addPos(0, 0, 0, 750, IType.SIN_DOWN)); + if(type == GunAnimation.CYCLE) return new BusAnimation() + .addBus("SWINGRIGHT", new BusAnimationSequence().addPos(1, 0, 0, 250, IType.SIN_DOWN).addPos(0, 0, 0, 500, IType.SIN_FULL)) + .addBus("SWINGLEFT", new BusAnimationSequence().addPos(0, 0, 0, 500).addPos(1, 0, 0, 250, IType.SIN_DOWN).addPos(0, 0, 0, 500, IType.SIN_FULL)); + if(type == GunAnimation.ALT_CYCLE) return new BusAnimation() + .addBus("SWEEPTURN", new BusAnimationSequence().addPos(1, 0, 0, 100, IType.LINEAR).hold(350).addPos(0, 0, 0, 500, IType.LINEAR)) + .addBus("SWEEPCUT", new BusAnimationSequence().hold(100).addPos(1, 0, 0, 250, IType.SIN_DOWN).hold(100).addPos(0, 0, 0, 500, IType.SIN_FULL)); + + return null; + } + + @Override public void setupFirstPerson(ItemStack stack) { } + + @Override public void renderFirstPerson(ItemStack stack) { Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.ncrpa_arm); @@ -18,31 +88,38 @@ public class ArmorNCRPAMelee implements IPAMelee { double scale = 0.125D; GL11.glScaled(scale, scale, scale); - double forwardTilt = 60; + double[] equip = HbmAnimations.getRelevantTransformation("EQUIP"); + double swingRight = HbmAnimations.getRelevantTransformation("SWINGRIGHT")[0]; + double swingLeft = HbmAnimations.getRelevantTransformation("SWINGLEFT")[0]; + double sweepTurn = HbmAnimations.getRelevantTransformation("SWEEPTURN")[0]; + double sweepCut = HbmAnimations.getRelevantTransformation("SWEEPCUT")[0]; + + double forwardTilt = 60 - 60 * equip[0]; double offsetOutward = 3; double roll = 60; GL11.glPushMatrix(); - GL11.glRotated(forwardTilt, 1, 0, 0); + + GL11.glTranslated(-14 * swingLeft - 4 * sweepTurn, 6 * sweepCut, 2 * swingLeft + 8 * sweepCut); + GL11.glRotated(forwardTilt + swingRight * 40 - 60 * sweepCut, 1, 0, 0); GL11.glTranslated(offsetOutward, 0, 0); GL11.glTranslated(6, 8, 0); - GL11.glRotated(roll, 0, 1, 0); - GL11.glRotated(10, 0, 0, 1); + GL11.glRotated(90 * swingLeft, 0, 0, 1); + GL11.glRotated(roll + 30 * swingLeft - 90 * sweepTurn, 0, 1, 0); GL11.glTranslated(-6, -8, 0); ResourceManager.armor_ncr.renderPart("LeftArm"); GL11.glPopMatrix(); GL11.glPushMatrix(); - //GL11.glTranslated(7, 0, 4); - - GL11.glRotated(forwardTilt, 1, 0, 0); + GL11.glTranslated(14 * swingRight + 4 * sweepTurn, 6 * sweepCut, 2 * swingRight + 8 * sweepCut); + GL11.glRotated(forwardTilt + swingLeft * 40 - 60 * sweepCut, 1, 0, 0); GL11.glTranslated(-offsetOutward, 0, 0); GL11.glTranslated(-6, 8, 0); - GL11.glRotated(-90, 0, 0, 1); - GL11.glRotated(-roll - 30, 0, 1, 0); + GL11.glRotated(-90 * swingRight, 0, 0, 1); + GL11.glRotated(-roll - 30 * swingRight + 90 * sweepTurn, 0, 1, 0); GL11.glTranslated(6, -8, 0); ResourceManager.armor_ncr.renderPart("RightArm"); GL11.glPopMatrix(); diff --git a/src/main/java/com/hbm/items/armor/IPAMelee.java b/src/main/java/com/hbm/items/armor/IPAMelee.java index 6e24d22bf..87208c86f 100644 --- a/src/main/java/com/hbm/items/armor/IPAMelee.java +++ b/src/main/java/com/hbm/items/armor/IPAMelee.java @@ -1,9 +1,19 @@ package com.hbm.items.armor; +import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; +import com.hbm.render.anim.AnimationEnums.GunAnimation; +import com.hbm.render.anim.BusAnimation; + import net.minecraft.item.ItemStack; public interface IPAMelee { public void setupFirstPerson(ItemStack stack); public void renderFirstPerson(ItemStack stack); + + public BusAnimation playAnim(ItemStack stack, GunAnimation type); + public void orchestra(ItemStack stack, LambdaContext ctx); + + public void clickPrimary(ItemStack stack, LambdaContext ctx); + public void clickSecondary(ItemStack stack, LambdaContext ctx); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryPA.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryPA.java index 7597cde7e..fc173e8ad 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryPA.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryPA.java @@ -5,16 +5,17 @@ import java.util.function.BiConsumer; import java.util.function.BiFunction; import com.hbm.items.ModItems; +import com.hbm.items.armor.IPAMelee; +import com.hbm.items.armor.IPAWeaponsProvider; import com.hbm.items.weapon.sedna.Crosshair; import com.hbm.items.weapon.sedna.GunConfig; import com.hbm.items.weapon.sedna.Receiver; import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.ItemGunBaseNT.GunState; import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; import com.hbm.items.weapon.sedna.ItemGunBaseNT.WeaponQuality; import com.hbm.render.anim.BusAnimation; -import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.AnimationEnums.GunAnimation; -import com.hbm.render.anim.BusAnimationKeyframe.IType; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -29,27 +30,44 @@ public class XFactoryPA { .draw(10).inspect(55).crosshair(Crosshair.NONE) .rec(new Receiver(0) .dmg(10F).delay(20).jam(0) - .offset(1, -0.0625 * 2.5, -0.25D) - .canFire(LAMBDA_MELEE_CAN_FIRE).fire(LAMBDA_MELEE_FIRE)) - .pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY).rp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY).decider(GunStateDecider.LAMBDA_STANDARD_DECIDER) - .anim(LAMBDA_MELEE_ANIMS).orchestra(Orchestras.ORCHESTRA_DRILL) + .offset(1, -0.0625 * 2.5, -0.25D)) + .pp(LAMBDA_CLICK_PRIMARY).ps(LAMBDA_CLICK_SENONDARY).decider(GunStateDecider.LAMBDA_STANDARD_DECIDER) + .anim(LAMBDA_MELEE_ANIMS).orchestra(ORCHESTRA) ).setUnlocalizedName("gun_pa_melee"); } + + public static BiConsumer ORCHESTRA = (stack, ctx) -> { + IPAMelee component = IPAWeaponsProvider.getMeleeComponentClient(); + if(component != null) component.orchestra(stack, ctx); + }; public static BiFunction LAMBDA_MELEE_ANIMS = (stack, type) -> { - if(type == GunAnimation.EQUIP) return new BusAnimation() - .addBus("EQUIP", new BusAnimationSequence().setPos(-1, 0, 0).addPos(0, 0, 0, 750, IType.SIN_DOWN)); - - return new BusAnimation() - .addBus("SWING", new BusAnimationSequence().setPos(-1, 0, 0).addPos(0, 0, 0, 750, IType.SIN_DOWN)); + IPAMelee component = IPAWeaponsProvider.getMeleeComponentClient(); + if(component != null) return component.playAnim(stack, type); + return null; }; - public static BiFunction LAMBDA_MELEE_CAN_FIRE = (stack, ctx) -> { return true; }; + public static BiConsumer LAMBDA_CLICK_PRIMARY = (stack, ctx) -> { + IPAMelee component = IPAWeaponsProvider.getMeleeComponentClient(); + if(component != null) component.clickPrimary(stack, ctx); + }; + public static BiConsumer LAMBDA_CLICK_SENONDARY = (stack, ctx) -> { + IPAMelee component = IPAWeaponsProvider.getMeleeComponentClient(); + if(component != null) component.clickSecondary(stack, ctx); + }; - public static BiConsumer LAMBDA_MELEE_FIRE = (stack, ctx) -> { + public static void doSwing(ItemStack stack, LambdaContext ctx, GunAnimation anim, int cooldown) { + EntityPlayer player = ctx.getPlayer(); - ItemGunBaseNT.playAnimation(player, stack, ItemGunBaseNT.getPrimary(stack, 0) ? GunAnimation.CYCLE : GunAnimation.ALT_CYCLE, ctx.configIndex); - }; + int index = ctx.configIndex; + GunState state = ItemGunBaseNT.getState(stack, index); + + if(state == GunState.IDLE) { + ItemGunBaseNT.playAnimation(player, stack, anim, ctx.configIndex); + ItemGunBaseNT.setState(stack, index, GunState.COOLDOWN); + ItemGunBaseNT.setTimer(stack, index, cooldown); + } + } public static class ItemGunMelee extends ItemGunBaseNT { diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderPAMelee.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderPAMelee.java index 7588ea9dd..20946c0df 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderPAMelee.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderPAMelee.java @@ -13,6 +13,9 @@ import net.minecraft.item.ItemStack; public class ItemRenderPAMelee extends ItemRenderWeaponBase { @Override public boolean isAkimbo(EntityLivingBase entity) { return true; } + + @Override protected float getSwayMagnitude(ItemStack stack) { return 2F; } + @Override protected float getSwayPeriod(ItemStack stack) { return 0.5F; } @Override public void setupFirstPerson(ItemStack stack) { @@ -53,28 +56,19 @@ public class ItemRenderPAMelee extends ItemRenderWeaponBase { GL11.glEnable(GL11.GL_LIGHTING); GL11.glShadeModel(GL11.GL_SMOOTH); - Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.maresleg_tex); + Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.ncrpa_arm); GL11.glPushMatrix(); - GL11.glRotated(225, 0, 0, 1); - GL11.glRotated(90, 0, 1, 0); - GL11.glRotated(25, 1, 0, 0); - GL11.glRotated(45, 0, 1, 0); - GL11.glTranslated(-1, 0, 0); - ResourceManager.maresleg.renderPart("Gun"); - ResourceManager.maresleg.renderPart("Lever"); - GL11.glPopMatrix(); - - GL11.glTranslated(0, 0, 5); - GL11.glPushMatrix(); - GL11.glRotated(225, 0, 0, 1); - GL11.glRotated(-90, 0, 1, 0); - GL11.glRotated(-90, 1, 0, 0); - GL11.glRotated(25, 1, 0, 0); - GL11.glRotated(-45, 0, 1, 0); - GL11.glTranslated(1, 0, 0); - ResourceManager.maresleg.renderPart("Gun"); - ResourceManager.maresleg.renderPart("Lever"); + double scale = 0.3125D; + GL11.glScaled(scale, scale, scale); + + GL11.glRotated(135, 0, 0, 1); + GL11.glRotated(135, 0, 1, 0); + GL11.glTranslated(0, -5.5, 0); + GL11.glTranslated(-3.5, 0, 0); + ResourceManager.armor_ncr.renderPart("Leftarm"); + GL11.glTranslated(7, 1, -1); + ResourceManager.armor_ncr.renderPart("RightArm"); GL11.glPopMatrix(); GL11.glShadeModel(GL11.GL_FLAT); diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 880a6a454..df5364607 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -2220,8 +2220,9 @@ item.gun_minigun_dual.name=Doppelete Miniguns item.gun_minigun_lacunae.name=Lacunae item.gun_missile_launcher.name=Raketenwerfer item.gun_n_i_4_n_i.name=N I 4 N I -item.gun_pepperbox.name=Bündelrevolver +item.gun_pa_melee.name=Powerrüstung - Nahkampfcontroller item.gun_panzerschreck.name=Panzerschreck +item.gun_pepperbox.name=Bündelrevolver item.gun_quadro.name=Vierfachraketenwerfer item.gun_spas12.name=SPAS-12 item.gun_star_f.name=Sportpistole diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 6501a9018..5603c8c43 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -3063,8 +3063,9 @@ item.gun_minigun_dual.name=Dual Miniguns item.gun_minigun_lacunae.name=Lacunae item.gun_missile_launcher.name=Missile Launcher item.gun_n_i_4_n_i.name=N I 4 N I -item.gun_pepperbox.name=Pepperbox +item.gun_pa_melee.name=Power Armor - Melee Controller item.gun_panzerschreck.name=Panzerschreck +item.gun_pepperbox.name=Pepperbox item.gun_quadro.name=Quad Rocket Launcher item.gun_spas12.name=SPAS-12 item.gun_star_f.name=Target Pistol