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)
|
@SideOnly(Side.CLIENT)
|
||||||
public boolean m2;// = false;
|
public boolean m2;// = false;
|
||||||
|
|
||||||
public int burstDuration = 0;
|
|
||||||
public ItemGunBase(GunConfiguration config) {
|
public ItemGunBase(GunConfiguration config) {
|
||||||
mainConfig = config;
|
mainConfig = config;
|
||||||
this.setMaxStackSize(1);
|
this.setMaxStackSize(1);
|
||||||
@ -133,7 +132,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
|||||||
setIsMouseDown(stack, false);
|
setIsMouseDown(stack, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(burstDuration > 0) {
|
if(getBurstDuration(stack) > 0) {
|
||||||
if(altConfig == null) {
|
if(altConfig == null) {
|
||||||
if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) {
|
if (world.getWorldTime() % mainConfig.firingDuration == 0 && tryShoot(stack, world, player, true)) {
|
||||||
fire(stack, world, player);
|
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) {
|
if(getIsAltDown(stack) && !isCurrentItem) {
|
||||||
setIsAltDown(stack, false);
|
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(validConfig && main && tryShoot(stack, world, player, main)) {
|
||||||
|
|
||||||
if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){
|
if(mainConfig.firingMode == GunConfiguration.FIRE_BURST){
|
||||||
if(burstDuration <= 0)
|
if(getBurstDuration(stack) <= 0)
|
||||||
burstDuration = mainConfig.firingDuration * mainConfig.roundsPerBurst;
|
setBurstDuration(stack,mainConfig.firingDuration * mainConfig.roundsPerBurst);
|
||||||
} else {
|
} else {
|
||||||
fire(stack, world, player);
|
fire(stack, world, player);
|
||||||
setDelay(stack, mainConfig.rateOfFire);
|
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(!main && altConfig != null && tryShoot(stack, world, player, main)) {
|
||||||
|
|
||||||
if(altConfig.firingMode == GunConfiguration.FIRE_BURST && burstDuration <= 0){
|
if(altConfig.firingMode == GunConfiguration.FIRE_BURST && getBurstDuration(stack) <= 0){
|
||||||
burstDuration = altConfig.firingDuration * altConfig.roundsPerBurst;
|
setBurstDuration(stack,altConfig.firingDuration * altConfig.roundsPerBurst);
|
||||||
} else {
|
} else {
|
||||||
altFire(stack, world, player);
|
altFire(stack, world, player);
|
||||||
setDelay(stack, altConfig.rateOfFire);
|
setDelay(stack, altConfig.rateOfFire);
|
||||||
@ -673,6 +673,14 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu
|
|||||||
public static int getMagType(ItemStack stack) {
|
public static int getMagType(ItemStack stack) {
|
||||||
return readNBT(stack, "magazineType");
|
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 ///
|
/// queued casing for ejection ///
|
||||||
public static void setCasing(ItemStack stack, BulletConfiguration bullet) {
|
public static void setCasing(ItemStack stack, BulletConfiguration bullet) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user