From 1dd3e7bbce3467e1c86a7478cdb9f82969eb44f7 Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 7 Apr 2026 11:22:32 +0200 Subject: [PATCH] grenade extras --- changelog | 13 ++- .../fusion/MachineFusionPlasmaForge.java | 1 + .../grenade/EntityGrenadeUniversal.java | 44 ++++++++- .../java/com/hbm/items/ItemEnumMulti.java | 1 - src/main/java/com/hbm/items/ModItems.java | 3 + .../weapon/grenade/ItemGrenadeExtra.java | 81 +++++++++++++++++ .../weapon/grenade/ItemGrenadeFilling.java | 85 +++++++++++++----- .../items/weapon/grenade/ItemGrenadeFuze.java | 19 ++-- .../weapon/grenade/ItemGrenadeShell.java | 15 ++-- .../weapon/grenade/ItemGrenadeUniversal.java | 20 ++++- src/main/java/com/hbm/util/Vec3NT.java | 8 ++ .../textures/items/grenade_fuze.airburst.png | Bin 0 -> 383 bytes .../textures/items/grenade_fuze.impact.png | Bin 0 -> 379 bytes .../hbm/textures/items/grenade_fuze.s15.png | Bin 0 -> 366 bytes .../hbm/textures/items/grenade_fuze.s3.png | Bin 0 -> 363 bytes .../hbm/textures/items/grenade_fuze.s7.png | Bin 0 -> 364 bytes .../hbm/textures/items/grenade_shell.frag.png | Bin 0 -> 245 bytes .../textures/items/grenade_shell.stick.png | Bin 0 -> 199 bytes .../hbm/textures/items/grenade_shell.tech.png | Bin 0 -> 307 bytes 19 files changed, 249 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeExtra.java create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_fuze.airburst.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_fuze.impact.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_fuze.s15.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_fuze.s3.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_fuze.s7.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_shell.frag.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_shell.stick.png create mode 100644 src/main/resources/assets/hbm/textures/items/grenade_shell.tech.png diff --git a/changelog b/changelog index 3b4999bec..f43d0be0e 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,11 @@ +## Added +* New grenades + * Universal system where there's only one grenade item + * A grenade is composed of a shell, filling and fuze, which can be mixed and matched as needed + * Instead of having dedicated grenades with impact or long timers, the desired fuze can simply be put into any grenade configuration + * Comes with proper 3D models and animations + * Grenade max stacksize has been drastically reduced (and now depends on the shell used) + ## Changed * Removed the euphemium and DNT compound plate recipes from the anvil, they are now plasma forge exclusive * More RoR integration @@ -15,4 +23,7 @@ * Fixed euphemium compound plate recipe not yielding four items as it should in the plasma forge * Fixed NTM rare item drops ignoring the mob loot gamerule * Fixed flamethrowers not properly igniting entities on direct hit, only via lingering fire -* Fixed PWR RoR components not properly showing the possible values/functions when connected to ports \ No newline at end of file +* Fixed PWR RoR components not properly showing the possible values/functions when connected to ports +* Fixed missing ports on the plasma forge +* Fixed wrong texture being bound in the crucible for the molten metal gauge +* Fixed RoR panels having no hardness at all \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionPlasmaForge.java b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionPlasmaForge.java index 7abfa15bf..5da87a630 100644 --- a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionPlasmaForge.java +++ b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionPlasmaForge.java @@ -64,6 +64,7 @@ public class MachineFusionPlasmaForge extends BlockDummyable { for(int i = -2; i <= 2; i++) { this.makeExtra(world, x + dir.offsetX * 5 + rot.offsetX * i, y, z + dir.offsetZ * 5 + rot.offsetZ * i); + this.makeExtra(world, x - dir.offsetX * 5 + rot.offsetX * i, y, z - dir.offsetZ * 5 + rot.offsetZ * i); } } } diff --git a/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java b/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java index 6d6991441..d55504ae2 100644 --- a/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java +++ b/src/main/java/com/hbm/entity/grenade/EntityGrenadeUniversal.java @@ -1,15 +1,18 @@ package com.hbm.entity.grenade; import com.hbm.entity.projectile.EntityThrowableInterp; +import com.hbm.items.weapon.grenade.ItemGrenadeExtra.EnumGrenadeExtra; 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.main.MainRegistry; import com.hbm.items.weapon.grenade.ItemGrenadeUniversal; import com.hbm.util.TrackerUtil; import com.hbm.util.Vec3NT; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraft.world.WorldServer; @@ -19,6 +22,9 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { public static final int DW_GRENADE = 3; public static final int DW_BOUNCES = 4; + public static final int DW_TRAIL = 5; + + public static final int TRAIL_TRIPLET = 1; public double prevSpin; public double spin; @@ -27,6 +33,13 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { super(world); } + public EntityGrenadeUniversal(World world, ItemStack grenade) { + super(world); + ItemStack copy = grenade.copy(); + copy.stackSize = 1; + this.dataWatcher.updateObject(DW_GRENADE, copy); + } + public EntityGrenadeUniversal(World world, EntityPlayer thrower, ItemStack grenade) { super(world); ItemStack copy = grenade.copy(); @@ -37,7 +50,9 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { this.setPosition(thrower.posX + offset.xCoord, thrower.posY + thrower.getEyeHeight() + offset.yCoord, thrower.posZ + offset.zCoord); - Vec3NT yeet = new Vec3NT(thrower.getLookVec()).normalizeSelf().multiply(1D); + 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); } @@ -47,21 +62,32 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { super.entityInit(); this.dataWatcher.addObjectByDataType(DW_GRENADE, 5); this.dataWatcher.addObject(DW_BOUNCES, new Integer(0)); + this.dataWatcher.addObject(DW_TRAIL, new Integer(0)); + } + + public EntityGrenadeUniversal setTrail(int trail) { + this.dataWatcher.updateObject(DW_TRAIL, trail); + return this; } public ItemStack getGrenadeItem() { return this.dataWatcher.getWatchableObjectItemStack(DW_GRENADE); } public int getBounces() { return this.dataWatcher.getWatchableObjectInt(DW_BOUNCES); } + public int getTrail() { return this.dataWatcher.getWatchableObjectInt(DW_TRAIL); } public EnumGrenadeShell getShell() { return ItemGrenadeUniversal.getShell(getGrenadeItem()); } public EnumGrenadeFilling getFilling() { return ItemGrenadeUniversal.getFilling(getGrenadeItem()); } public EnumGrenadeFuze getFuze() { return ItemGrenadeUniversal.getFuze(getGrenadeItem()); } + public EnumGrenadeExtra getExtra() { return ItemGrenadeUniversal.getExtra(getGrenadeItem()); } @Override public void onUpdate() { super.onUpdate(); EnumGrenadeFuze fuze = this.getFuze(); + EnumGrenadeExtra extra = this.getExtra(); + if(fuze.updateTick != null) fuze.updateTick.accept(this); + if(extra != null && extra.updateTick != null) extra.updateTick.accept(this); if(worldObj.isRemote) { this.prevSpin = this.spin; @@ -76,14 +102,26 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { this.prevSpin -= 360; this.spin -= 360; } + + if(this.getTrail() == TRAIL_TRIPLET) { + NBTTagCompound data = new NBTTagCompound(); + data.setDouble("posX", posX); + data.setDouble("posY", posY); + data.setDouble("posZ", posZ); + data.setString("type", "vanillaExt"); + data.setString("mode", "flame"); + MainRegistry.proxy.effectNT(data); + } } } @Override protected void onImpact(MovingObjectPosition mop) { EnumGrenadeFuze fuze = this.getFuze(); + EnumGrenadeExtra extra = this.getExtra(); if(fuze.onImpact != null) fuze.onImpact.accept(this, mop); + if(extra != null && extra.onImpact != null) extra.onImpact.accept(this, mop); if(this.isDead) return; // we assume the grenade has gone off by this point @@ -107,8 +145,12 @@ public class EntityGrenadeUniversal extends EntityThrowableInterp { this.setDead(); EnumGrenadeFilling filling = this.getFilling(); if(filling.explode != null) filling.explode.accept(this); + EnumGrenadeExtra extra = this.getExtra(); + if(extra != null && extra.onExplode != null) extra.onExplode.accept(this); } + public int getTimer() { return this.ticksInAir + this.ticksInGround; } + @Override protected int groundDespawn() { return 0; } @Override public boolean fullBlockCollisions() { return true; } } diff --git a/src/main/java/com/hbm/items/ItemEnumMulti.java b/src/main/java/com/hbm/items/ItemEnumMulti.java index 396fa9464..3d677b7ff 100644 --- a/src/main/java/com/hbm/items/ItemEnumMulti.java +++ b/src/main/java/com/hbm/items/ItemEnumMulti.java @@ -102,5 +102,4 @@ public class ItemEnumMulti extends Item { return super.getUnlocalizedName(stack); } } - } diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 47347e6f3..2ab2372c4 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1451,6 +1451,7 @@ public class ModItems { public static Item grenade_shell; public static Item grenade_filling; public static Item grenade_fuze; + public static Item grenade_extra; public static Item grenade_universal; @Deprecated public static Item grenade_generic; @@ -3691,6 +3692,7 @@ public class ModItems { grenade_shell = new ItemGrenadeShell().setUnlocalizedName("grenade_shell").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_shell"); grenade_filling = new ItemGrenadeFilling().setUnlocalizedName("grenade_filling").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_filling"); grenade_fuze = new ItemGrenadeFuze().setUnlocalizedName("grenade_fuze").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_fuze"); + grenade_extra = new ItemGrenadeExtra().setUnlocalizedName("grenade_extra").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_extra"); grenade_universal = new ItemGrenadeUniversal().setUnlocalizedName("grenade_universal").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_universal"); grenade_generic = new ItemGrenade(4).setUnlocalizedName("grenade_generic").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_generic"); @@ -6040,6 +6042,7 @@ public class ModItems { GameRegistry.registerItem(grenade_shell, grenade_shell.getUnlocalizedName()); GameRegistry.registerItem(grenade_filling, grenade_filling.getUnlocalizedName()); GameRegistry.registerItem(grenade_fuze, grenade_fuze.getUnlocalizedName()); + GameRegistry.registerItem(grenade_extra, grenade_extra.getUnlocalizedName()); GameRegistry.registerItem(grenade_universal, grenade_universal.getUnlocalizedName()); GameRegistry.registerItem(grenade_generic, grenade_generic.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeExtra.java b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeExtra.java new file mode 100644 index 000000000..b359e36e1 --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeExtra.java @@ -0,0 +1,81 @@ +package com.hbm.items.weapon.grenade; + +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +import com.hbm.entity.grenade.EntityGrenadeUniversal; +import com.hbm.items.ItemEnumMulti; +import com.hbm.items.weapon.grenade.ItemGrenadeFuze.EnumGrenadeFuze; +import com.hbm.util.Vec3NT; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; + +public class ItemGrenadeExtra extends ItemEnumMulti { + + public ItemGrenadeExtra() { + super(EnumGrenadeExtra.class, true, true); + } + + public static enum EnumGrenadeExtra { + GLUE(null, EXTRA_GLUE, null), // sticky bombs! + PROXY_FUZE(EXTRA_PROXY, null, null), // additional 10m EntityLivingBase triggered fuze + FRAG_SLEEVE(null, null, EXTRA_FRAG), // 25 extra frags + TRIPLEX(null, null, EXTRA_TRIPLEX); // [THE BIG ONE] + + public Consumer updateTick; + public BiConsumer onImpact; + public Consumer onExplode; + + private EnumGrenadeExtra(Consumer updateTick, + BiConsumer onImpact, + Consumer onExplode) { + this.updateTick = updateTick; + this.onImpact = onImpact; + this.onExplode = onExplode; + } + } + + public static BiConsumer EXTRA_GLUE = (grenade, mop) -> { + if(mop.typeOfHit == mop.typeOfHit.BLOCK) { + grenade.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); + grenade.getStuck(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit); + } + }; + + public static Consumer EXTRA_PROXY = (grenade) -> { + if(grenade.getTimer() >= 10 && grenade.getTimer() % 3 == 0) { + List living = grenade.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(grenade.posX, grenade.posY, grenade.posZ, grenade.posX, grenade.posY, grenade.posZ).expand(10, 10, 10)); + for(EntityLivingBase e : living) { + if(e == grenade.getThrower()) continue; + if(e.getDistanceToEntity(grenade) <= 10) { + grenade.explode(); + return; + } + } + } + }; + + public static Consumer EXTRA_FRAG = (grenade) -> { + ItemGrenadeFilling.standardFragmentation(grenade, 25); + }; + + public static Consumer EXTRA_TRIPLEX = (grenade) -> { + ItemStack frag = ItemGrenadeUniversal.make(grenade.getShell(), grenade.getFilling(), EnumGrenadeFuze.S3); + + Vec3NT vec = new Vec3NT(0.25, 0, 0).rotateAroundYDeg(grenade.worldObj.rand.nextDouble() * 360); + + for(int i = 0; i < 3; i++) { + EntityGrenadeUniversal triplet = new EntityGrenadeUniversal(grenade.worldObj, frag).setTrail(EntityGrenadeUniversal.TRAIL_TRIPLET); + triplet.setPosition(grenade.posX, grenade.posY, grenade.posZ); + triplet.motionX = vec.xCoord; + triplet.motionY = 0.75D; + triplet.motionZ = vec.zCoord; + grenade.worldObj.spawnEntityInWorld(triplet); + vec.rotateAroundYDeg(120); + } + }; +} diff --git a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFilling.java b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFilling.java index 60239b0da..43825f1f7 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFilling.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFilling.java @@ -10,17 +10,21 @@ import com.hbm.entity.grenade.EntityGrenadeUniversal; import com.hbm.entity.projectile.EntityBulletBaseMK4; import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard; +import com.hbm.explosion.vanillant.standard.BlockMutatorFire; import com.hbm.explosion.vanillant.standard.BlockProcessorStandard; import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth; import com.hbm.explosion.vanillant.standard.ExplosionEffectTiny; import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon; import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; +import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.threading.PacketThreading; import com.hbm.items.ItemEnumMulti; import com.hbm.items.weapon.grenade.ItemGrenadeShell.EnumGrenadeShell; import static com.hbm.items.weapon.grenade.ItemGrenadeShell.EnumGrenadeShell.*; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.factory.Lego; +import com.hbm.items.weapon.sedna.factory.XFactoryCatapult; +import com.hbm.main.MainRegistry; import com.hbm.main.NTMSounds; import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.util.DamageResistanceHandler.DamageClass; @@ -44,17 +48,15 @@ public class ItemGrenadeFilling extends ItemEnumMulti { } public static enum EnumGrenadeFilling { - POWDER(EXPLODE_POWDER, 0x424242, 0x939176, FRAG, STICK), // gunpowder - HE(EXPLODE_HE, 0x595533, 0xA49D62, FRAG, STICK), // high explosive - HE_FRAG(EXPLODE_FRAG, 0x595533, 0xE0BA29, FRAG, STICK), // high explosive with fragmentation - DEMO(EXPLODE_DEMO, 0x595533, 0xDD4029, FRAG, STICK), // demolition - INC(EXPLODE_INC, 0x5A5A5A, 0xFF5F21, FRAG, STICK), // incendiary - CLUSTER(EXPLODE_CLUSTER, 0x5A5A5A, 0xFFC711, FRAG, STICK), // explosive pellets - EMP(EXPLODE_EMP, 0x93A1AC, 0x00FFFF, TECH), // tesla - PLASMA(EXPLODE_PLASMA, 0x655B2C, 0x4CFF00, TECH), // EMP but more oomph - NUCLEAR(null, 0, 0, NUKE); // nuka grenade - - // and more which i haven't decided. probably plasma, EMP, perhaps laser(?) + POWDER(EXPLODE_POWDER, 0x424242, 0x939176, FRAG, STICK), // gunpowder + HE(EXPLODE_HE, 0x595533, 0xA49D62, FRAG, STICK), // high explosive + DEMO(EXPLODE_DEMO, 0x595533, 0xDD4029, FRAG, STICK), // demolition + INC(EXPLODE_INC, 0x5A5A5A, 0xFF5F21, FRAG, STICK), // incendiary + CLUSTER(EXPLODE_CLUSTER, 0x5A5A5A, 0xFFC711, FRAG, STICK, NUKE), // explosive pellets + EMP(EXPLODE_EMP, 0x93A1AC, 0x00FFFF, TECH), // tesla + PLASMA(EXPLODE_PLASMA, 0x655B2C, 0x4CFF00, TECH), // EMP but more oomph + NUCLEAR(EXPLODE_NUKE, 0, 0xA49D62, NUKE), // nuka grenade + NUCLEAR_DEMO(EXPLODE_NUKE_DEMO, 0, 0xDD4029, NUKE); // demolition nuka grenade public Consumer explode; public Set compatibleShells = new HashSet(); @@ -73,17 +75,6 @@ public class ItemGrenadeFilling extends ItemEnumMulti { public static Consumer EXPLODE_HE = (grenade) -> { standardExplode(grenade, 7.5F, 25F, 10F, 0.1F); }; - public static Consumer EXPLODE_FRAG = (grenade) -> { - standardExplode(grenade, 7.5F, 15F, 10F, 0.1F); - int frags = 50; - if(grenade.getShell() == EnumGrenadeShell.FRAG) frags *= 1.5; - for(int i = 0; i < frags; i++) { - EntityBulletBaseMK4 bullet = new EntityBulletBaseMK4(grenade.worldObj, fragmentation, 10F, 0F, grenade.worldObj.rand.nextFloat() * 2F * (float) Math.PI, (grenade.worldObj.rand.nextFloat() - 0.5F) * 2F * (float) Math.PI); - bullet.setPosition(grenade.posX, grenade.posY + 0.05, grenade.posZ); - grenade.worldObj.spawnEntityInWorld(bullet); - } - }; - public static Consumer EXPLODE_CLUSTER = (grenade) -> { standardExplode(grenade, 7.5F, 15F, 10F, 0.1F); int frags = 30; @@ -134,8 +125,47 @@ public class ItemGrenadeFilling extends ItemEnumMulti { }; public static Consumer EXPLODE_PLASMA = (grenade) -> { - explodeStandardEnergy(grenade, 50F, 5F, DamageClass.PLASMA, 0.5F, 1F, 0.5F, 4F); + explodeStandardEnergy(grenade, 50F, 5F, DamageClass.PLASMA, 0.5F, 1F, 0.5F, 4F); // TODO: unique effect because this sucks }; + + public static Consumer EXPLODE_NUKE = (grenade) -> { + ExplosionVNT vnt = new ExplosionVNT(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, 10); + vnt.setEntityProcessor(new EntityProcessorCrossSmooth(2, 100).withRangeMod(1.5F)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.explode(); + + XFactoryCatapult.incrementRad(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, 1F); + spawnMush(grenade); + }; + + public static Consumer EXPLODE_NUKE_DEMO = (grenade) -> { + ExplosionVNT vnt = new ExplosionVNT(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, 10); + vnt.setBlockAllocator(new BlockAllocatorStandard(64)); + vnt.setBlockProcessor(new BlockProcessorStandard().withBlockEffect(new BlockMutatorFire())); + vnt.setEntityProcessor(new EntityProcessorCrossSmooth(2, 50).withRangeMod(1.5F)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.explode(); + + XFactoryCatapult.incrementRad(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, 1.5F); + spawnMush(grenade); + }; + + public static void incrementRad(World world, double posX, double posY, double posZ, float mult) { + for(int i = -2; i <= 2; i++) { for(int j = -2; j <= 2; j++) { + if(Math.abs(i) + Math.abs(j) < 4) { + ChunkRadiationManager.proxy.incrementRad(world, (int) Math.floor(posX + i * 16), (int) Math.floor(posY), (int) Math.floor(posZ + j * 16), 50F / (Math.abs(i) + Math.abs(j) + 1) * mult); + } + } + } + } + + public static void spawnMush(EntityGrenadeUniversal grenade) { + grenade.worldObj.playSoundEffect(grenade.posX, grenade.posY, grenade.posZ, NTMSounds.GUN_MINI_NUKE_EXPLOSION, 15.0F, 1.0F); + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "muke"); + data.setBoolean("balefire", MainRegistry.polaroidID == 11 || grenade.worldObj.rand.nextInt(100) == 0); + PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, grenade.posX, grenade.posY + 0.5, grenade.posZ), new TargetPoint(grenade.dimension, grenade.posX, grenade.posY, grenade.posZ, 250)); + } public static void explodeStandardEnergy(EntityGrenadeUniversal grenade, float damage, float range, DamageClass damageClass, float r, float g, float b, float scale) { ExplosionVNT vnt = new ExplosionVNT(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, range, grenade.getThrower()); @@ -182,4 +212,13 @@ public class ItemGrenadeFilling extends ItemEnumMulti { vnt.setSFX(new ExplosionEffectTiny()); vnt.explode(); } + + public static void standardFragmentation(EntityGrenadeUniversal grenade, float frags) { + if(grenade.getShell() == EnumGrenadeShell.FRAG) frags *= 1.5; + for(int i = 0; i < frags; i++) { + EntityBulletBaseMK4 bullet = new EntityBulletBaseMK4(grenade.worldObj, fragmentation, 10F, 0F, grenade.worldObj.rand.nextFloat() * 2F * (float) Math.PI, (grenade.worldObj.rand.nextFloat() - 0.5F) * 2F * (float) Math.PI); + bullet.setPosition(grenade.posX, grenade.posY + 0.05, grenade.posZ); + grenade.worldObj.spawnEntityInWorld(bullet); + } + } } 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 8a93c3469..12ecdfec0 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeFuze.java @@ -5,6 +5,7 @@ import java.util.function.Consumer; import com.hbm.entity.grenade.EntityGrenadeUniversal; import com.hbm.items.ItemEnumMulti; +import com.hbm.util.Vec3NT; import net.minecraft.util.MovingObjectPosition; @@ -19,7 +20,7 @@ public class ItemGrenadeFuze extends ItemEnumMulti { S7(FUZE_7S, 0x404040), // 7s times S15(FUZE_15S, 0x808080), // 15s timed IMPACT(FUZE_IMPACT, 0xE36C17), // on block/entity impact, 0.5s safety - AIRBURST(null, null, 0xD11EB8); // still have to figure out the mechanics, whether it should be an arc angle or fixed height over the floor, 2s safety + AIRBURST(FUZE_AIRBURST, 0x56A137); // 2s safety, explodes 10 blocks above ground public Consumer updateTick; public BiConsumer onImpact; @@ -34,13 +35,21 @@ public class ItemGrenadeFuze extends ItemEnumMulti { } } - public static Consumer FUZE_3S = (grenade) -> { if(grenade.ticksInAir >= 60) grenade.explode(); }; - public static Consumer FUZE_7S = (grenade) -> { if(grenade.ticksInAir >= 140) grenade.explode(); }; - public static Consumer FUZE_15S = (grenade) -> { if(grenade.ticksInAir >= 300) grenade.explode(); }; + public static Consumer FUZE_3S = (grenade) -> { if(grenade.getTimer() >= 60) grenade.explode(); }; + public static Consumer FUZE_7S = (grenade) -> { if(grenade.getTimer() >= 140) grenade.explode(); }; + public static Consumer FUZE_15S = (grenade) -> { if(grenade.getTimer() >= 300) grenade.explode(); }; public static BiConsumer FUZE_IMPACT = (grenade, mop) -> { - if(grenade.ticksInAir >= 10) { + if(grenade.getTimer() >= 10) { grenade.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); grenade.explode(); }; }; + public static Consumer FUZE_AIRBURST = (grenade) -> { + if(grenade.getTimer() >= 40) { + 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); + if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) grenade.explode(); + }; + }; } 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 f89eb7848..527c7097a 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeShell.java @@ -10,7 +10,7 @@ public class ItemGrenadeShell extends ItemEnumMulti { * | _____ | * | | _____________ LABEL COLOR - Changes based on filling * | |_____| | - * \________/__________ FUZE INDICATOR RING - Changes based on filling + * \________/__________ FUZE INDICATOR RING - Changes based on installed fuze * \______/ * | | * | | @@ -30,23 +30,26 @@ public class ItemGrenadeShell extends ItemEnumMulti { } public static enum EnumGrenadeShell { - FRAG(4, 20, 0.5D), // bonus fragmentation - STICK(4, 20, 0.25D), // thrown farther - TECH(2, 20, 0.5D), // casing with electronics for EMP/plasma - NUKE(1, 20, 0.25D); // nuka grenade casing for high yield grenades + 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 + NUKE(1, 20, 0.25D, 1.5D); // nuka grenade casing for high yield grenades private int stackLimit; private int drawDuration; private double bounceModifier = 1D; + private double yeetForce = 1D; - private EnumGrenadeShell(int stackLimit, int drawDuration, double bounceModifier) { + private EnumGrenadeShell(int stackLimit, int drawDuration, double bounceModifier, double yeetForce) { this.stackLimit = stackLimit; this.drawDuration = drawDuration; this.bounceModifier = bounceModifier; + this.yeetForce = yeetForce; } public int getStackLimit() { return stackLimit; } public int getDrawDuration() { return drawDuration; } public double getBounce() { return bounceModifier; } + public double getYeetForce() { return yeetForce; } } } 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 955866000..4fa150262 100644 --- a/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java +++ b/src/main/java/com/hbm/items/weapon/grenade/ItemGrenadeUniversal.java @@ -7,6 +7,7 @@ import com.hbm.entity.grenade.EntityGrenadeUniversal; import com.hbm.extprop.HbmPlayerProps; import com.hbm.items.IEquipReceiver; import com.hbm.items.ModItems; +import com.hbm.items.weapon.grenade.ItemGrenadeExtra.EnumGrenadeExtra; import com.hbm.items.weapon.grenade.ItemGrenadeFilling.EnumGrenadeFilling; import com.hbm.items.weapon.grenade.ItemGrenadeFuze.EnumGrenadeFuze; import com.hbm.items.weapon.grenade.ItemGrenadeShell.EnumGrenadeShell; @@ -50,6 +51,7 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { public static final String KEY_SHELL = "shell"; public static final String KEY_FILLING = "filling"; public static final String KEY_FUZE = "fuze"; + public static final String KEY_EXTRA = "extra"; @Override public int getItemStackLimit(ItemStack stack) { @@ -114,16 +116,22 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { return EnumUtil.grabEnumSafely(EnumGrenadeFuze.class, i); } - public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze) { - return make(shell, filling, fuze, 1); + public static EnumGrenadeExtra getExtra(ItemStack stack) { + if(stack == null || !stack.hasTagCompound() || !stack.stackTagCompound.hasKey(KEY_EXTRA)) return null; + int i = stack.stackTagCompound.getInteger(KEY_EXTRA); + return EnumUtil.grabEnumSafely(EnumGrenadeExtra.class, i); } - public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze, int amount) { + public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze) { return make(shell, filling, fuze, null, 1); } + public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze, EnumGrenadeExtra extra) { return make(shell, filling, fuze, extra, 1); } + + public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze, EnumGrenadeExtra extra, int amount) { ItemStack stack = new ItemStack(ModItems.grenade_universal, amount); stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setInteger(KEY_SHELL, shell.ordinal()); stack.stackTagCompound.setInteger(KEY_FILLING, filling.ordinal()); stack.stackTagCompound.setInteger(KEY_FUZE, fuze.ordinal()); + if(extra != null) stack.stackTagCompound.setInteger(KEY_EXTRA, extra.ordinal()); return stack; } @@ -135,7 +143,9 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { if(filling.compatibleShells.contains(shell)) for(EnumGrenadeFuze fuze : EnumGrenadeFuze.values()) list.add(make(shell, filling, fuze)); } - list.add(make(EnumGrenadeShell.TECH, EnumGrenadeFilling.HE, EnumGrenadeFuze.S3)); + for(EnumGrenadeExtra extra : EnumGrenadeExtra.values()) { + list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.HE, EnumGrenadeFuze.IMPACT, extra)); + } } @SideOnly(Side.CLIENT) @@ -143,5 +153,7 @@ public class ItemGrenadeUniversal extends Item implements IEquipReceiver { list.add("item.grenade_universal.shell." + this.getShell(stack).name().toLowerCase(Locale.US)); list.add("item.grenade_universal.filling." + this.getFilling(stack).name().toLowerCase(Locale.US)); list.add("item.grenade_universal.fuze." + this.getFuze(stack).name().toLowerCase(Locale.US)); + EnumGrenadeExtra extra = this.getExtra(stack); + if(extra != null) list.add("item.grenade_universal.extra." + extra.name().toLowerCase(Locale.US)); } } diff --git a/src/main/java/com/hbm/util/Vec3NT.java b/src/main/java/com/hbm/util/Vec3NT.java index 1e6cb1294..240e08530 100644 --- a/src/main/java/com/hbm/util/Vec3NT.java +++ b/src/main/java/com/hbm/util/Vec3NT.java @@ -1,5 +1,6 @@ package com.hbm.util; +import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; @@ -13,6 +14,13 @@ public class Vec3NT extends Vec3 { super(vec.xCoord, vec.yCoord, vec.zCoord); } + public Vec3NT(Entity e) { + super(e.posX, e.posY, e.posZ); + } + + public Vec3NT eyeHeight(Entity e) { return this.add(0, e.getEyeHeight(), 0); } + public Vec3NT halfHeight(Entity e) { return this.add(0, e.height / 2D, 0); } + public Vec3NT normalizeSelf() { double len = MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); if(len < 1.0E-4D) { diff --git a/src/main/resources/assets/hbm/textures/items/grenade_fuze.airburst.png b/src/main/resources/assets/hbm/textures/items/grenade_fuze.airburst.png new file mode 100644 index 0000000000000000000000000000000000000000..b0fe5f75465b1f6b5affea14509c9d1893a786ff GIT binary patch literal 383 zcmV-_0f7FAP)$Npw53nXK=Gw z;PkiyV+;Ub7zO~~ReeT%eMSBUcAlOdq;w(WNWK-nAN*T?d z%sHw<+i|M1$e)w}!Ko;*%;|_gKD=#y^U)0AAXD})AEO!AuHNe`(J0+bj^S?`2bqHY d26_e;$2ZLYjU$#Rq0fhdEP)bdT+k@S7O=1-sSaxQZ|KERh2F|ovG2#2ZHolY+&+|$(2MG)~ zj^jKx7!3X;5ylygds<4#bUGzT5|SjrbzL0CVL0yTLj)Ig5QZV6(Fn(J^4w%Hf%f4R za)PT)gU!Q?Fbo0c_xk|6wqMBB>Nr8YBe=Y7^1*Be{JpcaLbgOT+9ud8743ULmnPq< z41mw~FJw!ct{`0~8aDzZb}!1Muoc)JSt}731?fVuU8z0!Q7}h8TIgrAA<3Jw71TSs zQw0W0tWQ#K%yI>rWm>5KfTse=iuYD@IPU50U3m&oFh{>xpxZxeX~&Ce8wGPyQ#pmR Z?FR~zfB8EZzJLG#002ovPDHLkV1mX`nx_B& literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/grenade_fuze.s15.png b/src/main/resources/assets/hbm/textures/items/grenade_fuze.s15.png new file mode 100644 index 0000000000000000000000000000000000000000..dfbcf47943fb12006e34eeac2058b14b07270074 GIT binary patch literal 366 zcmV-!0g?WRP)d$a0A((GLekldMX|~>>>IbKEY0XfIfh4W1vu9 zz`LT|DF|gnVN$fEhs487)^zPAXdvYKK7Ria0{n3~-9a43O4pQ9L{YSd85GduEX&L+ z2!ewmL>G(YTv1AqrYVFF5JJHBeK5wbSkBduz)8E|oFfcFFviR*NfN*vzJd`rn~hLj zufRD60C=7U0C;lm(QM>#fzuhm_`)GnL*;qREmpGW93vQ>_ zOHdXS#yPbT47s-j4D#Xj)mcA&SP3++eRi*9S!t27sEniDef__zZ+!QVe$5gmNdN!< M07*qoM6N<$f;8Ei!vFvP literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/grenade_fuze.s3.png b/src/main/resources/assets/hbm/textures/items/grenade_fuze.s3.png new file mode 100644 index 0000000000000000000000000000000000000000..2d7a1963d4ceb5307fcd0c2d37a14519b6b0b729 GIT binary patch literal 363 zcmV-x0hIoUP))*7dS|okwee~!D_-7;CLKud+8Z*Wa1VL}jD4+@_NmADw z$GHlj)xh;l%@{)*$BremyK6amA zEBbeXJXM%&DHJVtWEpK53|%DY8RV(L`Jh_*m4Vhj3_{3cgF4g%O)}_)TYyuRW1h0B z29-tYC{3E{n|gEKe}$K)H&Sliy93huOqWKA&UTcA1N!2(0!JN`sqG zkImzfFbn~hPNx98TF>m(`fr2lk)(e+;DhB}cvyF9jT*{kb=6>-X{-mym;v9b9RQzi zU#OuxpCC^)y*r7P`xjLvs{~Dr6g7f8)ofS#2)`gO=GQ|AaWO$Dsv2EH(Ak4cmeWsF zCqYvjjp)pqnDKr67hay;1(hZmV~TP_ZN^W>_8^9qUuZ=;H+}$MLx~Sh(n%Bm0000< KMNUMnLSTaZt(AxX literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/grenade_shell.frag.png b/src/main/resources/assets/hbm/textures/items/grenade_shell.frag.png new file mode 100644 index 0000000000000000000000000000000000000000..80be8711007a8ee3f3b1e4840db924b44082639a GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#VfBs+@{`}#2Z(o-pFnM}v0ubyd z`)P7*!-1>@f&C0^#Z#Z`+$eRR=`4e6t{hutW?|cM|9GQ4zZbP0l+XkK3h!Ou literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/items/grenade_shell.stick.png b/src/main/resources/assets/hbm/textures/items/grenade_shell.stick.png new file mode 100644 index 0000000000000000000000000000000000000000..b18424f605b485d37b600b37566364ef34f8c294 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vfua6efaXyyRBUQpK;92Zz8Ls)MD6L+MPC-}K?*hY`e@@@+c^+`F&pB|;>)HOkXK{a8ys? uCEJb2lYjo7_}TjK<@$7!p_2dt6*b>A4?od#?TPqe zY>+5?=IqPg{Fi_Hco)nTnVPvnB98f+tkt;}Ktuk&T6&eo;5H}YnsZG%ox&n#+2~I( z-|{EicxrOR?~i7OzeXRI+~Km%P$f-F;2V=A!*cOCZ*>0eulwKX7&4*#;n&~#Jk#~# z)$Vcg0Kth_uB?>>yBL-;o|qNC|G(2N#v{8JR_{M09rf?DMwWri&idwuS5KSsBt25% zSs%AAafW>@Q(M)oV@&$y=7*oJkN