diff --git a/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java b/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java index 3eddeb922..dfadd69c0 100644 --- a/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java +++ b/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java @@ -56,9 +56,8 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { EnumGrenadeShell shell = ItemGrenadeUniversal.getShell(grenade); - Vec3NT yeet = new Vec3NT(thrower.getLookVec()).normalizeSelf().multiply(shell.getYeetForce()); - this.addVelocity(yeet.xCoord, yeet.yCoord, yeet.zCoord); - this.setThrowableHeading(yeet.xCoord, yeet.yCoord, yeet.zCoord, 1, 0); + Vec3NT yeet = new Vec3NT(thrower.getLookVec()).normalizeSelf(); + this.setThrowableHeading(yeet.xCoord, yeet.yCoord, yeet.zCoord, (float) shell.getYeetForce(), 0); } @Override diff --git a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java index 12ecdfec0..d1448f6cd 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java @@ -45,7 +45,7 @@ public class ItemGrenadeFuze extends ItemEnumMulti { }; }; public static Consumer FUZE_AIRBURST = (grenade) -> { - if(grenade.getTimer() >= 40) { + if(grenade.getTimer() >= 30) { Vec3NT start = new Vec3NT(grenade); Vec3NT end = new Vec3NT(grenade).add(0, -10, 0); MovingObjectPosition mop = grenade.worldObj.func_147447_a(start, end, false, false, true); diff --git a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java index 527c7097a..f05da1d46 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java @@ -30,9 +30,9 @@ public class ItemGrenadeShell extends ItemEnumMulti { } public static enum EnumGrenadeShell { - FRAG(4, 20, 0.5D, 1D), // bonus fragmentation - STICK(4, 20, 0.25D, 1.5D), // thrown farther - TECH(2, 20, 0.5D, 1D), // casing with electronics for EMP/plasma + FRAG(4, 30, 0.5D, 1D), // bonus fragmentation + STICK(4, 43, 0.25D, 1.5D), // thrown farther + TECH(2, 30, 0.5D, 1D), // casing with electronics for EMP/plasma NUKE(1, 20, 0.25D, 1.5D); // nuka grenade casing for high yield grenades private int stackLimit; diff --git a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java index 7aa4cfa79..dbf065e1a 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java @@ -5,6 +5,7 @@ import java.util.Locale; import com.hbm.entity.grenade.EntityGrenadeUniversal; import com.hbm.extprop.HbmPlayerProps; +import com.hbm.items.IAnimatedItem; import com.hbm.items.IEquipReceiver; import com.hbm.items.ModItems; import com.hbm.items.weapon.grenade.ItemGrenadeExtra.EnumGrenadeExtra; @@ -12,6 +13,13 @@ import com.hbm.items.weapon.grenade.ItemGrenadeFilling.EnumGrenadeFilling; import com.hbm.items.weapon.grenade.ItemGrenadeFuze.EnumGrenadeFuze; import com.hbm.items.weapon.grenade.ItemGrenadeShell.EnumGrenadeShell; import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.main.NTMSounds; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.toclient.HbmAnimationPacket; +import com.hbm.render.anim.AnimationEnums.GunAnimation; +import com.hbm.render.anim.BusAnimationKeyframe.IType; +import com.hbm.render.anim.BusAnimation; +import com.hbm.render.anim.BusAnimationSequence; import com.hbm.util.EnumUtil; import cpw.mods.fml.relauncher.Side; @@ -20,12 +28,13 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class ItemGrenadeUniversal extends Item implements IEquipReceiver { +public class ItemGrenadeUniversal extends Item implements IEquipReceiver, IAnimatedItem { /* * __________ @@ -61,6 +70,10 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { @Override public void onEquip(EntityPlayer player, ItemStack stack) { HbmPlayerProps.getData(player).grenadeDeployment = 0; + + if(player instanceof EntityPlayerMP) { + PacketDispatcher.wrapper.sendTo(new HbmAnimationPacket(GunAnimation.EQUIP.ordinal(), 0), (EntityPlayerMP) player); + } } @Override @@ -72,7 +85,7 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { EntityGrenadeUniversal grenade = new EntityGrenadeUniversal(world, player, stack); world.spawnEntityInWorld(grenade); } - stack.stackSize--; + if(!player.capabilities.isCreativeMode) stack.stackSize--; if(stack.stackSize > 0) this.onEquip(player, stack); } @@ -92,6 +105,18 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { this.onEquip(player, stack); } else if(isHeld) { HbmPlayerProps.getData(player).grenadeDeployment++; + int deployment = HbmPlayerProps.getData(player).grenadeDeployment; + EnumGrenadeShell shell = this.getShell(stack); + if(shell == EnumGrenadeShell.FRAG && deployment == 18) { + world.playSoundAtEntity(player, NTMSounds.GUN_REVOLVER_COCK, 1F, 1F); + } + if(shell == EnumGrenadeShell.STICK) { + if(deployment == 16) world.playSoundAtEntity(player, NTMSounds.GUN_BOLT_OPEN, 1F, 1.25F); + if(deployment == 25) world.playSoundAtEntity(player, NTMSounds.GUN_BOLT_OPEN, 1F, 1.25F); + } + if(shell == EnumGrenadeShell.TECH && deployment == 18) { + world.playSoundAtEntity(player, NTMSounds.GRENADE_TECH, 1F, 1F); + } } } @@ -156,4 +181,42 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { EnumGrenadeExtra extra = this.getExtra(stack); if(extra != null) list.add("item.grenade_universal.extra." + extra.name().toLowerCase(Locale.US)); } + + @Override + public BusAnimation getAnimation(Enum type, ItemStack stack) { + if(type != GunAnimation.EQUIP) return null; + EnumGrenadeShell shell = this.getShell(stack); + + if(shell == EnumGrenadeShell.FRAG) { + return new BusAnimation() + .addBus("BODYMOVE", new BusAnimationSequence().setPos(0, -5, 0).addPos(0, -3, 0, 350).addPos(0, 0, 0, 350, IType.SIN_DOWN)) + .addBus("BODYTURN", new BusAnimationSequence().addPos(0, 0, 45, 350).addPos(0, 0, -15, 350, IType.SIN_DOWN).hold(200).addPos(0, 0, -20, 100, IType.SIN_DOWN).addPos(0, 0, 0, 500, IType.SIN_FULL)) + .addBus("RINGMOVE", new BusAnimationSequence().hold(900).addPos(0, 0, 1, 150).addPos(0, -3, 3, 300)) + .addBus("RINGTURN", new BusAnimationSequence().hold(900).addPos(0, 0, 45, 300)) + .addBus("RENDERRING", new BusAnimationSequence().setPos(1, 1, 1).hold(1350).setPos(0, 0, 0)); + } + + if(shell == EnumGrenadeShell.STICK) { + return new BusAnimation() + .addBus("BODYMOVE", new BusAnimationSequence().setPos(0, -7, 0).addPos(0, 3, 0, 750, IType.SIN_DOWN).holdUntil(1900).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("BODYTURN", new BusAnimationSequence().setPos(0, 0, 90).addPos(0, 0, -45, 750, IType.SIN_DOWN).holdUntil(1900).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("CAPMOVE", new BusAnimationSequence().hold(800).addPos(0, -0.25, 0, 200, IType.SIN_FULL).hold(250).addPos(0, -0.5, 0, 200, IType.SIN_FULL).addPos(2, -5, 0, 350, IType.SIN_UP)) + .addBus("CAPTURN", new BusAnimationSequence().hold(800).addPos(0, 360, 0, 200, IType.SIN_FULL).hold(250).addPos(0, 360 * 2, 0, 200, IType.SIN_FULL)) + .addBus("RENDERCAP", new BusAnimationSequence().setPos(1, 1, 1).hold(2100).setPos(0, 0, 0)); + } + + if(shell == EnumGrenadeShell.TECH) { + return new BusAnimation() + .addBus("BODYMOVE", new BusAnimationSequence().setPos(0, -5, 0).addPos(0, -3, 0, 350).addPos(0, 0, 0, 350, IType.SIN_DOWN)) + .addBus("BODYTURN", new BusAnimationSequence().addPos(0, 0, 45, 350).addPos(0, 0, -15, 350, IType.SIN_DOWN).hold(200).addPos(0, 0, -20, 100, IType.SIN_DOWN).addPos(0, 0, 0, 500, IType.SIN_FULL)) + .addBus("RINGMOVE", new BusAnimationSequence().hold(900).addPos(0, 0, 1, 150).addPos(0, -3, 3, 300)) + .addBus("RINGTURN", new BusAnimationSequence().hold(900).addPos(0, 0, 45, 300)) + .addBus("RENDERRING", new BusAnimationSequence().setPos(1, 1, 1).hold(1350).setPos(0, 0, 0)); + } + + return null; + } + + @Override public boolean shouldPlayerModelAim(ItemStack stack) { return false; } + @Override public Class getEnum() { return GunAnimation.class; } } diff --git a/src/main/java/com/hbm/main/NTMSounds.java b/src/main/java/com/hbm/main/NTMSounds.java index f18c91761..995273d7a 100644 --- a/src/main/java/com/hbm/main/NTMSounds.java +++ b/src/main/java/com/hbm/main/NTMSounds.java @@ -34,6 +34,7 @@ public class NTMSounds { public static final String GUN_LATCH_OPEN = "hbm:weapon.reload.openLatch"; public static final String GUN_VALVE = "hbm:weapon.reload.pressureValve"; public static final String GUN_FATMAN_RELOAD = "hbm:weapon.reload.fatmanFull"; + public static final String GRENADE_TECH = "hbm:weapon.reload.grenadeTech"; /// FOLEY /// public static final String GUN_WHACK = "hbm:weapon.foley.gunWhack"; diff --git a/src/main/java/com/hbm/render/item/ItemRenderGrenade.java b/src/main/java/com/hbm/render/item/ItemRenderGrenade.java index 51ccc340e..beab5be6e 100644 --- a/src/main/java/com/hbm/render/item/ItemRenderGrenade.java +++ b/src/main/java/com/hbm/render/item/ItemRenderGrenade.java @@ -8,6 +8,7 @@ import org.lwjgl.opengl.GL11; import com.hbm.items.weapon.grenade.ItemGrenadeUniversal; import com.hbm.main.ResourceManager; +import com.hbm.render.anim.HbmAnimations; import com.hbm.render.tileentity.RenderArcFurnace; import com.hbm.util.ColorUtil; @@ -79,25 +80,63 @@ public class ItemRenderGrenade implements IItemRenderer { GL11.glRotated(180, 0, -1, 0); if(shell == EnumGrenadeShell.FRAG) { + double[] bodyMove = HbmAnimations.getRelevantTransformation("BODYMOVE"); + double[] bodyTurn = HbmAnimations.getRelevantTransformation("BODYTURN"); + double[] ringMove = HbmAnimations.getRelevantTransformation("RINGMOVE"); + double[] ringTurn = HbmAnimations.getRelevantTransformation("RINGTURN"); + double[] renderRing = HbmAnimations.getRelevantTransformation("RENDERRING"); + GL11.glTranslated(bodyMove[0], bodyMove[1], bodyMove[2]); + GL11.glRotated(bodyTurn[2], 1, 0, 0); renderFragBody(stack); Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.grenade_frag_tex); ResourceManager.grenades.renderPart("FragSpoon"); - ResourceManager.grenades.renderPart("FragRing"); + if(renderRing[0] != 0) { + GL11.glTranslated(ringMove[0], ringMove[1], ringMove[2]); + GL11.glRotated(ringTurn[2], 1, 0, 0); + ResourceManager.grenades.renderPart("FragRing"); + } } if(shell == EnumGrenadeShell.STICK) { + double[] bodyMove = HbmAnimations.getRelevantTransformation("BODYMOVE"); + double[] bodyTurn = HbmAnimations.getRelevantTransformation("BODYTURN"); + double[] capMove = HbmAnimations.getRelevantTransformation("CAPMOVE"); + double[] capTurn = HbmAnimations.getRelevantTransformation("CAPTURN"); + double[] renderCap = HbmAnimations.getRelevantTransformation("RENDERCAP"); + GL11.glTranslated(bodyMove[0], bodyMove[1], bodyMove[2]); + GL11.glRotated(bodyTurn[2], 0, 0, 1); renderStickBody(stack); - EnumGrenadeFilling filling = ItemGrenadeUniversal.getFilling(stack); - GL11.glColor3f(ColorUtil.fr(filling.bodyColor), ColorUtil.fg(filling.bodyColor), ColorUtil.fb(filling.bodyColor)); - bind(ResourceManager.grenade_stick_body_tex); - ResourceManager.grenades.renderPart("StickCap"); - GL11.glColor3f(1F, 1F, 1F); + if(renderCap[0] != 0) { + GL11.glTranslated(capMove[0], capMove[1], capMove[2]); + GL11.glRotated(capTurn[1], 0, 1, 0); + EnumGrenadeFilling filling = ItemGrenadeUniversal.getFilling(stack); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + bind(ResourceManager.grenade_stick_tex); + ResourceManager.grenades.renderPart("StickCap"); + GL11.glColor3f(ColorUtil.fr(filling.bodyColor), ColorUtil.fg(filling.bodyColor), ColorUtil.fb(filling.bodyColor)); + bind(ResourceManager.grenade_stick_body_tex); + ResourceManager.grenades.renderPart("StickCap"); + GL11.glColor3f(1F, 1F, 1F); + GL11.glDisable(GL11.GL_BLEND); + } } if(shell == EnumGrenadeShell.TECH) { + double[] bodyMove = HbmAnimations.getRelevantTransformation("BODYMOVE"); + double[] bodyTurn = HbmAnimations.getRelevantTransformation("BODYTURN"); + double[] ringMove = HbmAnimations.getRelevantTransformation("RINGMOVE"); + double[] ringTurn = HbmAnimations.getRelevantTransformation("RINGTURN"); + double[] renderRing = HbmAnimations.getRelevantTransformation("RENDERRING"); + GL11.glTranslated(bodyMove[0], bodyMove[1], bodyMove[2]); + GL11.glRotated(bodyTurn[2], 1, 0, 0); renderTechBody(stack); - Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.grenade_tech_tex); - ResourceManager.grenades.renderPart("TechRing"); + if(renderRing[0] != 0) { + GL11.glTranslated(ringMove[0], ringMove[1], ringMove[2]); + GL11.glRotated(ringTurn[2], 1, 0, 0); + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.grenade_tech_tex); + ResourceManager.grenades.renderPart("TechRing"); + } } if(shell == EnumGrenadeShell.NUKE) { diff --git a/src/main/resources/assets/hbm/sounds.json b/src/main/resources/assets/hbm/sounds.json index c536953dd..c9c2ab6c5 100644 --- a/src/main/resources/assets/hbm/sounds.json +++ b/src/main/resources/assets/hbm/sounds.json @@ -294,6 +294,7 @@ "weapon.reload.impact": {"category": "player", "sounds": ["weapon/reload/impact1", "weapon/reload/impact2", "weapon/reload/impact3"]}, "weapon.reload.fatmanFull": {"category": "player", "sounds": ["weapon/reload/fatmanFull"]}, "weapon.reload.screw": {"category": "player", "sounds": ["weapon/reload/screw"]}, + "weapon.reload.grenadeTech": {"category": "player", "sounds": ["weapon/reload/grenadeTech"]}, "weapon.foley.gunWhack": {"category": "player", "sounds": ["weapon/foley/gunWhack", "weapon/foley/gunWhack2"]}, diff --git a/src/main/resources/assets/hbm/sounds/weapon/reload/grenadeTech.ogg b/src/main/resources/assets/hbm/sounds/weapon/reload/grenadeTech.ogg new file mode 100644 index 000000000..e391388b8 Binary files /dev/null and b/src/main/resources/assets/hbm/sounds/weapon/reload/grenadeTech.ogg differ