mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
gun crap
This commit is contained in:
parent
833ae407e5
commit
32ab93f146
@ -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());
|
||||
|
||||
@ -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<BulletConfig> 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; }
|
||||
}
|
||||
|
||||
@ -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<Triplet<ItemStack, EnumKeybind, GunConfig>, Receiver> receiverDecider;
|
||||
protected Receiver[] receivers;
|
||||
protected float durability;
|
||||
protected int drawDuration = 0;
|
||||
protected Crosshair crosshair;
|
||||
/** Lambda functions for clicking shit */
|
||||
public BiConsumer<ItemStack, GunConfig> onPressPrimary;
|
||||
public BiConsumer<ItemStack, GunConfig> onPressSecondary;
|
||||
public BiConsumer<ItemStack, GunConfig> onPressTertiary;
|
||||
public BiConsumer<ItemStack, GunConfig> onPressReload;
|
||||
protected BiConsumer<ItemStack, GunConfig> onPressPrimary;
|
||||
protected BiConsumer<ItemStack, GunConfig> onPressSecondary;
|
||||
protected BiConsumer<ItemStack, GunConfig> onPressTertiary;
|
||||
protected BiConsumer<ItemStack, GunConfig> onPressReload;
|
||||
/** Lambda functions for releasing the aforementioned shit */
|
||||
public BiConsumer<ItemStack, GunConfig> onReleasePrimary;
|
||||
public BiConsumer<ItemStack, GunConfig> onReleaseSecondary;
|
||||
public BiConsumer<ItemStack, GunConfig> onReleaseTertiary;
|
||||
public BiConsumer<ItemStack, GunConfig> onReleaseReload;
|
||||
protected BiConsumer<ItemStack, GunConfig> onReleasePrimary;
|
||||
protected BiConsumer<ItemStack, GunConfig> onReleaseSecondary;
|
||||
protected BiConsumer<ItemStack, GunConfig> onReleaseTertiary;
|
||||
protected BiConsumer<ItemStack, GunConfig> 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<ItemStack, GunConfig> getPressPrimary(ItemStack stack) { return this.onPressPrimary; }
|
||||
public BiConsumer<ItemStack, GunConfig> getPressSecondary(ItemStack stack) { return this.onPressSecondary; }
|
||||
public BiConsumer<ItemStack, GunConfig> getPressTertiary(ItemStack stack) { return this.onPressTertiary; }
|
||||
public BiConsumer<ItemStack, GunConfig> getPressReload(ItemStack stack) { return this.onPressReload; }
|
||||
|
||||
public BiConsumer<ItemStack, GunConfig> getReleasePrimary(ItemStack stack) { return this.onReleasePrimary; }
|
||||
public BiConsumer<ItemStack, GunConfig> getReleaseSecondary(ItemStack stack) { return this.onReleaseSecondary; }
|
||||
public BiConsumer<ItemStack, GunConfig> getReleaseTertiary(ItemStack stack) { return this.onReleaseTertiary; }
|
||||
public BiConsumer<ItemStack, GunConfig> 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<ItemStack, GunConfig> lambda) { this.onPressPrimary = lambda; return this; }
|
||||
public GunConfig ps(BiConsumer<ItemStack, GunConfig> lambda) { this.onPressSecondary = lambda; return this; }
|
||||
public GunConfig pt(BiConsumer<ItemStack, GunConfig> lambda) { this.onPressTertiary = lambda; return this; }
|
||||
public GunConfig pr(BiConsumer<ItemStack, GunConfig> lambda) { this.onPressReload = lambda; return this; }
|
||||
|
||||
public GunConfig rp(BiConsumer<ItemStack, GunConfig> lambda) { this.onReleasePrimary = lambda; return this; }
|
||||
public GunConfig rs(BiConsumer<ItemStack, GunConfig> lambda) { this.onReleaseSecondary = lambda; return this; }
|
||||
public GunConfig rt(BiConsumer<ItemStack, GunConfig> lambda) { this.onReleaseTertiary = lambda; return this; }
|
||||
public GunConfig rr(BiConsumer<ItemStack, GunConfig> lambda) { this.onReleaseReload = lambda; return this; }
|
||||
}
|
||||
|
||||
25
src/main/java/com/hbm/items/weapon/sedna/GunFactory.java
Normal file
25
src/main/java/com/hbm/items/weapon/sedna/GunFactory.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB |
Loading…
x
Reference in New Issue
Block a user