diff --git a/src/main/java/com/hbm/config/ClientConfig.java b/src/main/java/com/hbm/config/ClientConfig.java index 1c852c7c8..8f040e5e5 100644 --- a/src/main/java/com/hbm/config/ClientConfig.java +++ b/src/main/java/com/hbm/config/ClientConfig.java @@ -25,9 +25,12 @@ public class ClientConfig { public static ConfigWrapper GEIGER_OFFSET_HORIZONTAL = new ConfigWrapper(0); public static ConfigWrapper GEIGER_OFFSET_VERTICAL = new ConfigWrapper(0); + public static ConfigWrapper GUN_ANIMS_LEGACY = new ConfigWrapper(false); + private static void initDefaults() { configMap.put("GEIGER_OFFSET_HORIZONTAL", GEIGER_OFFSET_HORIZONTAL); configMap.put("GEIGER_OFFSET_VERTICAL", GEIGER_OFFSET_VERTICAL); + configMap.put("GUN_ANIMS_LEGACY", GUN_ANIMS_LEGACY); } public static void initConfig() { diff --git a/src/main/java/com/hbm/crafting/WeaponRecipes.java b/src/main/java/com/hbm/crafting/WeaponRecipes.java index e62e9633a..d4c0631c7 100644 --- a/src/main/java/com/hbm/crafting/WeaponRecipes.java +++ b/src/main/java/com/hbm/crafting/WeaponRecipes.java @@ -45,6 +45,7 @@ public class WeaponRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_am180, 1), new Object[] { "BBR", "GMS", 'B', DURA.lightBarrel(), 'R', DURA.lightReceiver(), 'M', GUNMETAL.mechanism(), 'G', WOOD.grip(), 'S', WOOD.stock() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_liberator, 1), new Object[] { "BB ", "BBM", "G G", 'B', DURA.lightBarrel(), 'M', GUNMETAL.mechanism(), 'G', WOOD.grip() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_congolake, 1), new Object[] { "BM ", "BRS", "G ", 'B', DURA.heavyBarrel(), 'M', GUNMETAL.mechanism(), 'R', DURA.lightReceiver(), 'S', WOOD.stock(), 'G', WOOD.grip() }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_flamer, 1), new Object[] { " MG", "BBR", " GM", 'M', GUNMETAL.mechanism(), 'G', DURA.grip(), 'B', DURA.heavyBarrel(), 'R', DURA.heavyReceiver() }); //SEDNA Ammo CraftingManager.addRecipeAuto(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.STONE, 6), new Object[] { "C", "P", "G", 'C', KEY_COBBLESTONE, 'P', Items.paper, 'G', Items.gunpowder }); diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java index f83eeb76d..4f4704bb9 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseMK4.java @@ -165,12 +165,15 @@ public class EntityBulletBaseMK4 extends EntityThrowableInterp { if(mop.typeOfHit == mop.typeOfHit.ENTITY) { Entity entity = mop.entityHit; - if(!entity.isEntityAlive()) return; + + if(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).getHealth() <= 0) { + return; + } DamageSource damageCalc = this.config.getDamage(this, getThrower(), false); if(!(entity instanceof EntityLivingBase)) { - entity.attackEntityFrom(damageCalc, this.damage); + EntityDamageUtil.attackEntityFromIgnoreIFrame(entity, damageCalc, this.damage); return; } diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/EntityProcessorCross.java b/src/main/java/com/hbm/explosion/vanillant/standard/EntityProcessorCross.java index 15b1a06b8..a463e016c 100644 --- a/src/main/java/com/hbm/explosion/vanillant/standard/EntityProcessorCross.java +++ b/src/main/java/com/hbm/explosion/vanillant/standard/EntityProcessorCross.java @@ -2,6 +2,7 @@ package com.hbm.explosion.vanillant.standard; import java.util.HashMap; import java.util.List; +import java.util.Map.Entry; import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.interfaces.ICustomDamageHandler; @@ -59,6 +60,8 @@ public class EntityProcessorCross implements IEntityProcessor { ForgeDirection dir = ForgeDirection.getOrientation(i); nodes[i] = Vec3.createVectorHelper(x + dir.offsetX * nodeDist, y + dir.offsetY * nodeDist, z + dir.offsetZ * nodeDist); } + + HashMap damageMap = new HashMap(); for(int index = 0; index < list.size(); ++index) { @@ -89,7 +92,8 @@ public class EntityProcessorCross implements IEntityProcessor { double knockback = (1.0D - distanceScaled) * density; - entity.attackEntityFrom(setExplosionSource(explosion.compat), calculateDamage(distanceScaled, density, knockback, size)); + float dmg = calculateDamage(distanceScaled, density, knockback, size); + if(!damageMap.containsKey(entity) || damageMap.get(entity) < dmg) damageMap.put(entity, dmg); double enchKnockback = EnchantmentProtection.func_92092_a(entity, knockback); entity.motionX += deltaX * enchKnockback; @@ -99,14 +103,22 @@ public class EntityProcessorCross implements IEntityProcessor { if(entity instanceof EntityPlayer) { affectedPlayers.put((EntityPlayer) entity, Vec3.createVectorHelper(deltaX * knockback, deltaY * knockback, deltaZ * knockback)); } - - if(damage != null) { - damage.handleAttack(explosion, entity, distanceScaled); - } } } } + for(Entry entry : damageMap.entrySet()) { + + Entity entity = entry.getKey(); + entity.attackEntityFrom(setExplosionSource(explosion.compat), entry.getValue()); + System.out.println(entity + " " + entry.getValue()); + + if(damage != null) { + double distanceScaled = entity.getDistance(x, y, z) / size; + damage.handleAttack(explosion, entity, distanceScaled); + } + } + return affectedPlayers; } diff --git a/src/main/java/com/hbm/explosion/vanillant/standard/ExplosionEffectWeapon.java b/src/main/java/com/hbm/explosion/vanillant/standard/ExplosionEffectWeapon.java new file mode 100644 index 000000000..1443bb3c0 --- /dev/null +++ b/src/main/java/com/hbm/explosion/vanillant/standard/ExplosionEffectWeapon.java @@ -0,0 +1,28 @@ +package com.hbm.explosion.vanillant.standard; + +import com.hbm.explosion.vanillant.ExplosionVNT; +import com.hbm.explosion.vanillant.interfaces.IExplosionSFX; +import com.hbm.particle.helper.ExplosionSmallCreator; + +import net.minecraft.world.World; + +public class ExplosionEffectWeapon implements IExplosionSFX { + + int cloudCount; + float cloudScale; + float cloudSpeedMult; + + public ExplosionEffectWeapon(int cloudCount, float cloudScale, float cloudSpeedMult) { + this.cloudCount = cloudCount; + this.cloudScale = cloudScale; + this.cloudSpeedMult = cloudSpeedMult; + } + + @Override + public void doEffect(ExplosionVNT explosion, World world, double x, double y, double z, float size) { + if(world.isRemote) return; + + world.playSoundEffect(x, y, z, "random.explode", 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.9F); + ExplosionSmallCreator.composeEffect(world, x, y, z, cloudCount, cloudScale, cloudSpeedMult); + } +} diff --git a/src/main/java/com/hbm/inventory/material/Mats.java b/src/main/java/com/hbm/inventory/material/Mats.java index 11864a70c..797295ffc 100644 --- a/src/main/java/com/hbm/inventory/material/Mats.java +++ b/src/main/java/com/hbm/inventory/material/Mats.java @@ -136,7 +136,7 @@ public class Mats { public static final NTMMaterial MAT_STEEL = makeSmeltable(_AS + 0, STEEL, 0xAFAFAF, 0x0F0F0F, 0x4A4A4A).setShapes(DUSTTINY, BOLT, WIRE, INGOT, DUST, PLATE, CASTPLATE, WELDEDPLATE, SHELL, PIPE, BLOCK, HEAVY_COMPONENT, LIGHTBARREL, HEAVYBARREL, LIGHTRECEIVER, GRIP).m(); public static final NTMMaterial MAT_MINGRADE = makeSmeltable(_AS + 1, MINGRADE, 0xFFBA7D, 0xAF1700, 0xE44C0F).setShapes(WIRE, INGOT, DUST, BLOCK).m(); public static final NTMMaterial MAT_ALLOY = makeSmeltable(_AS + 2, ALLOY, 0xFF8330, 0x700000, 0xFF7318).setShapes(WIRE, INGOT, DUST, DENSEWIRE, PLATE, CASTPLATE, BLOCK, HEAVY_COMPONENT).m(); - public static final NTMMaterial MAT_DURA = makeSmeltable(_AS + 3, DURA, 0x183039, 0x030B0B, 0x376373).setShapes(BOLT, INGOT, DUST, PIPE, BLOCK, LIGHTBARREL, HEAVYBARREL, LIGHTRECEIVER, GRIP).m(); + public static final NTMMaterial MAT_DURA = makeSmeltable(_AS + 3, DURA, 0x183039, 0x030B0B, 0x376373).setShapes(BOLT, INGOT, DUST, PIPE, BLOCK, LIGHTBARREL, HEAVYBARREL, LIGHTRECEIVER, HEAVYRECEIVER, GRIP).m(); public static final NTMMaterial MAT_DESH = makeSmeltable(_AS + 12, DESH, 0xFF6D6D, 0x720000, 0xF22929).setShapes(INGOT, DUST, CASTPLATE, BLOCK, HEAVY_COMPONENT).m(); public static final NTMMaterial MAT_STAR = makeSmeltable(_AS + 5, STAR, 0xCCCCEA, 0x11111A, 0xA5A5D3).setShapes(INGOT, DUST, DENSEWIRE, BLOCK).m(); public static final NTMMaterial MAT_FERRO = makeSmeltable(_AS + 7, FERRO, 0xB7B7C9, 0x101022, 0x6B6B8B).setShapes(INGOT).m(); 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 1d1aff580..918a2276e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java +++ b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java @@ -1,5 +1,6 @@ package com.hbm.items.weapon.sedna; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import com.hbm.handler.CasingEjector; @@ -14,6 +15,7 @@ import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.packet.toclient.GunAnimationPacket; import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.render.util.RenderScreenOverlay; +import com.hbm.sound.AudioWrapper; import com.hbm.util.EnumUtil; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; @@ -56,6 +58,8 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei public static final String KEY_RELOAD = "reload_"; public static final String KEY_LASTANIM = "lastanim_"; public static final String KEY_ANIMTIMER = "animtimer_"; + + public static ConcurrentHashMap loopedSounds = new ConcurrentHashMap(); public static float prevAimingProgress; public static float aimingProgress; @@ -157,6 +161,11 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei for(int i = 0; i < confNo; i++) if(configs[i].getSmokeHandler(stack) != null) { configs[i].getSmokeHandler(stack).accept(stack, ctx[i]); } + + for(int i = 0; i < confNo; i++) { + BiConsumer orchestra = configs[i].getOrchestra(stack); + if(orchestra != null) orchestra.accept(stack, ctx[i]); + } } return; } 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 7a2e2b362..632048996 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 @@ -8,7 +8,7 @@ import java.util.function.BiFunction; import com.hbm.entity.projectile.EntityBulletBaseMK4; import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth; -import com.hbm.explosion.vanillant.standard.ExplosionEffectStandard; +import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon; import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.GunConfig; @@ -197,7 +197,7 @@ public class Lego { ExplosionVNT vnt = new ExplosionVNT(bullet.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, range); vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, bullet.damage)); vnt.setPlayerProcessor(new PlayerProcessorStandard()); - vnt.setSFX(new ExplosionEffectStandard()); + vnt.setSFX(new ExplosionEffectWeapon(10, 2.5F, 1F)); vnt.explode(); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index 7a6a5fe5e..d2f167c8e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -2,13 +2,16 @@ package com.hbm.items.weapon.sedna.factory; import java.util.function.BiConsumer; +import com.hbm.config.ClientConfig; import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.items.weapon.sedna.Receiver; import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; import com.hbm.items.weapon.sedna.mags.IMagazine; +import com.hbm.main.MainRegistry; import com.hbm.particle.SpentCasing; import com.hbm.particle.helper.CasingCreator; import com.hbm.render.anim.HbmAnimations.AnimType; +import com.hbm.sound.AudioWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -20,6 +23,7 @@ public class Orchestras { public static BiConsumer DEBUG_ORCHESTRA = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -51,6 +55,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_PEPPERBOX = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -76,6 +81,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_ATLAS = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -103,6 +109,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_DANI = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -130,6 +137,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_HENRY = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -166,6 +174,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_GREASEGUN = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -201,6 +210,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_MARESLEG = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -235,6 +245,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_FLAREGUN = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -263,6 +274,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_NOPIP = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -294,6 +306,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_CARBIBE = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -327,38 +340,66 @@ public class Orchestras { public static BiConsumer ORCHESTRA_AM180 = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); - if(type == AnimType.CYCLE) { - if(timer == 0) { - SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - CasingCreator.composeEffect(player.worldObj, player, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); + if(ClientConfig.GUN_ANIMS_LEGACY.get()) { + if(type == AnimType.CYCLE) { + if(timer == 0) { + SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); + CasingCreator.composeEffect(player.worldObj, player, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); + } + } + if(type == AnimType.CYCLE_DRY) { + if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + } + if(type == AnimType.RELOAD) { + if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.25F, 1F); + if(timer == 32) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 40) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + } + if(type == AnimType.JAMMED) { + if(timer == 15) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + } + if(type == AnimType.INSPECT) { + if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 35) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + } + } else { + if(type == AnimType.CYCLE) { + if(timer == 0) { + SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); + CasingCreator.composeEffect(player.worldObj, player, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); + } + } + if(type == AnimType.CYCLE_DRY) { + if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + } + if(type == AnimType.RELOAD) { + if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.25F, 1F); + if(timer == 48) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 54) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + } + if(type == AnimType.JAMMED) { + if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1.0F); + } + if(type == AnimType.INSPECT) { + if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 53) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); } - } - if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); - } - if(type == AnimType.RELOAD) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.25F, 1F); - if(timer == 48) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 54) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); - } - if(type == AnimType.JAMMED) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); - if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1.0F); - } - if(type == AnimType.INSPECT) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 53) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); } }; public static BiConsumer ORCHESTRA_LIBERATOR = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); @@ -401,6 +442,7 @@ public class Orchestras { public static BiConsumer ORCHESTRA_CONGOLAKE = (stack, ctx) -> { EntityPlayer player = ctx.player; + if(player.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -426,6 +468,33 @@ public class Orchestras { AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); + if(type == AnimType.CYCLE && player.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + + if(timer < 5) { + //start sound + if(runningAudio == null || !runningAudio.isPlaying()) { + AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10); + ItemGunBaseNT.loopedSounds.put(player, audio); + audio.startSound(); + } + //keepalive + if(runningAudio != null && runningAudio.isPlaying()) { + runningAudio.keepAlive(); + runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ); + } + } else { + //stop sound due to timeout + if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); + } + } + //stop sound due to state change + if(type != AnimType.CYCLE && player.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); + } + if(player.worldObj.isRemote) return; + if(type == AnimType.RELOAD) { if(timer == 15) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.openLatch", 1F, 1F); if(timer == 35) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.5F, 1F); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java index 1bf3fc8a4..6855837d1 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java @@ -3,6 +3,7 @@ package com.hbm.items.weapon.sedna.factory; import java.util.function.BiConsumer; import java.util.function.BiFunction; +import com.hbm.config.ClientConfig; import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.Crosshair; @@ -58,14 +59,39 @@ public class XFactory22lr { }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_AM180_ANIMS = (stack, type) -> { - switch(type) { - case EQUIP: return new BusAnimation() - .addBus("EQUIP", new BusAnimationSequence().addPos(45, 0, 0, 0).addPos(0, 0, 0, 500, IType.SIN_FULL)); - case CYCLE: return ResourceManager.am180_anim.get("Fire"); - case CYCLE_DRY: return ResourceManager.am180_anim.get("FireDry"); - case RELOAD: return ResourceManager.am180_anim.get("Reload"); - case JAMMED: return ResourceManager.am180_anim.get("Jammed"); - case INSPECT: return ResourceManager.am180_anim.get("Inspect"); + if(ClientConfig.GUN_ANIMS_LEGACY.get()) { + switch(type) { + case EQUIP: return new BusAnimation() + .addBus("EQUIP", new BusAnimationSequence().addPos(45, 0, 0, 0).addPos(0, 0, 0, 500, IType.SIN_FULL)); + case CYCLE: return new BusAnimation() + .addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, ItemGunBaseNT.getIsAiming(stack) ? -0.125 : -0.25, 15, IType.SIN_DOWN).addPos(0, 0, 0, 35, IType.SIN_FULL)); + case CYCLE_DRY: return new BusAnimation() + .addBus("BOLT", new BusAnimationSequence().addPos(0, 0, 0, 550).addPos(0, 0, -1.5, 100, IType.SIN_UP).addPos(0, 0, 0, 100, IType.SIN_UP)) + .addBus("TURN", new BusAnimationSequence().addPos(0, 0, 0, 300).addPos(0, 0, 15, 250, IType.SIN_FULL).addPos(0, 0, 15, 400).addPos(0, 0, 0, 250, IType.SIN_FULL)); + case RELOAD: + return new BusAnimation() + .addBus("MAGTURN", new BusAnimationSequence().addPos(15, 0, 0, 250, IType.SIN_FULL).addPos(15, 0, 0, 250).addPos(15, 0, 70, 300, IType.SIN_FULL).addPos(15, 0, 0, 0).addPos(15, 0, 0, 750).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("MAG", new BusAnimationSequence().addPos(0, 0, 0, 250).addPos(2, 0, -4, 250, IType.SIN_FULL).addPos(-10, 2, -4, 300, IType.SIN_UP).addPos(3, -6, -4, 0).addPos(2, 0, -4, 500, IType.SIN_FULL).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("BOLT", new BusAnimationSequence().addPos(0, 0, 0, 2250).addPos(0, 0, -1.5, 100, IType.SIN_UP).addPos(0, 0, 0, 100, IType.SIN_UP)) + .addBus("TURN", new BusAnimationSequence().addPos(0, 0, 0, 2000).addPos(0, 0, 15, 250, IType.SIN_FULL).addPos(0, 0, 15, 400).addPos(0, 0, 0, 250, IType.SIN_FULL)); + case JAMMED: return new BusAnimation() + .addBus("BOLT", new BusAnimationSequence().addPos(0, 0, 0, 750).addPos(0, 0, -1.5, 100, IType.SIN_UP).addPos(0, 0, 0, 100, IType.SIN_UP)) + .addBus("TURN", new BusAnimationSequence().addPos(0, 0, 0, 500).addPos(0, 0, 45, 250, IType.SIN_FULL).addPos(0, 0, 45, 400).addPos(0, 0, 0, 250, IType.SIN_FULL)); + case INSPECT: return new BusAnimation() + .addBus("MAGTURN", new BusAnimationSequence().addPos(15, 0, 0, 250, IType.SIN_FULL).addPos(15, 0, 0, 1400).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("MAG", new BusAnimationSequence().addPos(0, 0, 0, 200).addPos(4, -1, -4, 200, IType.SIN_FULL).addPos(4, -1.5, -4, 50).addPos(4, 0, -4, 100).addPos(4, 6, -4, 250, IType.SIN_DOWN).addPos(4, 0, -4, 150, IType.SIN_UP).addPos(4, -1, -4, 100, IType.SIN_DOWN).addPos(4, -1, -4, 250).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("MAGSPIN", new BusAnimationSequence().addPos(0, 0, 0, 600).addPos(-400, 0, 0, 500, IType.SIN_FULL).addPos(-400, 0, 0, 250).addPos(-360, 0, 0, 250)); + } + } else { + switch(type) { + case EQUIP: return new BusAnimation() + .addBus("EQUIP", new BusAnimationSequence().addPos(45, 0, 0, 0).addPos(0, 0, 0, 500, IType.SIN_FULL)); + case CYCLE: return ResourceManager.am180_anim.get("Fire"); + case CYCLE_DRY: return ResourceManager.am180_anim.get("FireDry"); + case RELOAD: return ResourceManager.am180_anim.get("Reload"); + case JAMMED: return ResourceManager.am180_anim.get("Jammed"); + case INSPECT: return ResourceManager.am180_anim.get("Inspect"); + } } return null; diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index b34266158..4732f0370 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -980,14 +980,6 @@ public class ClientProxy extends ServerProxy { } } - public static HashMap particleCreators = new HashMap(); - - static { - particleCreators.put("explosionLarge", new ExplosionCreator()); - particleCreators.put("casingNT", new CasingCreator()); - particleCreators.put("flamethrower", new FlameCreator()); - } - //mk3, only use this one @Override public void effectNT(NBTTagCompound data) { @@ -1006,8 +998,8 @@ public class ClientProxy extends ServerProxy { double y = data.getDouble("posY"); double z = data.getDouble("posZ"); - if(particleCreators.containsKey(type)) { - particleCreators.get(type).makeParticle(world, player, man, rand, x, y, z, data); + if(ParticleCreators.particleCreators.containsKey(type)) { + ParticleCreators.particleCreators.get(type).makeParticle(world, player, man, rand, x, y, z, data); return; } diff --git a/src/main/java/com/hbm/particle/EntityFXRotating.java b/src/main/java/com/hbm/particle/EntityFXRotating.java index 16dcfd7b4..0c05cd9ca 100644 --- a/src/main/java/com/hbm/particle/EntityFXRotating.java +++ b/src/main/java/com/hbm/particle/EntityFXRotating.java @@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Vec3; import net.minecraft.world.World; @SideOnly(Side.CLIENT) @@ -41,6 +42,11 @@ public class EntityFXRotating extends EntityFX { double nX = ((y2 - y1) * (z3 - z1)) - ((z2 - z1) * (y3 - y1)); double nY = ((z2 - z1) * (x3 - x1)) - ((x2 - x1) * (z3 - z1)); double nZ = ((x2 - x1) * (y3 - y1)) - ((y2 - y1) * (x3 - x1)); + + Vec3 vec = Vec3.createVectorHelper(nX, nY, nZ).normalize(); + nX = vec.xCoord; + nY = vec.yCoord; + nZ = vec.zCoord; double cosTh = Math.cos(rotation * Math.PI / 180D); double sinTh = Math.sin(rotation * Math.PI / 180D); diff --git a/src/main/java/com/hbm/particle/ParticleExplosionSmall.java b/src/main/java/com/hbm/particle/ParticleExplosionSmall.java new file mode 100644 index 000000000..18c7158bd --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleExplosionSmall.java @@ -0,0 +1,80 @@ +package com.hbm.particle; + +import java.awt.Color; + +import com.hbm.main.ModEventHandlerClient; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class ParticleExplosionSmall extends EntityFXRotating { + + public float hue; + + public ParticleExplosionSmall(World world, double x, double y, double z, float scale, float speedMult) { + super(world, x, y, z); + particleIcon = ModEventHandlerClient.particleBase; + this.particleMaxAge = 25 + rand.nextInt(10); + this.particleScale = scale * 0.9F + rand.nextFloat() * 0.2F; + + this.motionX = world.rand.nextGaussian() * speedMult; + this.motionZ = world.rand.nextGaussian() * speedMult; + + this.particleGravity = rand.nextFloat() * -0.01F; + + this.hue = 20F + rand.nextFloat() * 20F; + Color color = Color.getHSBColor(hue / 255F, 1F, 1F); + this.particleRed = color.getRed() / 255F; + this.particleGreen = color.getGreen() / 255F; + this.particleBlue = color.getBlue() / 255F; + + this.noClip = true; + } + + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.particleAge++; + + if(this.particleAge >= this.particleMaxAge) { + this.setDead(); + } + + this.motionY -= particleGravity; + this.prevRotationPitch = this.rotationPitch; + + float ageScaled = (float) this.particleAge / (float) this.particleMaxAge; + this.rotationPitch += (1 - ageScaled) * 5 * ((this.getEntityId() % 2) - 0.5); + + this.motionX *= 0.65D; + this.motionZ *= 0.65D; + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + + @Override + public void renderParticle(Tessellator tess, float interp, float sX, float sY, float sZ, float dX, float dZ) { + + double ageScaled = (double) (this.particleAge + interp) / (double) this.particleMaxAge; + + Color color = Color.getHSBColor(hue / 255F, Math.max(1F - (float) ageScaled * 2F, 0), MathHelper.clamp_float(1.25F - (float) ageScaled * 2F, hue * 0.01F - 0.1F, 1F)); + this.particleRed = color.getRed() / 255F; + this.particleGreen = color.getGreen() / 255F; + this.particleBlue = color.getBlue() / 255F; + + this.particleAlpha = (float) Math.pow(1 - Math.min(ageScaled, 1), 0.25); + + tess.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha * 0.5F); + tess.setNormal(0.0F, 1.0F, 0.0F); + + double scale = (0.25 + 1 - Math.pow(1 - ageScaled, 4) + (this.particleAge + interp) * 0.02) * this.particleScale; + renderParticleRotated(tess, interp, sX, sY, sZ, dX, dZ, scale); + } +} diff --git a/src/main/java/com/hbm/particle/ParticleFlamethrower.java b/src/main/java/com/hbm/particle/ParticleFlamethrower.java index 3cadf6f22..cc11601ba 100644 --- a/src/main/java/com/hbm/particle/ParticleFlamethrower.java +++ b/src/main/java/com/hbm/particle/ParticleFlamethrower.java @@ -62,7 +62,7 @@ public class ParticleFlamethrower extends EntityFXRotating { tess.setNormal(0.0F, 1.0F, 0.0F); tess.setBrightness(240); - double scale = (ageScaled * 0.75 + 0.5) * particleScale; + double scale = (ageScaled * 1.25 + 0.25) * particleScale; renderParticleRotated(tess, interp, sX, sY, sZ, dX, dZ, scale); } diff --git a/src/main/java/com/hbm/particle/helper/ExplosionSmallCreator.java b/src/main/java/com/hbm/particle/helper/ExplosionSmallCreator.java new file mode 100644 index 000000000..b271f80f6 --- /dev/null +++ b/src/main/java/com/hbm/particle/helper/ExplosionSmallCreator.java @@ -0,0 +1,61 @@ +package com.hbm.particle.helper; + +import java.util.Random; + +import com.hbm.particle.ParticleExplosionSmall; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityBlockDustFX; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class ExplosionSmallCreator implements IParticleCreator { + + public static void composeEffect(World world, double x, double y, double z, int cloudCount, float cloudScale, float cloudSpeedMult) { + + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "explosionSmall"); + data.setInteger("cloudCount", cloudCount); + data.setFloat("cloudScale", cloudScale); + data.setFloat("cloudSpeedMult", cloudSpeedMult); + data.setInteger("debris", 15); + IParticleCreator.sendPacket(world, x, y, z, 150, data); + } + + @Override + public void makeParticle(World world, EntityPlayer player, TextureManager texman, Random rand, double x, double y, double z, NBTTagCompound data) { + + int cloudCount = data.getInteger("cloudCount"); + float cloudScale = data.getFloat("cloudScale"); + float cloudSpeedMult = data.getFloat("cloudSpeedMult"); + int debris = data.getInteger("debris"); + + for(int i = 0; i < cloudCount; i++) { + ParticleExplosionSmall particle = new ParticleExplosionSmall(world, x, y, z, cloudScale, cloudSpeedMult); + Minecraft.getMinecraft().effectRenderer.addEffect(particle); + } + + Block b = Blocks.air; + int meta = 0; + + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + b = world.getBlock((int) Math.floor(x) + dir.offsetX, (int) Math.floor(y) + dir.offsetY, (int) Math.floor(z) + dir.offsetZ); + meta = world.getBlockMetadata((int) Math.floor(x) + dir.offsetX, (int) Math.floor(y) + dir.offsetY, (int) Math.floor(z) + dir.offsetZ); + if(b != Blocks.air) break; + } + + if(b != Blocks.air) for(int i = 0; i < debris; i++) { + EntityBlockDustFX fx = new EntityBlockDustFX(world, x, y + 0.1, z, world.rand.nextGaussian() * 0.2, 0.5F + world.rand.nextDouble() * 0.7, world.rand.nextGaussian() * 0.2, b, meta); + fx.multipleParticleScaleBy(2); + ReflectionHelper.setPrivateValue(EntityFX.class, fx, 50 + rand.nextInt(20), "particleMaxAge", "field_70547_e"); + Minecraft.getMinecraft().effectRenderer.addEffect(fx); + } + } +} diff --git a/src/main/java/com/hbm/particle/helper/ParticleCreators.java b/src/main/java/com/hbm/particle/helper/ParticleCreators.java new file mode 100644 index 000000000..84df3293b --- /dev/null +++ b/src/main/java/com/hbm/particle/helper/ParticleCreators.java @@ -0,0 +1,15 @@ +package com.hbm.particle.helper; + +import java.util.HashMap; + +public class ParticleCreators { + + public static HashMap particleCreators = new HashMap(); + + static { + particleCreators.put("explosionLarge", new ExplosionCreator()); + particleCreators.put("casingNT", new CasingCreator()); + particleCreators.put("flamethrower", new FlameCreator()); + particleCreators.put("explosionSmall", new ExplosionSmallCreator()); + } +} diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderFlamer.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderFlamer.java index 2cdf914fb..31b63e608 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderFlamer.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderFlamer.java @@ -72,7 +72,9 @@ public class ItemRenderFlamer extends ItemRenderWeaponBase { @Override public void setupThirdPerson(ItemStack stack) { super.setupThirdPerson(stack); - GL11.glTranslated(0, 1, 3); + double scale = 1.75D; + GL11.glScaled(scale, scale, scale); + GL11.glTranslated(0, -3, 4); } diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderWeaponBase.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderWeaponBase.java index 7212aa842..926ac4295 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderWeaponBase.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderWeaponBase.java @@ -213,7 +213,7 @@ public abstract class ItemRenderWeaponBase implements IItemRenderer { GL11.glRotatef(15.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(12.5F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(15.0F, 1.0F, 0.0F, 0.0F); GL11.glTranslated(3.5, 0, 0); diff --git a/src/main/resources/assets/hbm/sounds.json b/src/main/resources/assets/hbm/sounds.json index 543f67a45..39632d3cf 100644 --- a/src/main/resources/assets/hbm/sounds.json +++ b/src/main/resources/assets/hbm/sounds.json @@ -223,6 +223,7 @@ "weapon.switchmode2": {"category": "player", "sounds": [{"name": "weapon/switchmode2", "stream": false}]}, "weapon.fire.blackPowder": {"category": "player", "sounds": [{"name": "weapon/fire/blackPowder", "stream": false}]}, + "weapon.fire.flameLoop": {"category": "player", "sounds": [{"name": "weapon/fire/flameLoop", "stream": false}]}, "weapon.reload.boltClose": {"category": "player", "sounds": ["weapon/reload/boltClose"]}, "weapon.reload.boltOpen": {"category": "player", "sounds": ["weapon/reload/boltOpen"]}, diff --git a/src/main/resources/assets/hbm/sounds/weapon/fire/flameLoop.ogg b/src/main/resources/assets/hbm/sounds/weapon/fire/flameLoop.ogg new file mode 100644 index 000000000..8d2822779 Binary files /dev/null and b/src/main/resources/assets/hbm/sounds/weapon/fire/flameLoop.ogg differ