grenade extras

This commit is contained in:
Boblet 2026-04-07 11:22:32 +02:00
parent 759903158b
commit 1dd3e7bbce
19 changed files with 249 additions and 41 deletions

View File

@ -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
@ -16,3 +24,6 @@
* 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
* 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

View File

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

View File

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

View File

@ -102,5 +102,4 @@ public class ItemEnumMulti extends Item {
return super.getUnlocalizedName(stack);
}
}
}

View File

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

View File

@ -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<EntityGrenadeUniversal> updateTick;
public BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> onImpact;
public Consumer<EntityGrenadeUniversal> onExplode;
private EnumGrenadeExtra(Consumer<EntityGrenadeUniversal> updateTick,
BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> onImpact,
Consumer<EntityGrenadeUniversal> onExplode) {
this.updateTick = updateTick;
this.onImpact = onImpact;
this.onExplode = onExplode;
}
}
public static BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> 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<EntityGrenadeUniversal> EXTRA_PROXY = (grenade) -> {
if(grenade.getTimer() >= 10 && grenade.getTimer() % 3 == 0) {
List<EntityLivingBase> 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<EntityGrenadeUniversal> EXTRA_FRAG = (grenade) -> {
ItemGrenadeFilling.standardFragmentation(grenade, 25);
};
public static Consumer<EntityGrenadeUniversal> 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);
}
};
}

View File

@ -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<EntityGrenadeUniversal> explode;
public Set<EnumGrenadeShell> compatibleShells = new HashSet();
@ -73,17 +75,6 @@ public class ItemGrenadeFilling extends ItemEnumMulti {
public static Consumer<EntityGrenadeUniversal> EXPLODE_HE = (grenade) -> { standardExplode(grenade, 7.5F, 25F, 10F, 0.1F); };
public static Consumer<EntityGrenadeUniversal> 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<EntityGrenadeUniversal> EXPLODE_CLUSTER = (grenade) -> {
standardExplode(grenade, 7.5F, 15F, 10F, 0.1F);
int frags = 30;
@ -134,9 +125,48 @@ public class ItemGrenadeFilling extends ItemEnumMulti {
};
public static Consumer<EntityGrenadeUniversal> 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<EntityGrenadeUniversal> 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<EntityGrenadeUniversal> 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());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, damage).setDamageClass(damageClass));
@ -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);
}
}
}

View File

@ -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<EntityGrenadeUniversal> updateTick;
public BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> onImpact;
@ -34,13 +35,21 @@ public class ItemGrenadeFuze extends ItemEnumMulti {
}
}
public static Consumer<EntityGrenadeUniversal> FUZE_3S = (grenade) -> { if(grenade.ticksInAir >= 60) grenade.explode(); };
public static Consumer<EntityGrenadeUniversal> FUZE_7S = (grenade) -> { if(grenade.ticksInAir >= 140) grenade.explode(); };
public static Consumer<EntityGrenadeUniversal> FUZE_15S = (grenade) -> { if(grenade.ticksInAir >= 300) grenade.explode(); };
public static Consumer<EntityGrenadeUniversal> FUZE_3S = (grenade) -> { if(grenade.getTimer() >= 60) grenade.explode(); };
public static Consumer<EntityGrenadeUniversal> FUZE_7S = (grenade) -> { if(grenade.getTimer() >= 140) grenade.explode(); };
public static Consumer<EntityGrenadeUniversal> FUZE_15S = (grenade) -> { if(grenade.getTimer() >= 300) grenade.explode(); };
public static BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> 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<EntityGrenadeUniversal> 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();
};
};
}

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B