mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
commit
3ea888eccf
@ -25,6 +25,8 @@ public class GunConfiguration implements Cloneable {
|
||||
public int rateOfFire;
|
||||
//amount of bullets fired per delay passed
|
||||
public int roundsPerCycle;
|
||||
/** Amount of rounds per burst, irrelevant if not a burst fire weapon**/
|
||||
public int roundsPerBurst;
|
||||
//0 = normal, 1 = release, 2 = both
|
||||
public int gunMode;
|
||||
//0 = manual, 1 = automatic
|
||||
@ -46,7 +48,7 @@ public class GunConfiguration implements Cloneable {
|
||||
//how long the reload animation will play
|
||||
//MUST BE GREATER THAN ZERO ! ! !
|
||||
public int reloadDuration;
|
||||
//duration of every animation cycle
|
||||
//duration of every animation cycle, used also for how quickly a burst fire rifle can fire
|
||||
public int firingDuration;
|
||||
//sound path to the reload sound
|
||||
public String reloadSound = "";
|
||||
@ -94,6 +96,7 @@ public class GunConfiguration implements Cloneable {
|
||||
|
||||
public static final int FIRE_MANUAL = 0;
|
||||
public static final int FIRE_AUTO = 1;
|
||||
public static final int FIRE_BURST = 2;
|
||||
|
||||
public static final int RELOAD_NONE = 0;
|
||||
public static final int RELOAD_FULL = 1;
|
||||
|
||||
@ -62,7 +62,7 @@ public class Gun45ACPFactory {
|
||||
config.firingMode = GunConfiguration.FIRE_MANUAL;
|
||||
config.reloadDuration = 10;
|
||||
config.firingDuration = 8;
|
||||
config.ammoCap = 16;
|
||||
config.ammoCap = 21;
|
||||
config.durability = 10000;
|
||||
config.reloadType = 1;
|
||||
config.allowsInfinity = true;
|
||||
@ -91,6 +91,17 @@ public class Gun45ACPFactory {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static GunConfiguration getUACPistolBurstConfig() {
|
||||
GunConfiguration config = getUACPistolConfig();
|
||||
config.rateOfFire = 5;
|
||||
config.roundsPerBurst = 3;
|
||||
config.firingDuration = 2;
|
||||
config.gunMode = GunConfiguration.MODE_NORMAL;
|
||||
config.firingMode = GunConfiguration.FIRE_BURST;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static GunConfiguration getUACSMGConfig() {
|
||||
GunConfiguration config = new GunConfiguration();
|
||||
|
||||
|
||||
@ -157,7 +157,18 @@ public class Gun50BMGFactory {
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
public static GunConfiguration getAR15BurstConfig(){
|
||||
GunConfiguration config = getAR15Config();
|
||||
config.rateOfFire = 4;
|
||||
config.roundsPerBurst = 3;
|
||||
config.firingDuration = 2;
|
||||
config.gunMode = GunConfiguration.MODE_NORMAL;
|
||||
config.firingMode = GunConfiguration.FIRE_BURST;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static GunConfiguration getM2Config() {
|
||||
GunConfiguration config = getAR15Config();
|
||||
|
||||
|
||||
@ -4229,8 +4229,8 @@ public class ModItems {
|
||||
gun_glass_cannon = new ItemEnergyGunBase(GunPoweredFactory.getGlassCannonConfig()).setFull3D().setUnlocalizedName("gun_glass_cannon").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter");
|
||||
gun_m2 = new ItemGunBase(Gun50BMGFactory.getM2Config()).setFull3D().setUnlocalizedName("gun_m2").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter");
|
||||
gun_lunatic_marksman = new ItemGunBase(Gun50BMGFactory.getLunaticMarksman()).setFull3D().setUnlocalizedName("gun_lunatic_marksman").setCreativeTab(MainRegistry.weaponTab);
|
||||
gun_uac_pistol = new ItemGunBase(Gun45ACPFactory.getUACPistolConfig()).setFull3D().setUnlocalizedName("gun_uac_pistol").setCreativeTab(MainRegistry.weaponTab);
|
||||
|
||||
gun_uac_pistol = new ItemGunBase(Gun45ACPFactory.getUACPistolConfig(), Gun45ACPFactory.getUACPistolBurstConfig()).setFull3D().setUnlocalizedName("gun_uac_pistol").setCreativeTab(MainRegistry.weaponTab);
|
||||
|
||||
ToolMaterial matCrucible = EnumHelper.addToolMaterial("CRUCIBLE", 10, 3, 50.0F, 100.0F, 0);
|
||||
crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible");
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
public boolean m1;// = false;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean m2;// = false;
|
||||
|
||||
|
||||
public ItemGunBase(GunConfiguration config) {
|
||||
mainConfig = config;
|
||||
this.setMaxStackSize(1);
|
||||
@ -131,13 +131,27 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
if(getIsMouseDown(stack) && !(player.getHeldItem() == stack)) {
|
||||
setIsMouseDown(stack, false);
|
||||
}
|
||||
|
||||
|
||||
if(getBurstDuration(stack) > 0) {
|
||||
if(altConfig == null) {
|
||||
if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) {
|
||||
fire(stack, world, player);
|
||||
}
|
||||
} else {
|
||||
boolean canFire = altConfig.firingDuration == 1 || world.getWorldTime() % altConfig.firingDuration == 0;
|
||||
if (canFire && tryShoot(stack, world, player, false)) {
|
||||
altFire(stack, world, player);
|
||||
}
|
||||
}
|
||||
|
||||
setBurstDuration(stack, getBurstDuration(stack) - 1);
|
||||
if(getBurstDuration(stack) == 0) setDelay(stack, mainConfig.rateOfFire);
|
||||
}
|
||||
if(getIsAltDown(stack) && !isCurrentItem) {
|
||||
setIsAltDown(stack, false);
|
||||
}
|
||||
|
||||
if(GeneralConfig.enableGuns && mainConfig.firingMode == 1 && getIsMouseDown(stack) && tryShoot(stack, world, player, isCurrentItem)) {
|
||||
|
||||
fire(stack, world, player);
|
||||
setDelay(stack, mainConfig.rateOfFire);
|
||||
}
|
||||
@ -284,17 +298,32 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
//called on click (server side, called by mouse packet) for semi-automatics and specific events
|
||||
public void startAction(ItemStack stack, World world, EntityPlayer player, boolean main) {
|
||||
|
||||
if(mainConfig.firingMode == mainConfig.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) {
|
||||
fire(stack, world, player);
|
||||
setDelay(stack, mainConfig.rateOfFire);
|
||||
boolean validConfig = mainConfig.firingMode == GunConfiguration.FIRE_MANUAL || mainConfig.firingMode == GunConfiguration.FIRE_BURST;
|
||||
|
||||
if(validConfig && main && tryShoot(stack, world, player, main)) {
|
||||
|
||||
if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){
|
||||
if(getBurstDuration(stack) <= 0)
|
||||
setBurstDuration(stack,mainConfig.firingDuration * mainConfig.roundsPerBurst);
|
||||
} else {
|
||||
fire(stack, world, player);
|
||||
setDelay(stack, mainConfig.rateOfFire);
|
||||
}
|
||||
|
||||
//setMag(stack, getMag(stack) - 1);
|
||||
//useUpAmmo(player, stack, main);
|
||||
//player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
if(!main && altConfig != null && tryShoot(stack, world, player, main)) {
|
||||
altFire(stack, world, player);
|
||||
setDelay(stack, altConfig.rateOfFire);
|
||||
|
||||
if(altConfig.firingMode == GunConfiguration.FIRE_BURST && getBurstDuration(stack) <= 0){
|
||||
setBurstDuration(stack,altConfig.firingDuration * altConfig.roundsPerBurst);
|
||||
} else {
|
||||
altFire(stack, world, player);
|
||||
setDelay(stack, altConfig.rateOfFire);
|
||||
}
|
||||
|
||||
//useUpAmmo(player, stack, main);
|
||||
//player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
@ -644,6 +673,14 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
public static int getMagType(ItemStack stack) {
|
||||
return readNBT(stack, "magazineType");
|
||||
}
|
||||
/// Sets how long a burst fires for, only useful for burst fire weapons ///
|
||||
public static void setBurstDuration(ItemStack stack, int i) {
|
||||
writeNBT(stack, "bduration", i);
|
||||
}
|
||||
|
||||
public static int getBurstDuration(ItemStack stack) {
|
||||
return readNBT(stack, "bduration");
|
||||
}
|
||||
|
||||
/// queued casing for ejection ///
|
||||
public static void setCasing(ItemStack stack, BulletConfiguration bullet) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user