diff --git a/src/main/java/com/hbm/crafting/WeaponRecipes.java b/src/main/java/com/hbm/crafting/WeaponRecipes.java index 1a68a8fa7..f2be25e18 100644 --- a/src/main/java/com/hbm/crafting/WeaponRecipes.java +++ b/src/main/java/com/hbm/crafting/WeaponRecipes.java @@ -9,6 +9,7 @@ import com.hbm.inventory.material.Mats; import static com.hbm.inventory.OreDictManager.*; import com.hbm.items.ItemAmmoEnums.*; +import com.hbm.items.ItemEnums.EnumCasingType; import com.hbm.items.food.ItemConserve.EnumFoodType; import com.hbm.items.machine.ItemCircuit.EnumCircuitType; import com.hbm.items.ModItems; @@ -32,6 +33,10 @@ public class WeaponRecipes { //SEDNA Parts CraftingManager.addRecipeAuto(new ItemStack(ModItems.part_stock, 1, Mats.MAT_WOOD.id), new Object[] { "WWW", " W", 'W', KEY_PLANKS }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.part_grip, 1, Mats.MAT_WOOD.id), new Object[] { "W ", " W", " W", 'W', KEY_PLANKS }); + + CraftingManager.addRecipeAuto(DictFrame.fromOne(ModItems.casing, EnumCasingType.SHOTSHELL, 2), new Object[] { "P", "C", 'P', GUNMETAL.plate(), 'C', DictFrame.fromOne(ModItems.casing, EnumCasingType.LARGE) }); + CraftingManager.addRecipeAuto(DictFrame.fromOne(ModItems.casing, EnumCasingType.BUCKSHOT, 2), new Object[] { "P", "C", 'P', ANY_PLASTIC.ingot(), 'C', DictFrame.fromOne(ModItems.casing, EnumCasingType.LARGE) }); + CraftingManager.addRecipeAuto(DictFrame.fromOne(ModItems.casing, EnumCasingType.BUCKSHOT_ADVANCED, 2), new Object[] { "P", "C", 'P', ANY_PLASTIC.ingot(), 'C', DictFrame.fromOne(ModItems.casing, EnumCasingType.LARGE_STEEL) }); //SEDNA Guns CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_pepperbox, 1), new Object[] { "IIW", " C", 'I', IRON.ingot(), 'W', KEY_PLANKS, 'C', CU.ingot() }); diff --git a/src/main/java/com/hbm/inventory/recipes/AmmoPressRecipes.java b/src/main/java/com/hbm/inventory/recipes/AmmoPressRecipes.java index a4ae668ba..cb9602261 100644 --- a/src/main/java/com/hbm/inventory/recipes/AmmoPressRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/AmmoPressRecipes.java @@ -29,6 +29,7 @@ public class AmmoPressRecipes extends SerializableRecipe { public void registerDefaults() { OreDictStack lead = new OreDictStack(PB.ingot()); + OreDictStack nugget = new OreDictStack(PB.nugget()); OreDictStack steel = new OreDictStack(STEEL.ingot()); OreDictStack wSteel = new OreDictStack(WEAPONSTEEL.ingot()); OreDictStack copper = new OreDictStack(CU.ingot()); @@ -177,6 +178,19 @@ public class AmmoPressRecipes extends SerializableRecipe { null, uranium.copy(2), null, null, smokeless.copy(6), null, null, sBig, null)); + + recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.G12_BP, 6), + null, nugget.copy(6), null, + null, smokeless, null, + null, bpShell, null)); + recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.G12_MAGNUM, 6), + null, nugget.copy(8), null, + null, smokeless, null, + null, bpShell, null)); + recipes.add(new AmmoPressRecipe(DictFrame.fromOne(ModItems.ammo_standard, EnumAmmo.G12_SLUG, 6), + null, lead, null, + null, smokeless, null, + null, bpShell, null)); } @Override 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 4fdd36eca..213a2684b 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java +++ b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java @@ -72,6 +72,7 @@ public class BulletConfig implements Cloneable { public boolean isSpectral = false; public int selfDamageDelay = 2; + public boolean blackPowder = false; public boolean renderRotations = true; public SpentCasing casing; public BiConsumer renderer; @@ -111,6 +112,7 @@ public class BulletConfig implements Cloneable { public BulletConfig setDoesPenetrate(boolean pen) { this.doesPenetrate = pen; return this; } public BulletConfig setSpectral(boolean spectral) { this.isSpectral = spectral; return this; } public BulletConfig setSelfDamageDelay(int delay) { this.selfDamageDelay = delay; return this; } + public BulletConfig setBlackPowder(boolean bp) { this.blackPowder = bp; return this; } public BulletConfig setRenderRotations(boolean rot) { this.renderRotations = rot; return this; } public BulletConfig setCasing(SpentCasing casing) { this.casing = casing; return this; } 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 70a837049..a7f9dc938 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 @@ -20,6 +20,7 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; import com.hbm.items.weapon.sedna.ItemGunBaseNT.SmokeNode; import com.hbm.items.weapon.sedna.Receiver; import com.hbm.items.weapon.sedna.mags.IMagazine; +import com.hbm.particle.helper.BlackPowderHelper; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.HbmAnimations.AnimType; @@ -221,6 +222,7 @@ public class Lego { float spread = calcSpread(ctx, stack, primary, calcWear, index, aim); EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(entity, config, damage, spread, sideOffset, heightOffset, forwardOffset); if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = entity.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack)); + if(i == 0 && config.blackPowder) BlackPowderHelper.composeEffect(entity.worldObj, mk4.posX, mk4.posY, mk4.posZ, mk4.motionX, mk4.motionY, mk4.motionZ, 10, 0.25F, 0.5F, 10, 0.25F); entity.worldObj.spawnEntityInWorld(mk4); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java index c766034e2..4b3eada23 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java @@ -50,9 +50,9 @@ public class XFactory12ga { public static void init() { - g12_bp = new BulletConfig().setItem(EnumAmmo.G12_BP).setProjectiles(8).setSpread(0.05F).setRicochetAngle(15).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP")); - g12_bp_magnum = new BulletConfig().setItem(EnumAmmo.G12_BP_MAGNUM).setProjectiles(4).setSpread(0.05F).setRicochetAngle(25).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP_MAGNUM")); - g12_bp_slug = new BulletConfig().setItem(EnumAmmo.G12_BP_SLUG).setSpread(0.01F).setRicochetAngle(5).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP_SLUG")); + g12_bp = new BulletConfig().setItem(EnumAmmo.G12_BP).setBlackPowder(true).setProjectiles(8).setSpread(0.05F).setRicochetAngle(15).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP")); + g12_bp_magnum = new BulletConfig().setItem(EnumAmmo.G12_BP_MAGNUM).setBlackPowder(true).setProjectiles(4).setSpread(0.05F).setRicochetAngle(25).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP_MAGNUM")); + g12_bp_slug = new BulletConfig().setItem(EnumAmmo.G12_BP_SLUG).setBlackPowder(true).setSpread(0.01F).setRicochetAngle(5).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(SpentCasing.COLOR_CASE_BRASS, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_BP_SLUG")); g12 = new BulletConfig().setItem(EnumAmmo.G12).setProjectiles(8).setSpread(0.05F).setRicochetAngle(15).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(0xB52B2B, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA")); g12_slug = new BulletConfig().setItem(EnumAmmo.G12_SLUG).setSpread(0.0F).setRicochetAngle(25).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(0x393939, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_SLUG")); g12_flechette = new BulletConfig().setItem(EnumAmmo.G12_FLECHETTE).setProjectiles(8).setSpread(0.025F).setRicochetAngle(5).setCasing(new SpentCasing(CasingType.SHOTGUN).setColor(0x3C80F0, SpentCasing.COLOR_CASE_BRASS).setScale(0.75F).register("12GA_FLECHETTE")); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java index 60e3182b0..3cb6a8403 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java @@ -20,10 +20,10 @@ import net.minecraft.item.ItemStack; public class XFactoryBlackPowder { - public static BulletConfig stone = new BulletConfig().setItem(EnumAmmo.STONE).setSpread(0.025F).setRicochetAngle(15); - public static BulletConfig flint = new BulletConfig().setItem(EnumAmmo.STONE_AP).setSpread(0.01F).setRicochetAngle(5).setDoesPenetrate(true).setDamage(1.75F); - public static BulletConfig iron = new BulletConfig().setItem(EnumAmmo.STONE_IRON).setSpread(0F).setRicochetAngle(90).setRicochetCount(5).setDoesPenetrate(true).setDamageFalloutByPen(false).setDamage(2F); - public static BulletConfig shot = new BulletConfig().setItem(EnumAmmo.STONE_SHOT).setSpread(0.1F).setRicochetAngle(45).setProjectiles(6, 6).setDamage(0.5F); + public static BulletConfig stone = new BulletConfig().setItem(EnumAmmo.STONE).setBlackPowder(true).setSpread(0.025F).setRicochetAngle(15); + public static BulletConfig flint = new BulletConfig().setItem(EnumAmmo.STONE_AP).setBlackPowder(true).setSpread(0.01F).setRicochetAngle(5).setDoesPenetrate(true).setDamage(1.75F); + public static BulletConfig iron = new BulletConfig().setItem(EnumAmmo.STONE_IRON).setBlackPowder(true).setSpread(0F).setRicochetAngle(90).setRicochetCount(5).setDoesPenetrate(true).setDamageFalloutByPen(false).setDamage(2F); + public static BulletConfig shot = new BulletConfig().setItem(EnumAmmo.STONE_SHOT).setBlackPowder(true).setSpread(0.1F).setRicochetAngle(45).setProjectiles(6, 6).setDamage(0.5F); public static void init() { diff --git a/src/main/java/com/hbm/particle/ParticleBlackPowderSmoke.java b/src/main/java/com/hbm/particle/ParticleBlackPowderSmoke.java new file mode 100644 index 000000000..c11b88f57 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleBlackPowderSmoke.java @@ -0,0 +1,78 @@ +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 ParticleBlackPowderSmoke extends EntityFXRotating { + + public float hue; + + public ParticleBlackPowderSmoke(World world, double x, double y, double z, float scale) { + super(world, x, y, z); + particleIcon = ModEventHandlerClient.particleBase; + this.particleMaxAge = 30 + rand.nextInt(15); + this.particleScale = scale * 0.9F + rand.nextFloat() * 0.2F; + + this.particleGravity = 0F; + + 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) * 2 * ((this.getEntityId() % 2) - 0.5); + + this.motionX *= 0.65D; + this.motionY *= 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, 0.7F, 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.25F); + tess.setNormal(0.0F, 1.0F, 0.0F); + + double scale = (0.25 + ageScaled + (this.particleAge + interp) * 0.025) * this.particleScale; + renderParticleRotated(tess, interp, sX, sY, sZ, dX, dZ, scale); + } +} diff --git a/src/main/java/com/hbm/particle/ParticleBlackPowderSpark.java b/src/main/java/com/hbm/particle/ParticleBlackPowderSpark.java new file mode 100644 index 000000000..7c0e9ea22 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleBlackPowderSpark.java @@ -0,0 +1,51 @@ +package com.hbm.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class ParticleBlackPowderSpark extends EntityFX { + + public ParticleBlackPowderSpark(World world, double x, double y, double z, double mX, double mY, double mZ) { + super(world, x, y, z, mX, mY, mZ); + + this.motionX = mX; + this.motionY = mY; + this.motionZ = mZ; + + float f = this.rand.nextFloat() * 0.1F + 0.2F; + this.particleRed = f + 0.7F; + this.particleGreen = f + 0.5F; + this.particleBlue = f; + this.setParticleTextureIndex(0); + this.setSize(0.02F, 0.02F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.5F; + this.particleMaxAge = 15 + this.rand.nextInt(5); + + this.particleGravity = 0.01F; + } + + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= particleGravity; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.95D; + this.motionY *= 0.95D; + this.motionZ *= 0.95D; + + if(this.particleMaxAge-- <= 0) { + this.setDead(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float interp) { + return 15728880; + } +} diff --git a/src/main/java/com/hbm/particle/helper/BlackPowderHelper.java b/src/main/java/com/hbm/particle/helper/BlackPowderHelper.java new file mode 100644 index 000000000..72aa720c1 --- /dev/null +++ b/src/main/java/com/hbm/particle/helper/BlackPowderHelper.java @@ -0,0 +1,67 @@ +package com.hbm.particle.helper; + +import java.util.Random; + +import com.hbm.particle.ParticleBlackPowderSmoke; +import com.hbm.particle.ParticleBlackPowderSpark; +import com.hbm.util.Vec3NT; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class BlackPowderHelper implements IParticleCreator { + + public static void composeEffect(World world, double x, double y, double z, double headingX, double headingY, double headingZ, int cloudCount, float cloudScale, float cloudSpeedMult, int sparkCount, float sparkSpeedMult) { + + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "blackPowder"); + data.setInteger("cloudCount", cloudCount); + data.setFloat("cloudScale", cloudScale); + data.setFloat("cloudSpeedMult", cloudSpeedMult); + data.setInteger("sparkCount", sparkCount); + data.setFloat("sparkSpeedMult", sparkSpeedMult); + data.setDouble("hX", headingX); + data.setDouble("hY", headingY); + data.setDouble("hZ", headingZ); + IParticleCreator.sendPacket(world, x, y, z, 200, data); + } + + @Override + @SideOnly(Side.CLIENT) + public void makeParticle(World world, EntityPlayer player, TextureManager texman, Random rand, double x, double y, double z, NBTTagCompound data) { + + double headingX = data.getDouble("hX"); + double headingY = data.getDouble("hY"); + double headingZ = data.getDouble("hZ"); + int cloudCount = data.getInteger("cloudCount"); + float cloudScale = data.getFloat("cloudScale"); + float cloudSpeedMult = data.getFloat("cloudSpeedMult"); + int sparkCount = data.getInteger("sparkCount"); + float sparkSpeedMult = data.getFloat("sparkSpeedMult"); + + Vec3NT heading = new Vec3NT(headingX, headingY, headingZ).normalizeSelf(); + + for(int i = 0; i < cloudCount; i++) { + ParticleBlackPowderSmoke particle = new ParticleBlackPowderSmoke(world, x, y, z, cloudScale); + double speedMult = 0.85 + rand.nextDouble() * 0.3; + particle.motionX = heading.xCoord * cloudSpeedMult * speedMult + rand.nextGaussian() * 0.05; + particle.motionY = heading.yCoord * cloudSpeedMult * speedMult + rand.nextGaussian() * 0.05; + particle.motionZ = heading.zCoord * cloudSpeedMult * speedMult + rand.nextGaussian() * 0.05; + Minecraft.getMinecraft().effectRenderer.addEffect(particle); + } + + for(int i = 0; i < sparkCount; i++) { + double speedMult = 0.85 + rand.nextDouble() * 0.3; + ParticleBlackPowderSpark particle = new ParticleBlackPowderSpark(world, x, y, z, + heading.xCoord * sparkSpeedMult * speedMult + rand.nextGaussian() * 0.02, + heading.yCoord * sparkSpeedMult * speedMult + rand.nextGaussian() * 0.02, + heading.zCoord * sparkSpeedMult * speedMult + rand.nextGaussian() * 0.02); + Minecraft.getMinecraft().effectRenderer.addEffect(particle); + } + } +} diff --git a/src/main/java/com/hbm/particle/helper/IParticleCreator.java b/src/main/java/com/hbm/particle/helper/IParticleCreator.java index f55ef2f05..dce577ced 100644 --- a/src/main/java/com/hbm/particle/helper/IParticleCreator.java +++ b/src/main/java/com/hbm/particle/helper/IParticleCreator.java @@ -13,6 +13,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +/** + * Does two cool things: + *
- requires no more additions to ClientProxy which is already bloated, full of other stuff and cumbersome to work with + *
- being a separate class, we can get as messy as we want without affecting other particles, so effects can overall have more logic behind them without turning into a big ugly clump + * @author hbm + * + */ public interface IParticleCreator { @SideOnly(Side.CLIENT) diff --git a/src/main/java/com/hbm/particle/helper/ParticleCreators.java b/src/main/java/com/hbm/particle/helper/ParticleCreators.java index 84df3293b..1e93ed27f 100644 --- a/src/main/java/com/hbm/particle/helper/ParticleCreators.java +++ b/src/main/java/com/hbm/particle/helper/ParticleCreators.java @@ -11,5 +11,6 @@ public class ParticleCreators { particleCreators.put("casingNT", new CasingCreator()); particleCreators.put("flamethrower", new FlameCreator()); particleCreators.put("explosionSmall", new ExplosionSmallCreator()); + particleCreators.put("blackPowder", new BlackPowderHelper()); } } diff --git a/src/main/resources/assets/hbm/sounds/block/warnAPUFire.ogg b/src/main/resources/assets/hbm/sounds/block/warnAPUFire.ogg new file mode 100644 index 000000000..5035c2109 Binary files /dev/null and b/src/main/resources/assets/hbm/sounds/block/warnAPUFire.ogg differ