better explosion particle effects, flamethrower sound loop

This commit is contained in:
Bob 2024-10-13 19:49:31 +02:00
parent 1927110709
commit 047ebfe8aa
20 changed files with 361 additions and 53 deletions

View File

@ -25,9 +25,12 @@ public class ClientConfig {
public static ConfigWrapper<Integer> GEIGER_OFFSET_HORIZONTAL = new ConfigWrapper(0);
public static ConfigWrapper<Integer> GEIGER_OFFSET_VERTICAL = new ConfigWrapper(0);
public static ConfigWrapper<Boolean> 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() {

View File

@ -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 });

View File

@ -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;
}

View File

@ -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<Entity, Float> 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<Entity, Float> 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;
}

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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<EntityPlayer, AudioWrapper> 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<ItemStack, LambdaContext> orchestra = configs[i].getOrchestra(stack);
if(orchestra != null) orchestra.accept(stack, ctx[i]);
}
}
return;
}

View File

@ -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();
}

View File

@ -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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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<ItemStack, LambdaContext> 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);

View File

@ -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<ItemStack, AnimType, BusAnimation> 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;

View File

@ -980,14 +980,6 @@ public class ClientProxy extends ServerProxy {
}
}
public static HashMap<String, IParticleCreator> 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;
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -0,0 +1,15 @@
package com.hbm.particle.helper;
import java.util.HashMap;
public class ParticleCreators {
public static HashMap<String, IParticleCreator> particleCreators = new HashMap();
static {
particleCreators.put("explosionLarge", new ExplosionCreator());
particleCreators.put("casingNT", new CasingCreator());
particleCreators.put("flamethrower", new FlameCreator());
particleCreators.put("explosionSmall", new ExplosionSmallCreator());
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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"]},