From 400e0b24ed8a1525a99fd392f65e8d899baea11f Mon Sep 17 00:00:00 2001 From: Boblet Date: Tue, 22 Oct 2024 16:36:46 +0200 Subject: [PATCH] there are chemicals in my food --- .../java/com/hbm/blocks/bomb/Landmine.java | 8 +- src/main/java/com/hbm/items/ModItems.java | 5 +- .../sedna/factory/GunFactoryClient.java | 2 + .../weapon/sedna/factory/XFactoryFlamer.java | 22 ++++ .../weapon/sedna/impl/ItemGunChemthrower.java | 101 ++++++++++++++++++ .../weapon/sedna/mags/MagazineFluid.java | 65 +++++++++++ .../weapon/sedna/ItemRenderChemthrower.java | 26 +++++ 7 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java create mode 100644 src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java create mode 100644 src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderChemthrower.java diff --git a/src/main/java/com/hbm/blocks/bomb/Landmine.java b/src/main/java/com/hbm/blocks/bomb/Landmine.java index 35b7bdc9a..966cc470f 100644 --- a/src/main/java/com/hbm/blocks/bomb/Landmine.java +++ b/src/main/java/com/hbm/blocks/bomb/Landmine.java @@ -7,7 +7,6 @@ import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionNukeSmall; 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.ExplosionEffectWeapon; @@ -168,7 +167,12 @@ public class Landmine extends BlockContainer implements IBomb { vnt.setSFX(new ExplosionEffectWeapon(15, 3.5F, 1.25F)); vnt.explode(); } else if(this == ModBlocks.mine_shrap) { - ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 1, true, false, false); + ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F); + vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, 7.5F)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F)); + vnt.explode(); + ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D); ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5); } else if(this == ModBlocks.mine_fat) { diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 93128a3dd..2fdd58c9c 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1553,7 +1553,6 @@ public class ModItems { public static Item gun_proto; public static Item gun_mirv; public static Item gun_bf; - public static Item gun_chemthrower; public static Item gun_mp40; public static Item gun_thompson; public static Item gun_uzi_silencer; @@ -1637,6 +1636,7 @@ public class ModItems { public static Item gun_panzerschreck; public static Item gun_g3; public static Item gun_stinger; + public static Item gun_chemthrower; public static Item ammo_standard; @@ -4106,7 +4106,6 @@ public class ModItems { gun_proto = new ItemGunBase(GunFatmanFactory.getProtoConfig()).setUnlocalizedName("gun_proto").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_fatman"); gun_mirv = new ItemGunBase(GunFatmanFactory.getMIRVConfig()).setUnlocalizedName("gun_mirv").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_mirv"); gun_bf = new ItemGunBase(GunFatmanFactory.getBELConfig()).setUnlocalizedName("gun_bf").setCreativeTab(null).setTextureName(RefStrings.MODID + ":gun_bf"); - gun_chemthrower = new ItemGunChemthrower().setUnlocalizedName("gun_chemthrower").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_fatman"); gun_mp40 = new ItemGunBase(Gun9mmFactory.getMP40Config()).setUnlocalizedName("gun_mp40").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_mp40"); gun_thompson = new ItemGunBase(Gun45ACPFactory.getThompsonConfig()).setUnlocalizedName("gun_thompson").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_thompson"); gun_uzi_silencer = new ItemGunBase(Gun22LRFactory.getUziConfig().silenced()).setUnlocalizedName("gun_uzi_silencer").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_uzi_silencer"); @@ -6955,7 +6954,6 @@ public class ModItems { GameRegistry.registerItem(gun_proto, gun_proto.getUnlocalizedName()); GameRegistry.registerItem(gun_mirv, gun_mirv.getUnlocalizedName()); GameRegistry.registerItem(gun_bf, gun_bf.getUnlocalizedName()); - GameRegistry.registerItem(gun_chemthrower, gun_chemthrower.getUnlocalizedName()); GameRegistry.registerItem(gun_mp40, gun_mp40.getUnlocalizedName()); GameRegistry.registerItem(gun_thompson, gun_thompson.getUnlocalizedName()); GameRegistry.registerItem(gun_uzi_silencer,gun_uzi_silencer.getUnlocalizedName()); @@ -7026,6 +7024,7 @@ public class ModItems { GameRegistry.registerItem(gun_panzerschreck, gun_panzerschreck.getUnlocalizedName()); GameRegistry.registerItem(gun_g3, gun_g3.getUnlocalizedName()); GameRegistry.registerItem(gun_stinger, gun_stinger.getUnlocalizedName()); + GameRegistry.registerItem(gun_chemthrower, gun_chemthrower.getUnlocalizedName()); GameRegistry.registerItem(ammo_standard, ammo_standard.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java index 0aefd80de..b9a3b0294 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java @@ -42,6 +42,7 @@ public class GunFactoryClient { MinecraftForgeClient.registerItemRenderer(ModItems.gun_panzerschreck, new ItemRenderPanzerschreck()); MinecraftForgeClient.registerItemRenderer(ModItems.gun_g3, new ItemRenderG3()); MinecraftForgeClient.registerItemRenderer(ModItems.gun_stinger, new ItemRenderStinger()); + MinecraftForgeClient.registerItemRenderer(ModItems.gun_chemthrower, new ItemRenderChemthrower()); //PROJECTILES ammo_debug.setRenderer(LegoClient.RENDER_STANDARD_BULLET); ammo_debug_buckshot.setRenderer(LegoClient.RENDER_STANDARD_BULLET); @@ -100,6 +101,7 @@ public class GunFactoryClient { ((ItemGunBaseNT) ModItems.gun_panzerschreck) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_g3) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_stinger) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); + ((ItemGunBaseNT) ModItems.gun_chemthrower) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO_NOCOUNTER); ((ItemGunBaseNT) ModItems.gun_light_revolver_dani).getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY_MIRROR, LegoClient.HUD_COMPONENT_AMMO_MIRROR); ((ItemGunBaseNT) ModItems.gun_light_revolver_dani).getConfig(null, 1).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java index d92ed70a7..f4b1b58e1 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java @@ -9,6 +9,8 @@ import com.hbm.items.weapon.sedna.GunConfig; import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.items.weapon.sedna.Receiver; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo; +import com.hbm.items.weapon.sedna.impl.ItemGunChemthrower; +import com.hbm.items.weapon.sedna.mags.MagazineFluid; import com.hbm.items.weapon.sedna.mags.MagazineFullReload; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; @@ -48,6 +50,17 @@ public class XFactoryFlamer { .setupStandardConfiguration() .anim(LAMBDA_FLAMER_ANIMS).orchestra(Orchestras.ORCHESTRA_FLAMER) ).setUnlocalizedName("gun_flamer").setTextureName(RefStrings.MODID + ":gun_darter"); + + ModItems.gun_chemthrower = new ItemGunChemthrower(new GunConfig() + .dura(90_000).draw(10).inspect(17).crosshair(Crosshair.L_CIRCLE).smoke(Lego.LAMBDA_STANDARD_SMOKE) + .rec(new Receiver(0) + .delay(1).auto(true) + .mag(new MagazineFluid(0, 300)) + .offset(0.75, -0.0625, -0.25D) + .canFire(ItemGunChemthrower.LAMBDA_CAN_FIRE).fire(ItemGunChemthrower.LAMBDA_FIRE)) + .pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY).decider(GunStateDecider.LAMBDA_STANDARD_DECIDER) + .anim(LAMBDA_CHEMTHROWER_ANIMS).orchestra(Orchestras.ORCHESTRA_FLAMER) + ).setUnlocalizedName("gun_chemthrower").setTextureName(RefStrings.MODID + ":gun_darter"); } @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_FLAMER_ANIMS = (stack, type) -> { @@ -62,4 +75,13 @@ public class XFactoryFlamer { return null; }; + + @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_CHEMTHROWER_ANIMS = (stack, type) -> { + switch(type) { + case EQUIP: return new BusAnimation() + .addBus("EQUIP", new BusAnimationSequence().addPos(-45, 0, 0, 0).addPos(0, 0, 0, 500, IType.SIN_DOWN)); + } + + return null; + }; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java b/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java new file mode 100644 index 000000000..6eae059ec --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java @@ -0,0 +1,101 @@ +package com.hbm.items.weapon.sedna.impl; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +import com.hbm.entity.projectile.EntityChemical; +import com.hbm.inventory.fluid.FluidType; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.items.weapon.sedna.BulletConfig; +import com.hbm.items.weapon.sedna.GunConfig; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.Receiver; +import com.hbm.items.weapon.sedna.mags.IMagazine; +import com.hbm.items.weapon.sedna.mags.MagazineFluid; +import com.hbm.render.anim.HbmAnimations.AnimType; + +import api.hbm.fluid.IFillableItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Vec3; + +public class ItemGunChemthrower extends ItemGunBaseNT implements IFillableItem { + + public static final int CONSUMPTION = 3; + + public ItemGunChemthrower(GunConfig... cfg) { + super(cfg); + } + + @Override + public boolean acceptsFluid(FluidType type, ItemStack stack) { + return getFluidType(stack) == type || this.getMagCount(stack) == 0; + } + + public static final int transferSpeed = 50; + + @Override + public int tryFill(FluidType type, int amount, ItemStack stack) { + + if(!acceptsFluid(type, stack)) return amount; + if(this.getMagCount(stack) == 0) this.setMagType(stack, type.getID()); + + int fill = this.getMagCount(stack); + int req = this.getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getCapacity(stack) - fill; + int toFill = Math.min(amount, req); + toFill = Math.min(toFill, transferSpeed); + this.setMagCount(stack, fill + toFill); + + return amount - toFill; + } + + public FluidType getFluidType(ItemStack stack) { + return Fluids.fromID(this.getMagType(stack)); + } + + @Override + public boolean providesFluid(FluidType type, ItemStack stack) { + return getFluidType(stack) == type; + } + + @Override + public int tryEmpty(FluidType type, int amount, ItemStack stack) { + int fill = this.getMagCount(stack); + int toUnload = Math.min(fill, amount); + toUnload = Math.min(toUnload, transferSpeed); + this.setMagCount(stack, fill - toUnload); + return toUnload; + } + + @Override public FluidType getFirstFluidType(ItemStack stack) { return Fluids.fromID(this.getMagType(stack)); } + @Override public int getFill(ItemStack stack) { return this.getMagCount(stack); } + + public static int getMagType(ItemStack stack) { return ItemGunBaseNT.getValueInt(stack, MagazineFluid.KEY_MAG_TYPE + 0); } + public static void setMagType(ItemStack stack, int value) { ItemGunBaseNT.setValueInt(stack, MagazineFluid.KEY_MAG_TYPE + 0, value); } + public static int getMagCount(ItemStack stack) { return ItemGunBaseNT.getValueInt(stack, MagazineFluid.KEY_MAG_COUNT + 0); } + public static void setMagCount(ItemStack stack, int value) { ItemGunBaseNT.setValueInt(stack, MagazineFluid.KEY_MAG_COUNT + 0, value); } + + public static BiFunction LAMBDA_CAN_FIRE = (stack, ctx) -> { return ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmount(stack) >= CONSUMPTION; }; + + public static BiConsumer LAMBDA_FIRE = (stack, ctx) -> { + EntityPlayer player = ctx.player; + int index = ctx.configIndex; + ItemGunBaseNT.playAnimation(player, stack, AnimType.CYCLE, ctx.configIndex); + + Receiver primary = ctx.config.getReceivers(stack)[0]; + IMagazine mag = primary.getMagazine(stack); + BulletConfig config = (BulletConfig) mag.getType(stack); + + Vec3 offset = primary.getProjectileOffset(stack); + double forwardOffset = offset.xCoord; + double heightOffset = offset.yCoord; + double sideOffset = offset.zCoord; + + EntityChemical chem = new EntityChemical(player.worldObj, player); + chem.setFluid((FluidType) mag.getType(stack)); + player.worldObj.spawnEntityInWorld(chem); + + mag.setAmount(stack, mag.getAmount(stack) - CONSUMPTION); + ItemGunBaseNT.setWear(stack, index, Math.min(ItemGunBaseNT.getWear(stack, index) + config.wear, ctx.config.getDurability(stack))); + }; +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java new file mode 100644 index 000000000..bfe8d5caa --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java @@ -0,0 +1,65 @@ +package com.hbm.items.weapon.sedna.mags; + +import com.hbm.inventory.fluid.FluidType; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.items.ModItems; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.particle.SpentCasing; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class MagazineFluid implements IMagazine { + + public static final String KEY_MAG_COUNT = "magcount"; + public static final String KEY_MAG_TYPE = "magtype"; + public static final String KEY_MAG_PREV = "magprev"; + public static final String KEY_MAG_AFTER = "magafter"; + + /** A number so the gun tell multiple mags apart */ + public int index; + /** How much ammo this mag can hold */ + public int capacity; + + public MagazineFluid(int index, int capacity) { + this.index = index; + this.capacity = capacity; + } + + @Override + public FluidType getType(ItemStack stack) { + int id = this.getMagType(stack, index); + return Fluids.fromID(id); + } + + @Override + public void setType(ItemStack stack, FluidType type) { + this.setMagType(stack, index, type.getID()); + } + + @Override + public int getCapacity(ItemStack stack) { + return capacity; + } + + @Override public int getAmount(ItemStack stack) { return getMagCount(stack, index); } + @Override public void setAmount(ItemStack stack, int amount) { setMagCount(stack, index, amount); } + + @Override public boolean canReload(ItemStack stack, EntityPlayer player) { return false; } + @Override public void reloadAction(ItemStack stack, EntityPlayer player) { } + @Override public SpentCasing getCasing(ItemStack stack) { return null; } + + @Override public ItemStack getIconForHUD(ItemStack stack) { return new ItemStack(ModItems.fluid_icon, 1, this.getMagType(stack, index)); } + @Override public String reportAmmoStateForHUD(ItemStack stack) { return getAmount(stack) + " / " + getCapacity(stack) + "mB"; } + + @Override public void setAmountBeforeReload(ItemStack stack, int amount) { ItemGunBaseNT.setValueInt(stack, KEY_MAG_PREV + index, amount); } + @Override public int getAmountBeforeReload(ItemStack stack) { return ItemGunBaseNT.getValueInt(stack, KEY_MAG_PREV + index); } + @Override public void setAmountAfterReload(ItemStack stack, int amount) { ItemGunBaseNT.setValueInt(stack, KEY_MAG_AFTER + index, amount); } + @Override public int getAmountAfterReload(ItemStack stack) { return ItemGunBaseNT.getValueInt(stack, KEY_MAG_AFTER + index); } + + public static int getMagType(ItemStack stack, int index) { return ItemGunBaseNT.getValueInt(stack, KEY_MAG_TYPE + index); } + public static void setMagType(ItemStack stack, int index, int value) { ItemGunBaseNT.setValueInt(stack, KEY_MAG_TYPE + index, value); } + public static int getMagCount(ItemStack stack, int index) { return ItemGunBaseNT.getValueInt(stack, KEY_MAG_COUNT + index); } + public static void setMagCount(ItemStack stack, int index, int value) { ItemGunBaseNT.setValueInt(stack, KEY_MAG_COUNT + index, value); } + +} diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderChemthrower.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderChemthrower.java new file mode 100644 index 000000000..c3a3430f9 --- /dev/null +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderChemthrower.java @@ -0,0 +1,26 @@ +package com.hbm.render.item.weapon.sedna; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; + +public class ItemRenderChemthrower implements IItemRenderer { + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + // TODO Auto-generated method stub + + } + +}