mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Converted burst fire gun system to use NBT
This commit is contained in:
parent
ad826215ee
commit
523d76133b
@ -56,7 +56,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean m2;// = false;
|
||||
|
||||
public int burstDuration = 0;
|
||||
public ItemGunBase(GunConfiguration config) {
|
||||
mainConfig = config;
|
||||
this.setMaxStackSize(1);
|
||||
@ -133,7 +132,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
setIsMouseDown(stack, false);
|
||||
}
|
||||
|
||||
if(burstDuration > 0) {
|
||||
if(getBurstDuration(stack) > 0) {
|
||||
if(altConfig == null) {
|
||||
if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) {
|
||||
fire(stack, world, player);
|
||||
@ -145,7 +144,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
}
|
||||
}
|
||||
|
||||
if(--burstDuration == 0) setDelay(stack, mainConfig.rateOfFire);
|
||||
setBurstDuration(stack, getBurstDuration(stack) - 1);
|
||||
if(getBurstDuration(stack) == 0) setDelay(stack, mainConfig.rateOfFire);
|
||||
}
|
||||
if(getIsAltDown(stack) && !isCurrentItem) {
|
||||
setIsAltDown(stack, false);
|
||||
@ -303,8 +303,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
if(validConfig && main && tryShoot(stack, world, player, main)) {
|
||||
|
||||
if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){
|
||||
if(burstDuration <= 0)
|
||||
burstDuration = mainConfig.firingDuration * mainConfig.roundsPerBurst;
|
||||
if(getBurstDuration(stack) <= 0)
|
||||
setBurstDuration(stack,mainConfig.firingDuration * mainConfig.roundsPerBurst);
|
||||
} else {
|
||||
fire(stack, world, player);
|
||||
setDelay(stack, mainConfig.rateOfFire);
|
||||
@ -317,8 +317,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
||||
|
||||
if(!main && altConfig != null && tryShoot(stack, world, player, main)) {
|
||||
|
||||
if(altConfig.firingMode == GunConfiguration.FIRE_BURST && burstDuration <= 0){
|
||||
burstDuration = altConfig.firingDuration * altConfig.roundsPerBurst;
|
||||
if(altConfig.firingMode == GunConfiguration.FIRE_BURST && getBurstDuration(stack) <= 0){
|
||||
setBurstDuration(stack,altConfig.firingDuration * altConfig.roundsPerBurst);
|
||||
} else {
|
||||
altFire(stack, world, player);
|
||||
setDelay(stack, altConfig.rateOfFire);
|
||||
@ -673,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