mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
fire in the hole (there is hot sauce in my rectum)
This commit is contained in:
parent
dd96b6d48b
commit
192fac228d
@ -0,0 +1,67 @@
|
|||||||
|
package com.hbm.entity.grenade;
|
||||||
|
|
||||||
|
import com.hbm.entity.projectile.EntityThrowableInterp;
|
||||||
|
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.grenade.ItemGrenadeUniversal;
|
||||||
|
import com.hbm.util.Vec3NT;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class EntityGrenadeUniversal extends EntityThrowableInterp {
|
||||||
|
|
||||||
|
public static final int DW_GRENADE = 3;
|
||||||
|
|
||||||
|
public EntityGrenadeUniversal(World world) {
|
||||||
|
super(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityGrenadeUniversal(World world, EntityPlayer thrower, ItemStack grenade) {
|
||||||
|
super(world);
|
||||||
|
ItemStack copy = grenade.copy();
|
||||||
|
copy.stackSize = 1;
|
||||||
|
this.dataWatcher.addObject(DW_GRENADE, copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getGrenadeItem() {
|
||||||
|
return this.dataWatcher.getWatchableObjectItemStack(DW_GRENADE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumGrenadeShell getShell() { return ItemGrenadeUniversal.getShell(getGrenadeItem()); }
|
||||||
|
public EnumGrenadeFilling getFilling() { return ItemGrenadeUniversal.getFilling(getGrenadeItem()); }
|
||||||
|
public EnumGrenadeFuze getFuze() { return ItemGrenadeUniversal.getFuze(getGrenadeItem()); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate() {
|
||||||
|
super.onUpdate();
|
||||||
|
|
||||||
|
EnumGrenadeFuze fuze = this.getFuze();
|
||||||
|
if(fuze.updateTick != null) fuze.updateTick.accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onImpact(MovingObjectPosition mop) {
|
||||||
|
EnumGrenadeFuze fuze = this.getFuze();
|
||||||
|
|
||||||
|
if(fuze.onImpact != null) fuze.onImpact.accept(this, mop);
|
||||||
|
|
||||||
|
if(this.isDead) return; // we assume the grenade has gone off by this point
|
||||||
|
|
||||||
|
if(mop.typeOfHit == mop.typeOfHit.BLOCK) {
|
||||||
|
EnumGrenadeShell shell = this.getShell();
|
||||||
|
Vec3NT vec = new Vec3NT(this.motionX, this.motionY, this.motionZ);
|
||||||
|
if(vec.lengthVector() > 0.5) {
|
||||||
|
// TODO play bounce sound
|
||||||
|
}
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit);
|
||||||
|
if(dir.offsetX != 0) this.motionX *= -shell.getBounce();
|
||||||
|
if(dir.offsetY != 0) this.motionY *= -shell.getBounce();
|
||||||
|
if(dir.offsetZ != 0) this.motionZ *= -shell.getBounce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -312,6 +312,8 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
|
|||||||
nbt.setByte("inTile", (byte) Block.getIdFromBlock(this.stuckBlock));
|
nbt.setByte("inTile", (byte) Block.getIdFromBlock(this.stuckBlock));
|
||||||
nbt.setByte("shake", (byte) this.throwableShake);
|
nbt.setByte("shake", (byte) this.throwableShake);
|
||||||
nbt.setByte("inGround", (byte) (this.inGround ? 1 : 0));
|
nbt.setByte("inGround", (byte) (this.inGround ? 1 : 0));
|
||||||
|
nbt.setInteger("ticksInGround", this.ticksInGround);
|
||||||
|
nbt.setInteger("ticksInAir", this.ticksInAir);
|
||||||
|
|
||||||
if((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) {
|
if((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) {
|
||||||
this.throwerName = this.thrower.getCommandSenderName();
|
this.throwerName = this.thrower.getCommandSenderName();
|
||||||
@ -329,6 +331,8 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
|
|||||||
this.throwableShake = nbt.getByte("shake") & 255;
|
this.throwableShake = nbt.getByte("shake") & 255;
|
||||||
this.inGround = nbt.getByte("inGround") == 1;
|
this.inGround = nbt.getByte("inGround") == 1;
|
||||||
this.throwerName = nbt.getString("ownerName");
|
this.throwerName = nbt.getString("ownerName");
|
||||||
|
this.ticksInGround = nbt.getInteger("ticksInGround");
|
||||||
|
this.ticksInAir = nbt.getInteger("ticksInAir");
|
||||||
|
|
||||||
if(this.throwerName != null && this.throwerName.length() == 0) {
|
if(this.throwerName != null && this.throwerName.length() == 0) {
|
||||||
this.throwerName = null;
|
this.throwerName = null;
|
||||||
|
|||||||
@ -52,6 +52,8 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
public int reputation;
|
public int reputation;
|
||||||
|
|
||||||
public boolean isOnLadder = false;
|
public boolean isOnLadder = false;
|
||||||
|
|
||||||
|
public int grenadeDeployment;
|
||||||
|
|
||||||
public HbmPlayerProps(EntityPlayer player) {
|
public HbmPlayerProps(EntityPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|||||||
@ -36,6 +36,10 @@ import com.hbm.items.weapon.ItemCustomMissilePart.*;
|
|||||||
import com.hbm.items.weapon.ItemMissile.MissileFormFactor;
|
import com.hbm.items.weapon.ItemMissile.MissileFormFactor;
|
||||||
import com.hbm.items.weapon.ItemMissile.MissileFuel;
|
import com.hbm.items.weapon.ItemMissile.MissileFuel;
|
||||||
import com.hbm.items.weapon.ItemMissile.MissileTier;
|
import com.hbm.items.weapon.ItemMissile.MissileTier;
|
||||||
|
import com.hbm.items.weapon.grenade.ItemGrenadeFilling;
|
||||||
|
import com.hbm.items.weapon.grenade.ItemGrenadeFuze;
|
||||||
|
import com.hbm.items.weapon.grenade.ItemGrenadeShell;
|
||||||
|
import com.hbm.items.weapon.grenade.ItemGrenadeUniversal;
|
||||||
import com.hbm.items.weapon.sedna.factory.GunFactory;
|
import com.hbm.items.weapon.sedna.factory.GunFactory;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
@ -1449,51 +1453,57 @@ public class ModItems {
|
|||||||
public static Item stick_semtex;
|
public static Item stick_semtex;
|
||||||
public static Item stick_c4;
|
public static Item stick_c4;
|
||||||
|
|
||||||
public static Item grenade_generic;
|
public static Item grenade_shell;
|
||||||
public static Item grenade_strong;
|
public static Item grenade_filling;
|
||||||
public static Item grenade_frag;
|
public static Item grenade_fuze;
|
||||||
public static Item grenade_fire;
|
public static Item grenade_universal;
|
||||||
public static Item grenade_shrapnel;
|
|
||||||
public static Item grenade_cluster;
|
@Deprecated public static Item grenade_generic;
|
||||||
public static Item grenade_flare;
|
@Deprecated public static Item grenade_strong;
|
||||||
public static Item grenade_electric;
|
@Deprecated public static Item grenade_frag;
|
||||||
public static Item grenade_poison;
|
@Deprecated public static Item grenade_fire;
|
||||||
public static Item grenade_gas;
|
@Deprecated public static Item grenade_shrapnel;
|
||||||
public static Item grenade_pulse;
|
@Deprecated public static Item grenade_cluster;
|
||||||
public static Item grenade_plasma;
|
@Deprecated public static Item grenade_flare;
|
||||||
public static Item grenade_tau;
|
@Deprecated public static Item grenade_electric;
|
||||||
public static Item grenade_schrabidium;
|
@Deprecated public static Item grenade_poison;
|
||||||
public static Item grenade_lemon;
|
@Deprecated public static Item grenade_gas;
|
||||||
public static Item grenade_gascan;
|
@Deprecated public static Item grenade_pulse;
|
||||||
public static Item grenade_kyiv;
|
@Deprecated public static Item grenade_plasma;
|
||||||
public static Item grenade_mk2;
|
@Deprecated public static Item grenade_tau;
|
||||||
public static Item grenade_aschrab;
|
@Deprecated public static Item grenade_schrabidium;
|
||||||
public static Item grenade_nuke;
|
@Deprecated public static Item grenade_lemon;
|
||||||
public static Item grenade_nuclear;
|
@Deprecated public static Item grenade_gascan;
|
||||||
public static Item grenade_zomg;
|
@Deprecated public static Item grenade_kyiv;
|
||||||
public static Item grenade_black_hole;
|
@Deprecated public static Item grenade_mk2;
|
||||||
public static Item grenade_cloud;
|
@Deprecated public static Item grenade_aschrab;
|
||||||
public static Item grenade_pink_cloud;
|
@Deprecated public static Item grenade_nuke;
|
||||||
|
@Deprecated public static Item grenade_nuclear;
|
||||||
|
@Deprecated public static Item grenade_zomg;
|
||||||
|
@Deprecated public static Item grenade_black_hole;
|
||||||
|
@Deprecated public static Item grenade_cloud;
|
||||||
|
@Deprecated public static Item grenade_pink_cloud;
|
||||||
|
|
||||||
public static Item ullapool_caber;
|
public static Item ullapool_caber;
|
||||||
|
|
||||||
public static Item grenade_if_generic;
|
@Deprecated public static Item grenade_if_generic;
|
||||||
public static Item grenade_if_he;
|
@Deprecated public static Item grenade_if_he;
|
||||||
public static Item grenade_if_bouncy;
|
@Deprecated public static Item grenade_if_bouncy;
|
||||||
public static Item grenade_if_sticky;
|
@Deprecated public static Item grenade_if_sticky;
|
||||||
public static Item grenade_if_impact;
|
@Deprecated public static Item grenade_if_impact;
|
||||||
public static Item grenade_if_incendiary;
|
@Deprecated public static Item grenade_if_incendiary;
|
||||||
public static Item grenade_if_toxic;
|
@Deprecated public static Item grenade_if_toxic;
|
||||||
public static Item grenade_if_concussion;
|
@Deprecated public static Item grenade_if_concussion;
|
||||||
public static Item grenade_if_brimstone;
|
@Deprecated public static Item grenade_if_brimstone;
|
||||||
public static Item grenade_if_mystery;
|
@Deprecated public static Item grenade_if_mystery;
|
||||||
public static Item grenade_if_spark;
|
@Deprecated public static Item grenade_if_spark;
|
||||||
public static Item grenade_if_hopwire;
|
@Deprecated public static Item grenade_if_hopwire;
|
||||||
public static Item grenade_if_null;
|
@Deprecated public static Item grenade_if_null;
|
||||||
|
|
||||||
public static Item grenade_smart;
|
@Deprecated public static Item grenade_smart;
|
||||||
public static Item grenade_mirv;
|
@Deprecated public static Item grenade_mirv;
|
||||||
public static Item grenade_breach;
|
@Deprecated public static Item grenade_breach;
|
||||||
public static Item grenade_burst;
|
@Deprecated public static Item grenade_burst;
|
||||||
|
|
||||||
public static Item nuclear_waste_pearl;
|
public static Item nuclear_waste_pearl;
|
||||||
|
|
||||||
@ -3683,6 +3693,11 @@ public class ModItems {
|
|||||||
stick_semtex = new Item().setUnlocalizedName("stick_semtex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_semtex");
|
stick_semtex = new Item().setUnlocalizedName("stick_semtex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_semtex");
|
||||||
stick_c4 = new Item().setUnlocalizedName("stick_c4").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_c4");
|
stick_c4 = new Item().setUnlocalizedName("stick_c4").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":stick_c4");
|
||||||
|
|
||||||
|
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_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");
|
grenade_generic = new ItemGrenade(4).setUnlocalizedName("grenade_generic").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_generic");
|
||||||
grenade_strong = new ItemGrenade(5).setUnlocalizedName("grenade_strong").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_strong");
|
grenade_strong = new ItemGrenade(5).setUnlocalizedName("grenade_strong").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_strong");
|
||||||
grenade_frag = new ItemGrenade(4).setUnlocalizedName("grenade_frag").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_frag_alt");
|
grenade_frag = new ItemGrenade(4).setUnlocalizedName("grenade_frag").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":grenade_frag_alt");
|
||||||
@ -6026,6 +6041,12 @@ public class ModItems {
|
|||||||
GameRegistry.registerItem(stick_tnt, stick_tnt.getUnlocalizedName());
|
GameRegistry.registerItem(stick_tnt, stick_tnt.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(stick_semtex, stick_semtex.getUnlocalizedName());
|
GameRegistry.registerItem(stick_semtex, stick_semtex.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(stick_c4, stick_c4.getUnlocalizedName());
|
GameRegistry.registerItem(stick_c4, stick_c4.getUnlocalizedName());
|
||||||
|
|
||||||
|
GameRegistry.registerItem(grenade_shell, grenade_shell.getUnlocalizedName());
|
||||||
|
GameRegistry.registerItem(grenade_filling, grenade_filling.getUnlocalizedName());
|
||||||
|
GameRegistry.registerItem(grenade_fuze, grenade_fuze.getUnlocalizedName());
|
||||||
|
GameRegistry.registerItem(grenade_universal, grenade_universal.getUnlocalizedName());
|
||||||
|
|
||||||
GameRegistry.registerItem(grenade_generic, grenade_generic.getUnlocalizedName());
|
GameRegistry.registerItem(grenade_generic, grenade_generic.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(grenade_strong, grenade_strong.getUnlocalizedName());
|
GameRegistry.registerItem(grenade_strong, grenade_strong.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(grenade_frag, grenade_frag.getUnlocalizedName());
|
GameRegistry.registerItem(grenade_frag, grenade_frag.getUnlocalizedName());
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class ItemGenericGrenade extends ItemGrenade {
|
public class ItemGenericGrenade extends ItemGrenade {
|
||||||
|
|
||||||
public ItemGenericGrenade(int fuse) {
|
public ItemGenericGrenade(int fuse) {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class ItemGrenadeKyiv extends ItemGenericGrenade {
|
public class ItemGrenadeKyiv extends ItemGenericGrenade {
|
||||||
|
|
||||||
public ItemGrenadeKyiv(int fuse) {
|
public ItemGrenadeKyiv(int fuse) {
|
||||||
|
|||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.hbm.items.weapon.grenade;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.hbm.entity.grenade.EntityGrenadeUniversal;
|
||||||
|
import com.hbm.explosion.vanillant.ExplosionVNT;
|
||||||
|
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.items.ItemEnumMulti;
|
||||||
|
|
||||||
|
public class ItemGrenadeFilling extends ItemEnumMulti {
|
||||||
|
|
||||||
|
public ItemGrenadeFilling() {
|
||||||
|
super(EnumGrenadeFilling.class, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumGrenadeFilling {
|
||||||
|
POWDER(EXPLODE_POWDER), // gunpowder
|
||||||
|
HE(null), // high explosive
|
||||||
|
FRAG(null), // high explosive with fragmentation
|
||||||
|
DEMO(null), // demolition
|
||||||
|
INC(null), // incendiary
|
||||||
|
CLUSTER(null), // explosive pellets
|
||||||
|
NUCLEAR(null); // nuka grenade
|
||||||
|
|
||||||
|
// and more which i haven't decided. probably plasma, EMP, perhaps laser(?)
|
||||||
|
|
||||||
|
public Consumer<EntityGrenadeUniversal> explode;
|
||||||
|
|
||||||
|
private EnumGrenadeFilling(Consumer<EntityGrenadeUniversal> explode) {
|
||||||
|
this.explode = explode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Consumer<EntityGrenadeUniversal> EXPLODE_POWDER = (grenade) -> {
|
||||||
|
standardExplode(grenade, 5F, 10F, 5F, 0F);
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Consumer<EntityGrenadeUniversal> EXPLODE_HE = (grenade) -> {
|
||||||
|
standardExplode(grenade, 7.5F, 25F, 10F, 0.1F);
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void standardExplode(EntityGrenadeUniversal grenade, float range, float damage) { standardExplode(grenade, range, damage, 0F, 0F); }
|
||||||
|
public static void standardExplode(EntityGrenadeUniversal grenade, float range, float damage, float dt, float dr) {
|
||||||
|
ExplosionVNT vnt = new ExplosionVNT(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, range, grenade.getThrower());
|
||||||
|
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, damage).setupPiercing(dt, dr));
|
||||||
|
vnt.setPlayerProcessor(new PlayerProcessorStandard());
|
||||||
|
vnt.setSFX(new ExplosionEffectWeapon(10, 2.5F, 1F));
|
||||||
|
vnt.explode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tinyExplode(EntityGrenadeUniversal grenade, float range, float damage) { tinyExplode(grenade, range, damage, 0F, 0F); }
|
||||||
|
public static void tinyExplode(EntityGrenadeUniversal grenade, float range, float damage, float dt, float dr) {
|
||||||
|
ExplosionVNT vnt = new ExplosionVNT(grenade.worldObj, grenade.posX, grenade.posY, grenade.posZ, range, grenade.getThrower());
|
||||||
|
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, damage).setupPiercing(dt, dr).setKnockback(0.25D));
|
||||||
|
vnt.setPlayerProcessor(new PlayerProcessorStandard());
|
||||||
|
vnt.setSFX(new ExplosionEffectTiny());
|
||||||
|
vnt.explode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.hbm.items.weapon.grenade;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.hbm.entity.grenade.EntityGrenadeUniversal;
|
||||||
|
import com.hbm.items.ItemEnumMulti;
|
||||||
|
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
|
||||||
|
public class ItemGrenadeFuze extends ItemEnumMulti {
|
||||||
|
|
||||||
|
public ItemGrenadeFuze() {
|
||||||
|
super(EnumGrenadeFuze.class, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumGrenadeFuze {
|
||||||
|
S3(null, null), // 3s timed
|
||||||
|
S7(null, null), // 7s times
|
||||||
|
S15(null, null), // 15s timed
|
||||||
|
IMPACT(null, null), // on block/entity impact, 1s safety
|
||||||
|
AIRBURST(null, null); // still have to figure out the mechanics, whether it should be an arc angle or fixed height over the floor, 2s safety
|
||||||
|
|
||||||
|
public Consumer<EntityGrenadeUniversal> updateTick;
|
||||||
|
public BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> onImpact;
|
||||||
|
|
||||||
|
private EnumGrenadeFuze(Consumer<EntityGrenadeUniversal> updateTick, BiConsumer<EntityGrenadeUniversal, MovingObjectPosition> onImpact) {
|
||||||
|
this.updateTick = updateTick;
|
||||||
|
this.onImpact = onImpact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.hbm.items.weapon.grenade;
|
||||||
|
|
||||||
|
import com.hbm.items.ItemEnumMulti;
|
||||||
|
|
||||||
|
public class ItemGrenadeShell extends ItemEnumMulti {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __________
|
||||||
|
* | | ________ SHELL COLOR - Changes based on filling
|
||||||
|
* | _____ |
|
||||||
|
* | | _____________ LABEL COLOR - Changes based on filling
|
||||||
|
* | |_____| |
|
||||||
|
* \________/__________ FUZE INDICATOR RING - Changes based on filling
|
||||||
|
* \______/
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* | ______________ MISC - Remains static for this shell
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* | |
|
||||||
|
* / \
|
||||||
|
* |______|
|
||||||
|
* {__}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public ItemGrenadeShell() {
|
||||||
|
super(EnumGrenadeShell.class, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EnumGrenadeShell {
|
||||||
|
FRAG(4, 20, 0.25D), // bonus fragmentation
|
||||||
|
STICK(4, 20, 0.1D), // thrown father
|
||||||
|
TECH(2, 20, 0.25D), // casing with electronics for EMP/plasma
|
||||||
|
NUKE(1, 20, 0.05D); // nuka grenade casing for high yield grenades
|
||||||
|
/* ^
|
||||||
|
* nice */
|
||||||
|
|
||||||
|
private int stackLimit;
|
||||||
|
private int drawDuration;
|
||||||
|
private double bounceModifier = 1D;
|
||||||
|
|
||||||
|
private EnumGrenadeShell(int stackLimit, int drawDuration, double bounceModifier) {
|
||||||
|
this.stackLimit = stackLimit;
|
||||||
|
this.drawDuration = drawDuration;
|
||||||
|
this.bounceModifier = bounceModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStackLimit() { return stackLimit; }
|
||||||
|
public int getDrawDuration() { return drawDuration; }
|
||||||
|
public double getBounce() { return bounceModifier; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
package com.hbm.items.weapon.grenade;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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.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.util.EnumUtil;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __________
|
||||||
|
* | ________ | ______ SHELL - determines what filling can be used, various bonuses like throw distance and fragmentation, max stack size
|
||||||
|
* || ||
|
||||||
|
* || __________ FILLING - the bang - high explosive, fragmentation, incendiary, etc
|
||||||
|
* ||________||
|
||||||
|
* \ /\ /
|
||||||
|
* \_ || _/
|
||||||
|
* | || |
|
||||||
|
* | |_____________ FUZE - what triggers the explosive, timed, impact, or airburst
|
||||||
|
* | || |
|
||||||
|
* | || |
|
||||||
|
* | || |
|
||||||
|
* | || |
|
||||||
|
* | || |
|
||||||
|
* | || |
|
||||||
|
* / || \
|
||||||
|
* |__||__|
|
||||||
|
* {__}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final String KEY_SHELL = "shell";
|
||||||
|
public static final String KEY_FILLING = "filling";
|
||||||
|
public static final String KEY_FUZE = "fuze";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemStackLimit(ItemStack stack) {
|
||||||
|
return getShell(stack).getStackLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEquip(EntityPlayer player, ItemStack stack) {
|
||||||
|
HbmPlayerProps.getData(player).grenadeDeployment = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
|
|
||||||
|
EnumGrenadeShell shell = getShell(stack);
|
||||||
|
if(HbmPlayerProps.getData(player).grenadeDeployment >= shell.getDrawDuration()) {
|
||||||
|
if(!world.isRemote) {
|
||||||
|
EntityGrenadeUniversal grenade = new EntityGrenadeUniversal(world, player, stack);
|
||||||
|
world.spawnEntityInWorld(grenade);
|
||||||
|
}
|
||||||
|
stack.stackSize--;
|
||||||
|
if(stack.stackSize > 0) this.onEquip(player, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isHeld) {
|
||||||
|
|
||||||
|
if(!(entity instanceof EntityLivingBase)) return;
|
||||||
|
EntityPlayer player = entity instanceof EntityPlayer ? (EntityPlayer) entity : null;
|
||||||
|
|
||||||
|
if(player != null) {
|
||||||
|
boolean wasHeld = ItemGunBaseNT.getIsEquipped(stack);
|
||||||
|
|
||||||
|
if(!wasHeld && isHeld) {
|
||||||
|
this.onEquip(player, stack);
|
||||||
|
} else if(isHeld) {
|
||||||
|
HbmPlayerProps.getData(player).grenadeDeployment++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemGunBaseNT.setIsEquipped(stack, isHeld);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumGrenadeShell getShell(ItemStack stack) {
|
||||||
|
if(stack == null || !stack.hasTagCompound()) return EnumGrenadeShell.FRAG;
|
||||||
|
int i = stack.stackTagCompound.getInteger(KEY_SHELL);
|
||||||
|
return EnumUtil.grabEnumSafely(EnumGrenadeShell.class, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumGrenadeFilling getFilling(ItemStack stack) {
|
||||||
|
if(stack == null || !stack.hasTagCompound()) return EnumGrenadeFilling.HE;
|
||||||
|
int i = stack.stackTagCompound.getInteger(KEY_FILLING);
|
||||||
|
return EnumUtil.grabEnumSafely(EnumGrenadeFilling.class, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumGrenadeFuze getFuze(ItemStack stack) {
|
||||||
|
if(stack == null || !stack.hasTagCompound()) return EnumGrenadeFuze.S3;
|
||||||
|
int i = stack.stackTagCompound.getInteger(KEY_FUZE);
|
||||||
|
return EnumUtil.grabEnumSafely(EnumGrenadeFuze.class, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze) {
|
||||||
|
return make(shell, filling, fuze, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack make(EnumGrenadeShell shell, EnumGrenadeFilling filling, EnumGrenadeFuze fuze, 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());
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||||
|
// some demo crap
|
||||||
|
list.add(make(EnumGrenadeShell.STICK, EnumGrenadeFilling.HE, EnumGrenadeFuze.S3));
|
||||||
|
list.add(make(EnumGrenadeShell.STICK, EnumGrenadeFilling.HE, EnumGrenadeFuze.IMPACT));
|
||||||
|
list.add(make(EnumGrenadeShell.STICK, EnumGrenadeFilling.DEMO, EnumGrenadeFuze.S7));
|
||||||
|
list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.POWDER, EnumGrenadeFuze.S3));
|
||||||
|
list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.FRAG, EnumGrenadeFuze.S3));
|
||||||
|
list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.FRAG, EnumGrenadeFuze.IMPACT));
|
||||||
|
list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.INC, EnumGrenadeFuze.S7));
|
||||||
|
list.add(make(EnumGrenadeShell.FRAG, EnumGrenadeFilling.CLUSTER, EnumGrenadeFuze.AIRBURST));
|
||||||
|
list.add(make(EnumGrenadeShell.NUKE, EnumGrenadeFilling.NUCLEAR, EnumGrenadeFuze.S15));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user