diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java index 92938b64a..8491176be 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java @@ -11,6 +11,8 @@ import net.minecraft.world.World; public class EntityBulletBaseMK4 extends EntityThrowableInterp { public BulletConfig config; + public double velocity; + public double prevVelocity; public EntityBulletBaseMK4(World world) { super(world); @@ -69,16 +71,25 @@ public class EntityBulletBaseMK4 extends EntityThrowableInterp { return; } - this.prevPosX = posX; - this.prevPosY = posY; - this.prevPosZ = posZ; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; super.onUpdate(); + + double dX = this.posX - this.prevPosX; + double dY = this.posY - this.prevPosY; + double dZ = this.posZ - this.prevPosZ; + + this.prevVelocity = this.velocity; + this.velocity = Math.sqrt(dX * dX + dY * dY + dZ * dZ); } @Override protected void onImpact(MovingObjectPosition mop) { - this.setDead(); + if(!worldObj.isRemote) { + this.setDead(); + } } @Override protected double headingForceMult() { return 1D; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java index 1502b98ab..9ee46a194 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java @@ -70,13 +70,13 @@ public class Gun12GaugeFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL_TRANSLATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, -2, 100) - .addKeyframePosition(0, 0, 0, 200) + .addPos(0, 0, -2, 100) + .addPos(0, 0, 0, 200) ) .addBus("PUMP", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 450) - .addKeyframePosition(0, 0, -1.8, 200) - .addKeyframePosition(0, 0, 0, 200) + .addPos(0, 0, 0, 450) + .addPos(0, 0, -1.8, 200) + .addPos(0, 0, 0, 200) ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java index 60daa8afb..3aa45c9ab 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java @@ -49,16 +49,16 @@ public class Gun20GaugeFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("LEVER_ROTATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 250) - .addKeyframePosition(0, 0, 45, 500) - .addKeyframePosition(0, 0, 0, 500) + .addPos(0, 0, 0, 250) + .addPos(0, 0, 45, 500) + .addPos(0, 0, 0, 500) ) .addBus("LEVER_RECOIL", new BusAnimationSequence() - .addKeyframePosition(0.5, 0, 0, 50) - .addKeyframePosition(0, 0, 0, 50) - .addKeyframePosition(0, 0, 0, 150) - .addKeyframePosition(0, -0.5, 0, 500) - .addKeyframePosition(0, 0, 0, 500) + .addPos(0.5, 0, 0, 50) + .addPos(0, 0, 0, 50) + .addPos(0, 0, 0, 150) + .addPos(0, -0.5, 0, 500) + .addPos(0, 0, 0, 500) ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java index d9ae7f897..c09794ca6 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java @@ -80,12 +80,12 @@ public class Gun45ACPFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("SLIDE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 10)// Wait for hammer - .addKeyframePosition(0, 0, -3.5, 40)// Slide back - .addKeyframePosition(0, 0, 0, 40))// Return + .addPos(0, 0, 0, 10)// Wait for hammer + .addPos(0, 0, -3.5, 40)// Slide back + .addPos(0, 0, 0, 40))// Return .addBus("HAMMER", new BusAnimationSequence() - .addKeyframePosition(15, 0, 0, 10) - .addKeyframePosition(0, 0, 0, 40))); + .addPos(15, 0, 0, 10) + .addPos(0, 0, 0, 40))); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java index 9ebcb6f44..8869e7259 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java @@ -123,25 +123,25 @@ public class Gun4GaugeFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("SAUER_RECOIL", new BusAnimationSequence() - .addKeyframePosition(0.5, 0, 0, 50) - .addKeyframePosition(0, 0, 0, 50) + .addPos(0.5, 0, 0, 50) + .addPos(0, 0, 0, 50) ) .addBus("SAUER_TILT", new BusAnimationSequence() - .addKeyframePosition(0.0, 0, 0, 200) // do nothing for 200ms - .addKeyframePosition(0, 0, 30, 150) //tilt forward - .addKeyframePosition(45, 0, 30, 150) //tilt sideways - .addKeyframePosition(45, 0, 30, 200) //do nothing for 200ms (eject) - .addKeyframePosition(0, 0, 30, 150) //restore sideways - .addKeyframePosition(0, 0, 0, 150) //restore forward + .addPos(0.0, 0, 0, 200) // do nothing for 200ms + .addPos(0, 0, 30, 150) //tilt forward + .addPos(45, 0, 30, 150) //tilt sideways + .addPos(45, 0, 30, 200) //do nothing for 200ms (eject) + .addPos(0, 0, 30, 150) //restore sideways + .addPos(0, 0, 0, 150) //restore forward ) .addBus("SAUER_COCK", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 500) //do nothing for 500ms - .addKeyframePosition(1, 0, 0, 100) //pull back lever for 100ms - .addKeyframePosition(0, 0, 0, 100) //release lever for 100ms + .addPos(0, 0, 0, 500) //do nothing for 500ms + .addPos(1, 0, 0, 100) //pull back lever for 100ms + .addPos(0, 0, 0, 100) //release lever for 100ms ) .addBus("SAUER_SHELL_EJECT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 500) //do nothing for 500ms - .addKeyframePosition(0, 0, 1, 500) //FLING! + .addPos(0, 0, 0, 500) //do nothing for 500ms + .addPos(0, 0, 1, 500) //FLING! ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index 9494ba9a9..846d931b9 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -137,20 +137,20 @@ public class Gun50BMGFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) ); config.animations.put(AnimType.RELOAD, new BusAnimation() .addBus("TILT", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 125) - .addKeyframePosition(1, 0, 0, 750) - .addKeyframePosition(0, 0, 0, 125) + .addPos(1, 0, 0, 125) + .addPos(1, 0, 0, 750) + .addPos(0, 0, 0, 125) ) .addBus("MAG", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 200) - .addKeyframePosition(1, 0, 1, 200) - .addKeyframePosition(0, 0, 0, 200) + .addPos(0, 0, 1, 200) + .addPos(1, 0, 1, 200) + .addPos(0, 0, 0, 200) ) ); @@ -190,8 +190,8 @@ public class Gun50BMGFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) ); @@ -237,10 +237,10 @@ public class Gun50BMGFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(-0.45, 0.15, 0, 40) // Moves back and raise slightly - .addKeyframePosition(0, 0, 0, 75)) // Then forward again - .addBus("EJECT", new BusAnimationSequence().addKeyframePosition(0, 0, 0, 30) // Wait - .addKeyframePosition(50, 0, 0, 120))); // Fly // out + .addPos(-0.45, 0.15, 0, 40) // Moves back and raise slightly + .addPos(0, 0, 0, 75)) // Then forward again + .addBus("EJECT", new BusAnimationSequence().addPos(0, 0, 0, 30) // Wait + .addPos(50, 0, 0, 120))); // Fly // out config.ejector = EJECTOR_SNIPER; return config; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java index df66f7f16..25f683b8a 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -92,8 +92,8 @@ public class Gun556mmFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(0.5, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(0.5, 0, 0, 25) + .addPos(0, 0, 0, 75) ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java index 09384bcc7..e8e667fab 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java @@ -47,25 +47,25 @@ public class Gun75BoltFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) .addBus("EJECT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 25) - .addKeyframePosition(0, 0, 1, 75) + .addPos(0, 0, 0, 25) + .addPos(0, 0, 1, 75) ) ); config.animations.put(AnimType.RELOAD, new BusAnimation() .addBus("TILT", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 250) - .addKeyframePosition(1, 0, 0, 1500) - .addKeyframePosition(0, 0, 0, 250) + .addPos(1, 0, 0, 250) + .addPos(1, 0, 0, 1500) + .addPos(0, 0, 0, 250) ) .addBus("MAG", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 500) - .addKeyframePosition(1, 0, 1, 500) - .addKeyframePosition(0, 0, 0, 500) + .addPos(0, 0, 1, 500) + .addPos(1, 0, 1, 500) + .addPos(0, 0, 0, 500) ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java index 6f08a02eb..619a3fe96 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java @@ -57,15 +57,15 @@ public class Gun762mmFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) ); config.animations.put(AnimType.RELOAD, new BusAnimation() .addBus("MAG", new BusAnimationSequence() - .addKeyframePosition(0, -1, 0, 500) - .addKeyframePosition(0, 0, 0, 500) + .addPos(0, -1, 0, 500) + .addPos(0, 0, 0, 500) ) ); @@ -176,19 +176,19 @@ public class Gun762mmFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) .addBus("LEVER_PULL", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 375) //wait out recoil and lever flick - .addKeyframePosition(-1, 0, 0, 375) //pull back bolt - .addKeyframePosition(0, 0, 0, 375) //release bolt + .addPos(0, 0, 0, 375) //wait out recoil and lever flick + .addPos(-1, 0, 0, 375) //pull back bolt + .addPos(0, 0, 0, 375) //release bolt ) .addBus("LEVER_ROTATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 250) //wait out recoil - .addKeyframePosition(1, 0, 0, 125) //flick up lever in 125ms - .addKeyframePosition(1, 0, 0, 750) //pull action - .addKeyframePosition(0, 0, 0, 125) //flick down lever again + .addPos(0, 0, 0, 250) //wait out recoil + .addPos(1, 0, 0, 125) //flick up lever in 125ms + .addPos(1, 0, 0, 750) //pull action + .addPos(0, 0, 0, 125) //flick down lever again ) ); @@ -215,19 +215,19 @@ public class Gun762mmFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) .addBus("LEVER_PULL", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 375) //wait out recoil and lever flick - .addKeyframePosition(-1, 0, 0, 375) //pull back bolt - .addKeyframePosition(0, 0, 0, 375) //release bolt + .addPos(0, 0, 0, 375) //wait out recoil and lever flick + .addPos(-1, 0, 0, 375) //pull back bolt + .addPos(0, 0, 0, 375) //release bolt ) .addBus("LEVER_ROTATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 250) //wait out recoil - .addKeyframePosition(1, 0, 0, 125) //flick up lever in 125ms - .addKeyframePosition(1, 0, 0, 750) //pull action - .addKeyframePosition(0, 0, 0, 125) //flick down lever again + .addPos(0, 0, 0, 250) //wait out recoil + .addPos(1, 0, 0, 125) //flick up lever in 125ms + .addPos(1, 0, 0, 750) //pull action + .addPos(0, 0, 0, 125) //flick down lever again ) ); @@ -258,19 +258,19 @@ public class Gun762mmFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) .addBus("LEVER_PULL", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 375) //wait out recoil and lever flick - .addKeyframePosition(-1, 0, 0, 375) //pull back bolt - .addKeyframePosition(0, 0, 0, 375) //release bolt + .addPos(0, 0, 0, 375) //wait out recoil and lever flick + .addPos(-1, 0, 0, 375) //pull back bolt + .addPos(0, 0, 0, 375) //release bolt ) .addBus("LEVER_ROTATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 250) //wait out recoil - .addKeyframePosition(1, 0, 0, 125) //flick up lever in 125ms - .addKeyframePosition(1, 0, 0, 750) //pull action - .addKeyframePosition(0, 0, 0, 125) //flick down lever again + .addPos(0, 0, 0, 250) //wait out recoil + .addPos(1, 0, 0, 125) //flick up lever in 125ms + .addPos(1, 0, 0, 750) //pull action + .addPos(0, 0, 0, 125) //flick down lever again ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/GunGaussFactory.java b/src/main/java/com/hbm/handler/guncfg/GunGaussFactory.java index 572bf3674..000e74d4e 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunGaussFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunGaussFactory.java @@ -41,8 +41,8 @@ public class GunGaussFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 25) - .addKeyframePosition(0, 0, 0, 75) + .addPos(1, 0, 0, 25) + .addPos(0, 0, 0, 75) ) ); diff --git a/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java b/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java index 02a1e5a37..08a7bdc35 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java @@ -82,23 +82,23 @@ public class GunRocketFactory { config.animations.put(AnimType.CYCLE, new BusAnimation() .addBus("QUADRO_RECOIL", new BusAnimationSequence() - .addKeyframePosition(0, 0, -0.5, 50) - .addKeyframePosition(0, 0, 0, 50) + .addPos(0, 0, -0.5, 50) + .addPos(0, 0, 0, 50) ) ); config.animations.put(AnimType.RELOAD, new BusAnimation() .addBus("QUADRO_RELOAD_ROTATE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 60, 750) - .addKeyframePosition(0, 0, 60, 3500) - .addKeyframePosition(0, 0, 0, 750) + .addPos(0, 0, 60, 750) + .addPos(0, 0, 60, 3500) + .addPos(0, 0, 0, 750) ) .addBus("QUADRO_RELOAD_PUSH", new BusAnimationSequence() - .addKeyframePosition(-1, -1, 0, 0) - .addKeyframePosition(-1, -1, 0, 750) - .addKeyframePosition(-1, 0, 0, 500) - .addKeyframePosition(0, 0, 0, 3000) - .addKeyframePosition(0, 0, 0, 750) + .addPos(-1, -1, 0, 0) + .addPos(-1, -1, 0, 750) + .addPos(-1, 0, 0, 500) + .addPos(0, 0, 0, 3000) + .addPos(0, 0, 0, 750) ) ); diff --git a/src/main/java/com/hbm/items/tool/ItemBoltgun.java b/src/main/java/com/hbm/items/tool/ItemBoltgun.java index 16eb83a0b..837eb7207 100644 --- a/src/main/java/com/hbm/items/tool/ItemBoltgun.java +++ b/src/main/java/com/hbm/items/tool/ItemBoltgun.java @@ -127,7 +127,7 @@ public class ItemBoltgun extends Item implements IAnimatedItem { public BusAnimation getAnimation(NBTTagCompound data, ItemStack stack) { return new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 1, 50) - .addKeyframePosition(0, 0, 1, 100)); + .addPos(1, 0, 1, 50) + .addPos(0, 0, 1, 100)); } } diff --git a/src/main/java/com/hbm/items/weapon/ItemCoilgun.java b/src/main/java/com/hbm/items/weapon/ItemCoilgun.java index af245c5d2..86e8dc937 100644 --- a/src/main/java/com/hbm/items/weapon/ItemCoilgun.java +++ b/src/main/java/com/hbm/items/weapon/ItemCoilgun.java @@ -22,16 +22,16 @@ public class ItemCoilgun extends ItemGunBase { if(type == AnimType.CYCLE) { return new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 100) - .addKeyframePosition(0, 0, 0, 200)); + .addPos(1, 0, 0, 100) + .addPos(0, 0, 0, 200)); } if(type == AnimType.RELOAD) { return new BusAnimation() .addBus("RELOAD", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 250) - .addKeyframePosition(1, 0, 0, 500) - .addKeyframePosition(0, 0, 0, 250)); + .addPos(1, 0, 0, 250) + .addPos(1, 0, 0, 500) + .addPos(0, 0, 0, 250)); } GunConfiguration config = ((ItemGunBase) stack.getItem()).mainConfig; diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBio.java b/src/main/java/com/hbm/items/weapon/ItemGunBio.java index 1e7184e84..5ba412702 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBio.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBio.java @@ -69,54 +69,54 @@ public class ItemGunBio extends ItemGunBase { lastShot = System.currentTimeMillis(); return new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 50) - .addKeyframePosition(0, 0, -3, 50) - .addKeyframePosition(0, 0, 0, 250) + .addPos(0, 0, 0, 50) + .addPos(0, 0, -3, 50) + .addPos(0, 0, 0, 250) ) .addBus("HAMMER", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 50) - .addKeyframePosition(0, 0, 1, 300) - .addKeyframePosition(0, 0, 0, 200) + .addPos(0, 0, 1, 50) + .addPos(0, 0, 1, 300) + .addPos(0, 0, 0, 200) ) .addBus("DRUM", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 50) + .addPos(0, 0, 1, 50) ); } if(type == AnimType.RELOAD) { return new BusAnimation() .addBus("LATCH", new BusAnimationSequence() - .addKeyframePosition(0, 0, 90, 300) - .addKeyframePosition(0, 0, 90, 2000) - .addKeyframePosition(0, 0, 0, 150) + .addPos(0, 0, 90, 300) + .addPos(0, 0, 90, 2000) + .addPos(0, 0, 0, 150) ) .addBus("FRONT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 200) - .addKeyframePosition(0, 0, 45, 150) - .addKeyframePosition(0, 0, 45, 2000) - .addKeyframePosition(0, 0, 0, 75) + .addPos(0, 0, 0, 200) + .addPos(0, 0, 45, 150) + .addPos(0, 0, 45, 2000) + .addPos(0, 0, 0, 75) ) .addBus("RELOAD_ROT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 300) - .addKeyframePosition(60, 0, 0, 500) - .addKeyframePosition(60, 0, 0, 500) - .addKeyframePosition(0, -90, -90, 0) - .addKeyframePosition(0, -90, -90, 600) - .addKeyframePosition(0, 0, 0, 300) - .addKeyframePosition(0, 0, 0, 100) - .addKeyframePosition(-45, 0, 0, 50) - .addKeyframePosition(-45, 0, 0, 100) - .addKeyframePosition(0, 0, 0, 300) + .addPos(0, 0, 0, 300) + .addPos(60, 0, 0, 500) + .addPos(60, 0, 0, 500) + .addPos(0, -90, -90, 0) + .addPos(0, -90, -90, 600) + .addPos(0, 0, 0, 300) + .addPos(0, 0, 0, 100) + .addPos(-45, 0, 0, 50) + .addPos(-45, 0, 0, 100) + .addPos(0, 0, 0, 300) ) .addBus("RELOAD_MOVE", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 300) - .addKeyframePosition(0, -15, 0, 1000) - .addKeyframePosition(0, 0, 0, 450) + .addPos(0, 0, 0, 300) + .addPos(0, -15, 0, 1000) + .addPos(0, 0, 0, 450) ) .addBus("DRUM_PUSH", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 1600) - .addKeyframePosition(0, 0, -5, 0) - .addKeyframePosition(0, 0, 0, 300) + .addPos(0, 0, 0, 1600) + .addPos(0, 0, -5, 0) + .addPos(0, 0, 0, 300) ); } diff --git a/src/main/java/com/hbm/items/weapon/ItemGunPip.java b/src/main/java/com/hbm/items/weapon/ItemGunPip.java index c6ed8aaf9..5e0e636ca 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunPip.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunPip.java @@ -64,7 +64,7 @@ public class ItemGunPip extends ItemGunBase { if(type == AnimType.EQUIP) { return new BusAnimation() .addBus("ROTATE", new BusAnimationSequence() - .addKeyframePosition(-360, 0, 0, 350) + .addPos(-360, 0, 0, 350) ); } @@ -73,17 +73,17 @@ public class ItemGunPip extends ItemGunBase { int s = 1; return new BusAnimation() .addBus("RECOIL", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 50 * s) - .addKeyframePosition(0, 0, -3, 50 * s) - .addKeyframePosition(0, 0, 0, 250 * s) + .addPos(0, 0, 0, 50 * s) + .addPos(0, 0, -3, 50 * s) + .addPos(0, 0, 0, 250 * s) ) .addBus("HAMMER", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 50 * s) - .addKeyframePosition(0, 0, 1, 300 * s) - .addKeyframePosition(0, 0, 0, 200 * s) + .addPos(0, 0, 1, 50 * s) + .addPos(0, 0, 1, 300 * s) + .addPos(0, 0, 0, 200 * s) ) .addBus("DRUM", new BusAnimationSequence() - .addKeyframePosition(0, 0, 1, 50 * s) + .addPos(0, 0, 1, 50 * s) ); } @@ -91,44 +91,44 @@ public class ItemGunPip extends ItemGunBase { int s = 1; return new BusAnimation() .addBus("RELAOD_TILT", new BusAnimationSequence() - .addKeyframePosition(-15, 0, 0, 100 * s) - .addKeyframePosition(65, 0, 0, 100 * s) //200 - .addKeyframePosition(45, 0, 0, 50 * s) //250 - .addKeyframePosition(0, 0, 0, 200 * s) //450 - .addKeyframePosition(0, 0, 0, 1450 * s) //1900 - .addKeyframePosition(-80, 0, 0, 100 * s) //2000 - .addKeyframePosition(-80, 0, 0, 100 * s) //2100 - .addKeyframePosition(0, 0, 0, 200 * s) //2300 + .addPos(-15, 0, 0, 100 * s) + .addPos(65, 0, 0, 100 * s) //200 + .addPos(45, 0, 0, 50 * s) //250 + .addPos(0, 0, 0, 200 * s) //450 + .addPos(0, 0, 0, 1450 * s) //1900 + .addPos(-80, 0, 0, 100 * s) //2000 + .addPos(-80, 0, 0, 100 * s) //2100 + .addPos(0, 0, 0, 200 * s) //2300 ) .addBus("RELOAD_CYLINDER", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 200 * s) - .addKeyframePosition(90, 0, 0, 100 * s) //300 - .addKeyframePosition(90, 0, 0, 1700 * s) //2000 - .addKeyframePosition(0, 0, 0, 70 * s) //2100 + .addPos(0, 0, 0, 200 * s) + .addPos(90, 0, 0, 100 * s) //300 + .addPos(90, 0, 0, 1700 * s) //2000 + .addPos(0, 0, 0, 70 * s) //2100 ) .addBus("RELOAD_LIFT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 350 * s) - .addKeyframePosition(-45, 0, 0, 250 * s) //600 - .addKeyframePosition(-45, 0, 0, 350 * s) //950 - .addKeyframePosition(-15, 0, 0, 200 * s) //1150 - .addKeyframePosition(-15, 0, 0, 1050 * s) //2200 - .addKeyframePosition(0, 0, 0, 100 * s) //2300 + .addPos(0, 0, 0, 350 * s) + .addPos(-45, 0, 0, 250 * s) //600 + .addPos(-45, 0, 0, 350 * s) //950 + .addPos(-15, 0, 0, 200 * s) //1150 + .addPos(-15, 0, 0, 1050 * s) //2200 + .addPos(0, 0, 0, 100 * s) //2300 ) .addBus("RELOAD_JOLT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 600 * s) - .addKeyframePosition(2, 0, 0, 50 * s) //650 - .addKeyframePosition(0, 0, 0, 100 * s) //750 + .addPos(0, 0, 0, 600 * s) + .addPos(2, 0, 0, 50 * s) //650 + .addPos(0, 0, 0, 100 * s) //750 ) .addBus("RELOAD_BULLETS", new BusAnimationSequence() - .addKeyframePosition(0, 0, 0, 650 * s) - .addKeyframePosition(10, 0, 0, 300 * s) //950 - .addKeyframePosition(10, 0, 0, 200 * s) //1150 - .addKeyframePosition(0, 0, 0, 700 * s) //1850 + .addPos(0, 0, 0, 650 * s) + .addPos(10, 0, 0, 300 * s) //950 + .addPos(10, 0, 0, 200 * s) //1150 + .addPos(0, 0, 0, 700 * s) //1850 ) .addBus("RELOAD_BULLETS_CON", new BusAnimationSequence() - .addKeyframePosition(1, 0, 0, 0 * s) - .addKeyframePosition(1, 0, 0, 950 * s) - .addKeyframePosition(0, 0, 0, 1 * s) + .addPos(1, 0, 0, 0 * s) + .addPos(1, 0, 0, 950 * s) + .addPos(0, 0, 0, 1 * s) ); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java index 9a43ef50b..b3651a976 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java +++ b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java @@ -2,7 +2,9 @@ package com.hbm.items.weapon.sedna; import java.util.ArrayList; import java.util.List; +import java.util.function.BiConsumer; +import com.hbm.entity.projectile.EntityBulletBaseMK4; import com.hbm.inventory.RecipesCommon.ComparableStack; import net.minecraft.item.Item; @@ -27,19 +29,24 @@ public class BulletConfig { public double gravity = 0; public int expires = 100; + public boolean renderRotations = true; + public BiConsumer renderer; + public BulletConfig() { this.id = configs.size(); configs.add(this); } - public BulletConfig setItem(Item ammo) { this.ammo = new ComparableStack(ammo); return this; } - public BulletConfig setReloadCount(int ammoReloadCount) { this.ammoReloadCount = ammoReloadCount; return this; } - public BulletConfig setVel(float velocity) { this.velocity = velocity; return this; } - public BulletConfig setSpread(float spread) { this.spread = spread; return this; } - public BulletConfig setWear(float wear) { this.wear = wear; return this; } - public BulletConfig setProjectiles(int min, int max) { this.projectilesMin = min; this.projectilesMax = max; return this; } - public BulletConfig setDamage(float damageMult) { this.damageMult = damageMult; return this; } - public BulletConfig setHeadshot(float headshotMult) { this.headshotMult = headshotMult; return this; } - public BulletConfig setGrav(double gravity) { this.gravity = gravity; return this; } - public BulletConfig setLife(int expires) { this.expires = expires; return this; } + public BulletConfig setItem(Item ammo) { this.ammo = new ComparableStack(ammo); return this; } + public BulletConfig setReloadCount(int ammoReloadCount) { this.ammoReloadCount = ammoReloadCount; return this; } + public BulletConfig setVel(float velocity) { this.velocity = velocity; return this; } + public BulletConfig setSpread(float spread) { this.spread = spread; return this; } + public BulletConfig setWear(float wear) { this.wear = wear; return this; } + public BulletConfig setProjectiles(int min, int max) { this.projectilesMin = min; this.projectilesMax = max; return this; } + public BulletConfig setDamage(float damageMult) { this.damageMult = damageMult; return this; } + public BulletConfig setHeadshot(float headshotMult) { this.headshotMult = headshotMult; return this; } + public BulletConfig setGrav(double gravity) { this.gravity = gravity; return this; } + public BulletConfig setLife(int expires) { this.expires = expires; return this; } + public BulletConfig setRenderRotations(boolean rot) { this.renderRotations = rot; return this; } + public BulletConfig setRenderer(BiConsumer renderer) { this.renderer = renderer; return this; } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java index 36a3e9bfa..5b6ccf842 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java +++ b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java @@ -51,6 +51,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei public ItemGunBaseNT(GunConfig cfg) { this.setMaxStackSize(1); this.config_DNA = cfg; + this.setCreativeTab(MainRegistry.weaponTab); } public static enum GunState { diff --git a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java index 7c9ad2e14..c1a6603a3 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java +++ b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java @@ -24,6 +24,9 @@ public class Receiver { public static final String B_REFIREONHOLD = "B_REFIREONHOLD"; public static final String O_EJECTOR = "O_EJECTOR"; public static final String I_RELOADDURATION = "I_RELOADDURATION"; + public static final String S_FIRESOUND = "S_FIRESOUND"; + public static final String F_FIREVOLUME = "F_FIREVOLUME"; + public static final String F_FIREPITCH = "F_FIREPITCH"; public static final String O_MAGAZINE = "O_MAGAZINE"; public static final String FUN_CANFIRE = "FUN_CANFIRE"; public static final String CON_ONFIRE = "CON_ONFIRE"; @@ -40,6 +43,9 @@ public class Receiver { protected boolean refireOnHold_DNA = false; protected CasingEjector ejector_DNA = null; protected int reloadDuration_DNA; + protected String fireSound_DNA; + protected float fireVolume_DNA = 1.0F; + protected float firePitch_DNA = 1.0F; protected IMagazine magazine_DNA; protected BiFunction canFire_DNA; protected BiConsumer onFire_DNA; @@ -52,6 +58,9 @@ public class Receiver { public boolean getRefireOnHold(ItemStack stack) { return WeaponUpgradeManager.eval(this.refireOnHold_DNA, stack, B_REFIREONHOLD, this); } public CasingEjector getEjector(ItemStack stack) { return WeaponUpgradeManager.eval(this.ejector_DNA, stack, O_EJECTOR, this); } public int getReloadDuration(ItemStack stack) { return WeaponUpgradeManager.eval(this.reloadDuration_DNA, stack, I_RELOADDURATION, this); } + public String getFireSound(ItemStack stack) { return WeaponUpgradeManager.eval(this.fireSound_DNA, stack, S_FIRESOUND, this); } + public float getFireVolume(ItemStack stack) { return WeaponUpgradeManager.eval(this.fireVolume_DNA, stack, F_FIREVOLUME, this); } + public float getFirePitch(ItemStack stack) { return WeaponUpgradeManager.eval(this.firePitch_DNA, stack, F_FIREPITCH, this); } public IMagazine getMagazine(ItemStack stack) { return WeaponUpgradeManager.eval(this.magazine_DNA, stack, O_MAGAZINE, this); } public BiFunction getCanFire(ItemStack stack) { return WeaponUpgradeManager.eval(this.canFire_DNA, stack, FUN_CANFIRE, this); } @@ -69,4 +78,11 @@ public class Receiver { public Receiver canFire(BiFunction lambda) { this.canFire_DNA = lambda; return this; } public Receiver fire(BiConsumer lambda) { this.onFire_DNA = lambda; return this; } + + public Receiver sound(String sound, float volume, float pitch) { + this.fireSound_DNA = sound; + this.fireVolume_DNA = volume; + this.firePitch_DNA = pitch; + return this; + } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/WeaponUpgradeManager.java b/src/main/java/com/hbm/items/weapon/sedna/WeaponUpgradeManager.java index 4674ee866..c54dccb21 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/WeaponUpgradeManager.java +++ b/src/main/java/com/hbm/items/weapon/sedna/WeaponUpgradeManager.java @@ -10,6 +10,9 @@ import net.minecraft.item.ItemStack; */ public class WeaponUpgradeManager { + //TODO: add caching so this doesn't have to run 15 times per single action + + public static ItemStack[] getUpgrades(ItemStack stack) { return null; // TBI } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java index 434bf5949..99140471a 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java @@ -13,23 +13,30 @@ import com.hbm.main.MainRegistry; import net.minecraft.item.Item; public class GunFactory { + + public static BulletConfig ammo_debug; public static void init() { + /// AMMO ITEMS /// ModItems.ammo_debug = new Item().setUnlocalizedName("ammo_debug").setTextureName(RefStrings.MODID + ":ammo_45"); - - BulletConfig ammo_debug = new BulletConfig().setItem(ModItems.ammo_debug).setSpread(0.01F); - + + /// BULLLET CFGS /// + ammo_debug = new BulletConfig().setItem(ModItems.ammo_debug).setSpread(0.01F); + + /// GUNS /// ModItems.gun_debug = new ItemGunBaseNT(new GunConfig() .dura(600).draw(15).crosshair(Crosshair.L_CLASSIC) .rec(new Receiver(0) - .dmg(10F).delay(12).mag(new MagazineRevolverDrum(0, 6).addConfigs(ammo_debug)) - .canFire(Lego.LAMBDA_DEBUG_CAN_FIRE).fire(Lego.LAMBDA_DEBUG_FIRE)) - .pr(Lego.LAMBDA_STANDARD_RELOAD) - .pp(Lego.LAMBDA_STANDARD_FIRE) - .pt(Lego.LAMBDA_TOGGLE_AIM) + .dmg(10F).delay(12).reload(20).sound("hbm:weapon.44Shoot", 1.0F, 1.0F) + .mag(new MagazineRevolverDrum(0, 6).addConfigs(ammo_debug)) + .canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(Lego.LAMBDA_STANDARD_FIRE)) + .pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY) .pr(Lego.LAMBDA_STANDARD_RELOAD) .pt(Lego.LAMBDA_TOGGLE_AIM) .decider(GunStateDecider.LAMBDA_STANDARD_DECIDER) .anim(Lego.LAMBDA_DEBUG_ANIMS) - ).setUnlocalizedName("gun_debug").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter"); + ).setUnlocalizedName("gun_debug").setTextureName(RefStrings.MODID + ":gun_darter"); + + /// PROXY BULLSHIT /// + MainRegistry.proxy.registerGunCfg(); } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java new file mode 100644 index 000000000..6712017ec --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java @@ -0,0 +1,75 @@ +package com.hbm.items.weapon.sedna.factory; + +import static com.hbm.items.weapon.sedna.factory.GunFactory.*; + +import java.util.function.BiConsumer; + +import org.lwjgl.opengl.GL11; + +import com.hbm.entity.projectile.EntityBulletBaseMK4; + +import net.minecraft.client.renderer.Tessellator; + +public class GunFactoryClient { + + public static void init() { + ammo_debug.setRenderer(RENDER_STANDARD_BULLET); + } + + public static BiConsumer RENDER_STANDARD_BULLET = (bullet, interp) -> { + Tessellator tess = Tessellator.instance; + double length = bullet.prevVelocity + (bullet.velocity - bullet.prevVelocity) * interp; + if(length <= 0) return; + renderBulletStandard(tess, 0xFFBF00, 0xFFFFFF, length, false); + }; + + public static BiConsumer RENDER_TRACER_BULLET = (bullet, interp) -> { + Tessellator tess = Tessellator.instance; + double length = bullet.prevVelocity + (bullet.velocity - bullet.prevVelocity) * interp; + if(length <= 0) return; + renderBulletStandard(tess, 0x9E082E, 0xFF8A79, length, true); + }; + + public static void renderBulletStandard(Tessellator tess, int dark, int light, double length, boolean fullbright) { renderBulletStandard(tess, dark, light, length, 0.03125D, 0.03125D * 0.25D, fullbright); } + + public static void renderBulletStandard(Tessellator tess, int dark, int light, double length, double widthF, double widthB, boolean fullbright) { + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glColor4f(1F, 1F, 1F, 1F); + + tess.startDrawingQuads(); + if(fullbright) tess.setBrightness(240); + tess.setNormal(0F, 1F, 0F); + tess.setColorOpaque_I(dark); + tess.addVertex(length, widthB, -widthB); tess.addVertex(length, widthB, widthB); + tess.setColorOpaque_I(light); + tess.addVertex(0, widthF, widthF); tess.addVertex(0, widthF, -widthF); + tess.setColorOpaque_I(dark); + tess.addVertex(length, -widthB, -widthB); tess.addVertex(length, -widthB, widthB); + tess.setColorOpaque_I(light); + tess.addVertex(0, -widthF, widthF); tess.addVertex(0, -widthF, -widthF); + tess.setColorOpaque_I(dark); + tess.addVertex(length, -widthB, widthB); tess.addVertex(length, widthB, widthB); + tess.setColorOpaque_I(light); + tess.addVertex(0, widthF, widthF); tess.addVertex(0, -widthF, widthF); + tess.setColorOpaque_I(dark); + tess.addVertex(length, -widthB, -widthB); tess.addVertex(length, widthB, -widthB); + tess.setColorOpaque_I(light); + tess.addVertex(0, widthF, -widthF); tess.addVertex(0, -widthF, -widthF); + tess.setColorOpaque_I(dark); + tess.addVertex(length, widthB, widthB); tess.addVertex(length, widthB, -widthB); + tess.addVertex(length, -widthB, -widthB); tess.addVertex(length, -widthB, widthB); + tess.setColorOpaque_I(light); + tess.addVertex(0, widthF, widthF); tess.addVertex(0, widthF, -widthF); + tess.addVertex(0, -widthF, -widthF); tess.addVertex(0, -widthF, widthF); + tess.draw(); + + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java index 8546cfa39..0cb990e23 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java @@ -1,5 +1,6 @@ package com.hbm.items.weapon.sedna.factory; +import java.util.Random; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -9,6 +10,7 @@ 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.Receiver; +import com.hbm.items.weapon.sedna.mags.IMagazine; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toclient.GunAnimationPacket; import com.hbm.render.anim.BusAnimation; @@ -26,24 +28,42 @@ import net.minecraft.item.ItemStack; */ public class Lego { + public static final Random ANIM_RAND = new Random(); + /** * If IDLE and the mag of receiver 0 can be loaded, set state to RELOADING. Used by keybinds. */ public static BiConsumer LAMBDA_STANDARD_RELOAD = (stack, ctx) -> { - if(ItemGunBaseNT.getState(stack) == GunState.IDLE && ctx.config.getReceivers(stack)[0].getMagazine(stack).canReload(stack, ctx.player)) { - ItemGunBaseNT.setState(stack, GunState.RELOADING); - ItemGunBaseNT.setTimer(stack, ctx.config.getReceivers(stack)[0].getReloadDuration(stack)); + EntityPlayer player = ctx.player; + Receiver rec = ctx.config.getReceivers(stack)[0]; + + if(ItemGunBaseNT.getState(stack) == GunState.IDLE) { + + ItemGunBaseNT.setIsAiming(stack, false); + + if(rec.getMagazine(stack).canReload(stack, ctx.player)) { + ItemGunBaseNT.setState(stack, GunState.RELOADING); + ItemGunBaseNT.setTimer(stack, rec.getReloadDuration(stack)); + if(player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.RELOAD.ordinal()), (EntityPlayerMP) player); + } else { + if(player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.INSPECT.ordinal()), (EntityPlayerMP) player); + } } }; /** * If IDLE and ammo is loaded, fire and set to JUST_FIRED. */ - public static BiConsumer LAMBDA_STANDARD_FIRE = (stack, ctx) -> { + public static BiConsumer LAMBDA_STANDARD_CLICK_PRIMARY = (stack, ctx) -> { - if(ItemGunBaseNT.getState(stack) == GunState.IDLE && ctx.config.getReceivers(stack)[0].getCanFire(stack).apply(stack, ctx)) { + Receiver rec = ctx.config.getReceivers(stack)[0]; + + if(ItemGunBaseNT.getState(stack) == GunState.IDLE && rec.getCanFire(stack).apply(stack, ctx)) { ItemGunBaseNT.setState(stack, GunState.COOLDOWN); - ItemGunBaseNT.setTimer(stack, ctx.config.getReceivers(stack)[0].getDelayAfterFire(stack)); - ctx.config.getReceivers(stack)[0].getOnFire(stack).accept(stack, ctx); + ItemGunBaseNT.setTimer(stack, rec.getDelayAfterFire(stack)); + rec.getOnFire(stack).accept(stack, ctx); + + int remaining = rec.getRoundsPerCycle(stack) - 1; + for(int i = 0; i < remaining; i++) if(rec.getCanFire(stack).apply(stack, ctx)) rec.getOnFire(stack).accept(stack, ctx); } }; @@ -59,18 +79,21 @@ public class Lego { /** JUMPER - bypasses mag testing and just allows constant fire */ public static BiFunction LAMBDA_DEBUG_CAN_FIRE = (stack, ctx) -> { return true; }; - /** simply plays a sound to indicate that the keybind has triggered */ - public static BiConsumer LAMBDA_DEBUG_FIRE = (stack, ctx) -> { + /** Spawns an EntityBulletBaseMK4 with the loaded bulletcfg */ + public static BiConsumer LAMBDA_STANDARD_FIRE = (stack, ctx) -> { EntityPlayer player = ctx.player; if(player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); - double sideOffset = ItemGunBaseNT.getIsAiming(stack) ? 0 : -0.2D; + double sideOffset = ItemGunBaseNT.getIsAiming(stack) ? 0 : -0.3125D; float aim = ItemGunBaseNT.getIsAiming(stack) ? 0.25F : 1F; Receiver primary = ctx.config.getReceivers(stack)[0]; + IMagazine mag = primary.getMagazine(stack); - EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(player, (BulletConfig) primary.getMagazine(stack).getType(stack), primary.getBaseDamage(stack), primary.getSpreadMod(stack) * aim, sideOffset, -0.1, 0.75); + EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(player, (BulletConfig) mag.getType(stack), primary.getBaseDamage(stack), primary.getSpreadMod(stack) * aim, sideOffset, -0.0625, 0.75); player.worldObj.spawnEntityInWorld(mk4); - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.shotgunShoot", 1F, 1F); + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, primary.getFireSound(stack), primary.getFireVolume(stack), primary.getFirePitch(stack)); + + mag.setAmount(stack, mag.getAmount(stack) - 1);; }; /** No reload, simply play inspect animation */ @@ -80,23 +103,24 @@ public class Lego { }; /** anims for the DEBUG revolver, mostly a copy of the li'lpip but with some fixes regarding the cylinder movement */ - public static BiFunction LAMBDA_DEBUG_ANIMS = (stack, type) -> { + @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_DEBUG_ANIMS = (stack, type) -> { switch(type) { - case CYCLE: - return new BusAnimation() - .addBus("RECOIL", new BusAnimationSequence().addKeyframePosition(0, 0, 0, 50).addKeyframePosition(0, 0, -3, 50).addKeyframePosition(0, 0, 0, 250)) - .addBus("HAMMER", new BusAnimationSequence().addKeyframePosition(0, 0, 1, 50).addKeyframePosition(0, 0, 1, 300 + 100).addKeyframePosition(0, 0, 0, 200)) - .addBus("DRUM", new BusAnimationSequence().addKeyframePosition(0, 0, 0, 350 + 100).addKeyframePosition(0, 0, 1, 200)); - case CYCLE_EMPTY: break; - case ALT_CYCLE: break; - case EQUIP: return new BusAnimation().addBus("ROTATE", new BusAnimationSequence().addKeyframePosition(-360, 0, 0, 350)); - case RELOAD: break; - case RELOAD_CYCLE: break; - case RELOAD_EMPTY: break; - case RELOAD_END: break; - case SPINDOWN: break; - case SPINUP: break; - case INSPECT: break; + case CYCLE: return new BusAnimation() + .addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, 0, 50).addPos(0, 0, -3, 50).addPos(0, 0, 0, 250)) + .addBus("HAMMER", new BusAnimationSequence().addPos(0, 0, 1, 50).addPos(0, 0, 1, 300 + 100).addPos(0, 0, 0, 200)) + .addBus("DRUM", new BusAnimationSequence().addPos(0, 0, 0, 350 + 100).addPos(0, 0, 1, 200)); + case EQUIP: return new BusAnimation().addBus("ROTATE", new BusAnimationSequence().addPos(-360, 0, 0, 350)); + case RELOAD: return new BusAnimation() + .addBus("RELAOD_TILT", new BusAnimationSequence().addPos(-15, 0, 0, 100).addPos(65, 0, 0, 100).addPos(45, 0, 0, 50).addPos(0, 0, 0, 200).addPos(0, 0, 0, 1450).addPos(-80, 0, 0, 100).addPos(-80, 0, 0, 100).addPos(0, 0, 0, 200)) + .addBus("RELOAD_CYLINDER", new BusAnimationSequence().addPos(0, 0, 0, 200).addPos(90, 0, 0, 100).addPos(90, 0, 0, 1700).addPos(0, 0, 0, 70)) + .addBus("RELOAD_LIFT", new BusAnimationSequence().addPos(0, 0, 0, 350).addPos(-45, 0, 0, 250).addPos(-45, 0, 0, 350).addPos(-15, 0, 0, 200).addPos(-15, 0, 0, 1050).addPos(0, 0, 0, 100)) + .addBus("RELOAD_JOLT", new BusAnimationSequence().addPos(0, 0, 0, 600).addPos(2, 0, 0, 50).addPos(0, 0, 0, 100)) + .addBus("RELOAD_BULLETS", new BusAnimationSequence().addPos(0, 0, 0, 650).addPos(10, 0, 0, 300).addPos(10, 0, 0, 200).addPos(0, 0, 0, 700)) + .addBus("RELOAD_BULLETS_CON", new BusAnimationSequence().addPos(1, 0, 0, 0).addPos(1, 0, 0, 950).addPos(0, 0, 0, 1 ) ); + case INSPECT: if(ANIM_RAND.nextBoolean()) return new BusAnimation() + .addBus("RELAOD_TILT", new BusAnimationSequence().addPos(-15, 0, 0, 100).addPos(65, 0, 0, 100).addPos(45, 0, 0, 50).addPos(0, 0, 0, 200).addPos(0, 0, 0, 1450 - 1250).addPos(-80, 0, 0, 100).addPos(-80, 0, 0, 100).addPos(0, 0, 0, 200)) + .addBus("RELOAD_CYLINDER", new BusAnimationSequence().addPos(0, 0, 0, 200).addPos(90, 0, 0, 100).addPos(90, 0, 0, 1700 - 1250).addPos(0, 0, 0, 70)); + else return new BusAnimation().addBus("ROTATE", new BusAnimationSequence().addPos(-360 * 5, 0, 0, 350 * 5)); } return null; diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java index 628d1a73d..df7990b0e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java @@ -16,6 +16,8 @@ public class MagazineRevolverDrum extends MagazineStandardBase { @Override public boolean canReload(ItemStack stack, EntityPlayer player) { + if(this.getAmount(stack) >= this.getCapacity(stack)) return false; + for(ItemStack slot : player.inventory.mainInventory) { if(slot != null) { diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index f7d519d68..98114e26c 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -86,6 +86,7 @@ import com.hbm.handler.ImpactWorldHandler; import com.hbm.handler.HbmKeybinds.EnumKeybind; import com.hbm.items.IAnimatedItem; import com.hbm.items.ModItems; +import com.hbm.items.weapon.sedna.factory.GunFactoryClient; import com.hbm.lib.RefStrings; import com.hbm.particle.*; import com.hbm.particle.helper.ExplosionCreator; @@ -170,6 +171,11 @@ public class ClientProxy extends ServerProxy { public void handleNHNEICompat(){ IMCHandlerNHNEI.IMCSender(); } + + @Override + public void registerGunCfg() { + GunFactoryClient.init(); + } @Override public void registerTileEntitySpecialRenderer() { @@ -626,6 +632,7 @@ public class ClientProxy extends ServerProxy { RenderingRegistry.registerEntityRenderingHandler(EntitySchrab.class, new RenderFlare()); RenderingRegistry.registerEntityRenderingHandler(EntityBullet.class, new RenderRocket()); RenderingRegistry.registerEntityRenderingHandler(EntityBulletBaseNT.class, new RenderBullet()); + RenderingRegistry.registerEntityRenderingHandler(EntityBulletBaseMK4.class, new RenderBulletMK4()); RenderingRegistry.registerEntityRenderingHandler(EntityRainbow.class, new RenderRainbow()); RenderingRegistry.registerEntityRenderingHandler(EntityNightmareBlast.class, new RenderOminousBullet()); RenderingRegistry.registerEntityRenderingHandler(EntityFire.class, new RenderFireball(ModItems.nothing)); @@ -1815,9 +1822,9 @@ public class ClientProxy extends ServerProxy { BusAnimation animation = new BusAnimation() .addBus("GUARD_ROT", new BusAnimationSequence() - .addKeyframePosition(90, 0, 1, 0) - .addKeyframePosition(90, 0, 1, 800) - .addKeyframePosition(0, 0, 1, 50)); + .addPos(90, 0, 1, 0) + .addPos(90, 0, 1, 800) + .addPos(0, 0, 1, 50)); HbmAnimations.hotbar[player.inventory.currentItem] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), animation); } @@ -1831,13 +1838,13 @@ public class ClientProxy extends ServerProxy { BusAnimation animation = new BusAnimation() .addBus("SWING_ROT", new BusAnimationSequence() - .addKeyframePosition(90 - offset, 90 - offset, 35, 75) - .addKeyframePosition(90 + offset, 90 - offset, -45, 150) - .addKeyframePosition(0, 0, 0, 500)) + .addPos(90 - offset, 90 - offset, 35, 75) + .addPos(90 + offset, 90 - offset, -45, 150) + .addPos(0, 0, 0, 500)) .addBus("SWING_TRANS", new BusAnimationSequence() - .addKeyframePosition(-3, 0, 0, 75) - .addKeyframePosition(8, 0, 0, 150) - .addKeyframePosition(0, 0, 0, 500)); + .addPos(-3, 0, 0, 75) + .addPos(8, 0, 0, 150) + .addPos(0, 0, 0, 500)); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("hbm:weapon.cSwing"), 0.8F + player.getRNG().nextFloat() * 0.2F)); @@ -1856,13 +1863,13 @@ public class ClientProxy extends ServerProxy { BusAnimation animation = new BusAnimation() .addBus("SWING_ROT", new BusAnimationSequence() - .addKeyframePosition(0, 0, 90, forward) - .addKeyframePosition(45, 0, 90, sideways) - .addKeyframePosition(0, 0, 0, retire)) + .addPos(0, 0, 90, forward) + .addPos(45, 0, 90, sideways) + .addPos(0, 0, 0, retire)) .addBus("SWING_TRANS", new BusAnimationSequence() - .addKeyframePosition(0, 0, 3, forward) - .addKeyframePosition(2, 0, 2, sideways) - .addKeyframePosition(0, 0, 0, retire)); + .addPos(0, 0, 3, forward) + .addPos(2, 0, 2, sideways) + .addPos(0, 0, 0, retire)); HbmAnimations.hotbar[player.inventory.currentItem] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), animation); @@ -1876,15 +1883,15 @@ public class ClientProxy extends ServerProxy { BusAnimation animation = new BusAnimation() .addBus("SWING_ROT", new BusAnimationSequence() - .addKeyframePosition(rot[0], rot[1], rot[2], 0) - .addKeyframePosition(0, 0, 90, forward) - .addKeyframePosition(45, 0, 90, sideways) - .addKeyframePosition(0, 0, 0, retire)) + .addPos(rot[0], rot[1], rot[2], 0) + .addPos(0, 0, 90, forward) + .addPos(45, 0, 90, sideways) + .addPos(0, 0, 0, retire)) .addBus("SWING_TRANS", new BusAnimationSequence() - .addKeyframePosition(trans[0], trans[1], trans[2], 0) - .addKeyframePosition(0, 0, 3, forward) - .addKeyframePosition(2, 0, 2, sideways) - .addKeyframePosition(0, 0, 0, retire)); + .addPos(trans[0], trans[1], trans[2], 0) + .addPos(0, 0, 3, forward) + .addPos(2, 0, 2, sideways) + .addPos(0, 0, 0, retire)); HbmAnimations.hotbar[player.inventory.currentItem] = new Animation(player.getHeldItem().getItem().getUnlocalizedName(), System.currentTimeMillis(), animation); } diff --git a/src/main/java/com/hbm/main/ServerProxy.java b/src/main/java/com/hbm/main/ServerProxy.java index 3e48b8e15..530bf6c59 100644 --- a/src/main/java/com/hbm/main/ServerProxy.java +++ b/src/main/java/com/hbm/main/ServerProxy.java @@ -34,6 +34,7 @@ public class ServerProxy { public void registerItemRenderer() { } public void registerEntityRenderer() { } public void registerBlockRenderer() { } + public void registerGunCfg() { } public void handleNHNEICompat() { } public void particleControl(double x, double y, double z, int type) { } diff --git a/src/main/java/com/hbm/render/anim/BusAnimationSequence.java b/src/main/java/com/hbm/render/anim/BusAnimationSequence.java index ea573fb96..00c8ab137 100644 --- a/src/main/java/com/hbm/render/anim/BusAnimationSequence.java +++ b/src/main/java/com/hbm/render/anim/BusAnimationSequence.java @@ -49,7 +49,7 @@ public class BusAnimationSequence { // Two helper methods for the old hard-coded animations - public BusAnimationSequence addKeyframePosition(double x, double y, double z, int duration) { + public BusAnimationSequence addPos(double x, double y, double z, int duration) { addKeyframe(Dimension.TX, new BusAnimationKeyframe(x, duration)); addKeyframe(Dimension.TY, new BusAnimationKeyframe(y, duration)); addKeyframe(Dimension.TZ, new BusAnimationKeyframe(z, duration)); @@ -57,7 +57,7 @@ public class BusAnimationSequence { return this; } - public BusAnimationSequence addKeyframeRotation(double x, double y, double z, int duration) { + public BusAnimationSequence addRot(double x, double y, double z, int duration) { addKeyframe(Dimension.RX, new BusAnimationKeyframe(x, duration)); addKeyframe(Dimension.RY, new BusAnimationKeyframe(y, duration)); addKeyframe(Dimension.RZ, new BusAnimationKeyframe(z, duration)); diff --git a/src/main/java/com/hbm/render/entity/projectile/RenderBulletMK4.java b/src/main/java/com/hbm/render/entity/projectile/RenderBulletMK4.java new file mode 100644 index 000000000..561a71271 --- /dev/null +++ b/src/main/java/com/hbm/render/entity/projectile/RenderBulletMK4.java @@ -0,0 +1,36 @@ +package com.hbm.render.entity.projectile; + +import org.lwjgl.opengl.GL11; + +import com.hbm.entity.projectile.EntityBulletBaseMK4; +import com.hbm.main.ResourceManager; + +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +public class RenderBulletMK4 extends Render { + + @Override + public void doRender(Entity entity, double x, double y, double z, float f0, float interp) { + EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity; + if(bullet.config == null) bullet.config = bullet.getBulletConfig(); + if(bullet.config == null) return; + + GL11.glPushMatrix(); + GL11.glTranslatef((float) x, (float) y, (float) z); + + if(bullet.config.renderRotations) { + GL11.glRotatef(bullet.prevRotationYaw + (bullet.rotationYaw - bullet.prevRotationYaw) * interp - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(bullet.prevRotationPitch + (bullet.rotationPitch - bullet.prevRotationPitch) * interp + 180, 0.0F, 0.0F, 1.0F); + } + + if(bullet.config.renderer != null) { + bullet.config.renderer.accept(bullet, interp); + } + + GL11.glPopMatrix(); + } + + @Override protected ResourceLocation getEntityTexture(Entity entity) { return ResourceManager.universal; } +} diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderDebug.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderDebug.java index 1294c7443..b6981e6f1 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderDebug.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderDebug.java @@ -30,25 +30,37 @@ public class ItemRenderDebug extends ItemRenderWeaponBase { double scale = 0.125D; GL11.glScaled(scale, scale, scale); GL11.glRotated(90, 0, 1, 0); - + double[] equipSpin = HbmAnimations.getRelevantTransformation("ROTATE"); + double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); + double[] reloadLift = HbmAnimations.getRelevantTransformation("RELOAD_LIFT"); + double[] reloadJolt = HbmAnimations.getRelevantTransformation("RELOAD_JOLT"); + double[] reloadTilt = HbmAnimations.getRelevantTransformation("RELAOD_TILT"); + double[] cylinderFlip = HbmAnimations.getRelevantTransformation("RELOAD_CYLINDER"); + double[] reloadBullets = HbmAnimations.getRelevantTransformation("RELOAD_BULLETS"); + GL11.glRotated(equipSpin[0], 0, 0, 1); - double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); standardAimingTransform(stack, 0, 0, recoil[2], -recoil[2], 0, 0); - GL11.glRotated(recoil[2] * 10, 0, 0, 1); + GL11.glRotated(reloadLift[0], 0, 0, 1); + GL11.glTranslated(reloadJolt[0], 0, 0); + GL11.glRotated(reloadTilt[0], 1, 0, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.debug_gun_tex); ResourceManager.lilmac.renderPart("Gun"); GL11.glPushMatrix(); + GL11.glRotated(cylinderFlip[0], 1, 0, 0); ResourceManager.lilmac.renderPart("Pivot"); GL11.glTranslated(0, 1.75, 0); GL11.glRotated(HbmAnimations.getRelevantTransformation("DRUM")[2] * -60, 1, 0, 0); GL11.glTranslated(0, -1.75, 0); ResourceManager.lilmac.renderPart("Cylinder"); + GL11.glTranslated(reloadBullets[0], reloadBullets[1], reloadBullets[2]); + if(HbmAnimations.getRelevantTransformation("RELOAD_BULLETS_CON")[0] != 1) ResourceManager.lilmac.renderPart("Bullets"); ResourceManager.lilmac.renderPart("Casings"); GL11.glPopMatrix();