diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 7c7a2eb53..d25b15108 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -36,6 +36,7 @@ import com.hbm.items.weapon.ItemCustomMissilePart.*; import com.hbm.items.weapon.ItemMissile.MissileFormFactor; import com.hbm.items.weapon.ItemMissile.MissileFuel; import com.hbm.items.weapon.ItemMissile.MissileTier; +import com.hbm.items.weapon.sedna.GunFactory; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; import com.hbm.potion.HbmPotion; @@ -1608,11 +1609,9 @@ public class ModItems { public static Item gun_m2; public static Item gun_lunatic_marksman; public static Item gun_uac_pistol; - - // We'll figure this part out later - //public static Item gun_llr, gun_mlr, gun_hlr, gun_twr, gun_lunatic, gun_lunatic_shotty; - //public static Item gun_uac_pistol, gun_uac_dmr, gun_uac_carbine, gun_uac_lmg; - //public static Item gun_benelli, gun_benelli_mod, gun_g36, spear_bishamonten, pagoda; + + public static Item gun_debug; + public static Item ammo_debug; public static Item crucible; @@ -5458,6 +5457,8 @@ public class ModItems { mysteryshovel = new ItemMS().setUnlocalizedName("mysteryshovel").setFull3D().setMaxStackSize(1).setTextureName(RefStrings.MODID + ":cursed_shovel"); memory = new ItemBattery(Long.MAX_VALUE / 100L, 100000000000000L, 100000000000000L).setUnlocalizedName("memory").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":mo8_anim"); + GunFactory.init(); + FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.mud_fluid, 1000), new ItemStack(ModItems.bucket_mud), new ItemStack(Items.bucket)); FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.acid_fluid, 1000), new ItemStack(ModItems.bucket_acid), new ItemStack(Items.bucket)); FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.toxic_fluid, 1000), new ItemStack(ModItems.bucket_toxic), new ItemStack(Items.bucket)); @@ -6995,6 +6996,9 @@ public class ModItems { GameRegistry.registerItem(gun_glass_cannon, gun_glass_cannon.getUnlocalizedName()); GameRegistry.registerItem(gun_lunatic_marksman, gun_lunatic_marksman.getUnlocalizedName()); + GameRegistry.registerItem(gun_debug, gun_debug.getUnlocalizedName()); + GameRegistry.registerItem(ammo_debug, ammo_debug.getUnlocalizedName()); + //Ammo GameRegistry.registerItem(gun_b92_ammo, gun_b92_ammo.getUnlocalizedName()); GameRegistry.registerItem(gun_xvl1456_ammo, gun_xvl1456_ammo.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java index ce49ad85d..9cc858b8b 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java +++ b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java @@ -5,6 +5,8 @@ import java.util.List; import com.hbm.inventory.RecipesCommon.ComparableStack; +import net.minecraft.item.Item; + public class BulletConfig { public static List configs = new ArrayList(); @@ -12,7 +14,7 @@ public class BulletConfig { public final int id; public ComparableStack ammo; - public int ammoCount = 1; + public int ammoReloadCount = 1; public float velocity = 5F; public float spread = 0F; public float wear = 1F; @@ -29,4 +31,6 @@ public class BulletConfig { this.id = configs.size(); configs.add(this); } + + public BulletConfig setItem(Item ammo) { this.ammo = new ComparableStack(ammo); return this; } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/GunConfig.java b/src/main/java/com/hbm/items/weapon/sedna/GunConfig.java index 60abf5931..91bdffc24 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/GunConfig.java +++ b/src/main/java/com/hbm/items/weapon/sedna/GunConfig.java @@ -8,30 +8,55 @@ import net.minecraft.item.ItemStack; public class GunConfig { + /* FIELDS */ + /** List of receivers used by the gun, primary and secondary are usually indices 0 and 1 respectively, if applicable */ - public Receiver[] receivers; - public float durability; - public int drawDuration = 0; - public Crosshair crosshair; - /** Lambda function that determines what receiver the gun should use when a keybind is hit */ - //public Function, Receiver> receiverDecider; + protected Receiver[] receivers; + protected float durability; + protected int drawDuration = 0; + protected Crosshair crosshair; /** Lambda functions for clicking shit */ - public BiConsumer onPressPrimary; - public BiConsumer onPressSecondary; - public BiConsumer onPressTertiary; - public BiConsumer onPressReload; + protected BiConsumer onPressPrimary; + protected BiConsumer onPressSecondary; + protected BiConsumer onPressTertiary; + protected BiConsumer onPressReload; /** Lambda functions for releasing the aforementioned shit */ - public BiConsumer onReleasePrimary; - public BiConsumer onReleaseSecondary; - public BiConsumer onReleaseTertiary; - public BiConsumer onReleaseReload; + protected BiConsumer onReleasePrimary; + protected BiConsumer onReleaseSecondary; + protected BiConsumer onReleaseTertiary; + protected BiConsumer onReleaseReload; - public float getDurability(ItemStack stack) { - return durability; - } + /* GETTERS */ + + public Receiver[] getReceivers(ItemStack stack) { return receivers; } + public float getDurability(ItemStack stack) { return durability; } + public int getDrawDuration(ItemStack stack) { return drawDuration; } + public Crosshair getCrosshair(ItemStack stack) { return crosshair; } + + public BiConsumer getPressPrimary(ItemStack stack) { return this.onPressPrimary; } + public BiConsumer getPressSecondary(ItemStack stack) { return this.onPressSecondary; } + public BiConsumer getPressTertiary(ItemStack stack) { return this.onPressTertiary; } + public BiConsumer getPressReload(ItemStack stack) { return this.onPressReload; } + + public BiConsumer getReleasePrimary(ItemStack stack) { return this.onReleasePrimary; } + public BiConsumer getReleaseSecondary(ItemStack stack) { return this.onReleaseSecondary; } + public BiConsumer getReleaseTertiary(ItemStack stack) { return this.onReleaseTertiary; } + public BiConsumer getReleaseReload(ItemStack stack) { return this.onReleaseReload; } - public GunConfig setReceivers(Receiver... receivers) { - this.receivers = receivers; - return this; - } + /* SETTERS */ + + public GunConfig rec(Receiver... receivers) { this.receivers = receivers; return this; } + public GunConfig dura(float dura) { this.durability = dura; return this; } + public GunConfig draw(int draw) { this.drawDuration = draw; return this; } + public GunConfig crosshair(Crosshair crosshair) { this.crosshair = crosshair; return this; } + + public GunConfig pp(BiConsumer lambda) { this.onPressPrimary = lambda; return this; } + public GunConfig ps(BiConsumer lambda) { this.onPressSecondary = lambda; return this; } + public GunConfig pt(BiConsumer lambda) { this.onPressTertiary = lambda; return this; } + public GunConfig pr(BiConsumer lambda) { this.onPressReload = lambda; return this; } + + public GunConfig rp(BiConsumer lambda) { this.onReleasePrimary = lambda; return this; } + public GunConfig rs(BiConsumer lambda) { this.onReleaseSecondary = lambda; return this; } + public GunConfig rt(BiConsumer lambda) { this.onReleaseTertiary = lambda; return this; } + public GunConfig rr(BiConsumer lambda) { this.onReleaseReload = lambda; return this; } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/GunFactory.java b/src/main/java/com/hbm/items/weapon/sedna/GunFactory.java new file mode 100644 index 000000000..d27913133 --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/GunFactory.java @@ -0,0 +1,25 @@ +package com.hbm.items.weapon.sedna; + +import com.hbm.items.ModItems; +import com.hbm.items.weapon.sedna.mags.MagazineRevolverDrum; +import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; +import com.hbm.render.util.RenderScreenOverlay.Crosshair; + +import net.minecraft.item.Item; + +public class GunFactory { + + public static void init() { + + ModItems.ammo_debug = new Item().setUnlocalizedName("ammo_debug").setTextureName(RefStrings.MODID + ":ammo_45"); + + BulletConfig ammo_debug = new BulletConfig().setItem(ModItems.ammo_debug); + + ModItems.gun_debug = new ItemGunBase(new GunConfig() + .dura(600).draw(15).crosshair(Crosshair.L_CLASSIC) + .rec(new Receiver() + .dmg(10F).delay(10).mag(new MagazineRevolverDrum(0, 6).addConfigs(ammo_debug))) + ).setUnlocalizedName("gun_debug").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter"); + } +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBase.java index 38f0a4e62..1a82c51ba 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBase.java @@ -27,6 +27,11 @@ public class ItemGunBase extends Item implements IKeybindReceiver { public GunConfig getConfig(ItemStack stack) { return config_DNA; } + + public ItemGunBase(GunConfig cfg) { + this.setMaxStackSize(1); + this.config_DNA = cfg; + } public static enum GunState { DRAWING, //initial delay after selecting @@ -37,18 +42,18 @@ public class ItemGunBase extends Item implements IKeybindReceiver { } @Override - public void handleKeybind(EntityPlayer player, ItemStack stack, EnumKeybind keybind, boolean state) { + public void handleKeybind(EntityPlayer player, ItemStack stack, EnumKeybind keybind, boolean newState) { GunConfig config = getConfig(stack); - if(keybind == EnumKeybind.GUN_PRIMARY && state && !getPrimary(stack)) { if(config.onPressPrimary != null) config.onPressPrimary.accept(stack, config); return; } - if(keybind == EnumKeybind.GUN_PRIMARY && !state && getPrimary(stack)) { if(config.onReleasePrimary != null) config.onReleasePrimary.accept(stack, config); return; } - if(keybind == EnumKeybind.GUN_SECONDARY && state && !getSecondary(stack)) { if(config.onPressSecondary != null) config.onPressSecondary.accept(stack, config); return; } - if(keybind == EnumKeybind.GUN_SECONDARY && !state && getSecondary(stack)) { if(config.onReleaseSecondary != null) config.onReleaseSecondary.accept(stack, config); return; } - if(keybind == EnumKeybind.GUN_TERTIARY && state && !getTertiary(stack)) { if(config.onPressTertiary != null) config.onPressTertiary.accept(stack, config); return; } - if(keybind == EnumKeybind.GUN_TERTIARY && !state && getTertiary(stack)) { if(config.onReleaseTertiary != null) config.onReleaseTertiary.accept(stack, config); return; } - if(keybind == EnumKeybind.RELOAD && state && !getReloadKey(stack)) { if(config.onPressReload != null) config.onPressReload.accept(stack, config); return; } - if(keybind == EnumKeybind.RELOAD && !state && getReloadKey(stack)) { if(config.onReleaseReload != null) config.onReleaseReload.accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_PRIMARY && newState && !getPrimary(stack)) { if(config.getPressPrimary(stack) != null) config.getPressPrimary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_PRIMARY && !newState && getPrimary(stack)) { if(config.getReleasePrimary(stack) != null) config.getReleasePrimary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_SECONDARY && newState && !getSecondary(stack)) { if(config.getPressSecondary(stack) != null) config.getPressSecondary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_SECONDARY && !newState && getSecondary(stack)) { if(config.getReleaseSecondary(stack) != null) config.getReleaseSecondary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_TERTIARY && newState && !getTertiary(stack)) { if(config.getPressTertiary(stack) != null) config.getPressTertiary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.GUN_TERTIARY && !newState && getTertiary(stack)) { if(config.getReleaseTertiary(stack) != null) config.getReleaseTertiary(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.RELOAD && newState && !getReloadKey(stack)) { if(config.getPressReload(stack) != null) config.getPressReload(stack).accept(stack, config); return; } + if(keybind == EnumKeybind.RELOAD && !newState && getReloadKey(stack)) { if(config.getReleaseReload(stack) != null) config.getReleaseReload(stack).accept(stack, config); return; } } @Override @@ -59,7 +64,7 @@ public class ItemGunBase extends Item implements IKeybindReceiver { if(!isHeld) { this.setState(stack, GunState.DRAWING); - this.setTimer(stack, config.drawDuration); + this.setTimer(stack, config.getDrawDuration(stack)); return; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java index e09f0ec22..fbc3ec079 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java +++ b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java @@ -10,13 +10,15 @@ public class Receiver { protected int roundsPerCycle = 1; protected boolean refireOnHold = false; protected int burstSize = 1; - protected int delayAfterBurst; + protected int delayAfterBurst = 0; protected CasingEjector ejector = null; - protected IMagazine magazine; - - public Receiver setMag(IMagazine magazine) { - this.magazine = magazine; - return this; - } + + public Receiver dmg(float dmg) { this.baseDamage = dmg; return this; } + public Receiver delay(int delay) { this.delayAfterFire = delay; return this; } + public Receiver rounds(int rounds) { this.roundsPerCycle = rounds; return this; } + public Receiver auto(boolean auto) { this.refireOnHold = auto; return this; } + public Receiver burst(int size, int delay) { this.burstSize = size; this.delayAfterBurst = delay; return this; } + public Receiver burst(CasingEjector ejector) { this.ejector = ejector; return this; } + public Receiver mag(IMagazine magazine) { this.magazine = magazine; return this; } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java b/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java index 1a0aeaeec..27f659513 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java @@ -1,5 +1,6 @@ package com.hbm.items.weapon.sedna.mags; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; public interface IMagazine { @@ -13,7 +14,7 @@ public interface IMagazine { /** Sets the mag's ammo level */ public void setAmount(ItemStack stack, int amount); /** The action done at the end of one reload cycle, either loading one shell or replacing the whole mag */ - public void reloadAction(ItemStack stack); + public void reloadAction(ItemStack stack, EntityPlayer player); /** The stack that should be displayed for the ammo HUD */ public ItemStack getIcon(ItemStack stack); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java new file mode 100644 index 000000000..fc9a7f6ae --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineRevolverDrum.java @@ -0,0 +1,28 @@ +package com.hbm.items.weapon.sedna.mags; + +import com.hbm.items.weapon.sedna.BulletConfig; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** Uses individual bullets which are loaded all at once */ +public class MagazineRevolverDrum extends MagazineStandardBase { + + public MagazineRevolverDrum(int index, int capacity) { + super(index, capacity); + } + + @Override + public void reloadAction(ItemStack stack, EntityPlayer player) { + + } + + @Override + public ItemStack getIcon(ItemStack stack) { + Object o = this.getType(stack); + if(o instanceof BulletConfig) { + return ((BulletConfig) o).ammo.toStack(); + } + return null; + } +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineStandardBase.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineStandardBase.java index 09875ffe5..b066e2f91 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineStandardBase.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineStandardBase.java @@ -27,6 +27,8 @@ public abstract class MagazineStandardBase implements IMagazine { this.index = index; this.capacity = capacity; } + + public MagazineStandardBase addConfigs(BulletConfig... cfgs) { for(BulletConfig cfg : cfgs) acceptedBullets.add(cfg); return this; } @Override public Object getType(ItemStack stack) { diff --git a/src/main/resources/assets/hbm/textures/models/weapons/debug_gun.png b/src/main/resources/assets/hbm/textures/models/weapons/debug_gun.png new file mode 100644 index 000000000..49b083ca9 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/models/weapons/debug_gun.png differ diff --git a/src/main/resources/assets/hbm/textures/models/weapons/lil_pip.png b/src/main/resources/assets/hbm/textures/models/weapons/lil_pip.png deleted file mode 100644 index 7709cf279..000000000 Binary files a/src/main/resources/assets/hbm/textures/models/weapons/lil_pip.png and /dev/null differ