二次灾变在充能状态,瞄准射击初速为原本的三倍
This commit is contained in:
parent
5c6bdbba00
commit
f69b4997e0
8 changed files with 77 additions and 1 deletions
|
@ -321,6 +321,10 @@ public class ModSounds {
|
|||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_FIRE_3P = REGISTRY.register("secondary_cataclysm_fire_3p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_fire_3p")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_FAR = REGISTRY.register("secondary_cataclysm_far", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_far")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_VERYFAR = REGISTRY.register("secondary_cataclysm_veryfar", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_veryfar")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_FIRE_1P_CHARGE = REGISTRY.register("secondary_cataclysm_fire_1p_charge", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_fire_1p_charge")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_FIRE_3P_CHARGE = REGISTRY.register("secondary_cataclysm_fire_3p_charge", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_fire_3p_charge")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_FAR_CHARGE = REGISTRY.register("secondary_cataclysm_far_charge", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_far_charge")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_VERYFAR_CHARGE = REGISTRY.register("secondary_cataclysm_veryfar_charge", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_veryfar_charge")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_PREPARE_LOAD = REGISTRY.register("secondary_cataclysm_prepare_load", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_prepare_load")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_LOOP = REGISTRY.register("secondary_cataclysm_loop", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_loop")));
|
||||
public static final RegistryObject<SoundEvent> SECONDARY_CATACLYSM_END = REGISTRY.register("secondary_cataclysm_end", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("secondary_cataclysm_end")));
|
||||
|
|
|
@ -195,6 +195,32 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, AnimatedItem
|
|||
if (entity instanceof Player player) {
|
||||
GunsTool.setGunIntTag(stack, "MaxAmmo", getAmmoCount(player));
|
||||
}
|
||||
|
||||
if (entity instanceof Player player) {
|
||||
for (var cell : player.getInventory().items) {
|
||||
if (cell.is(ModItems.CELL.get())) {
|
||||
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||
var stackStorage = stack.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||
int stackMaxEnergy = stackStorage.getMaxEnergyStored();
|
||||
int stackEnergy = stackStorage.getEnergyStored();
|
||||
|
||||
assert cell.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||
var cellStorage = cell.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||
int cellEnergy = cellStorage.getEnergyStored();
|
||||
|
||||
int stackEnergyNeed = Math.min(cellEnergy, stackMaxEnergy - stackEnergy);
|
||||
|
||||
if (cellEnergy > 0) {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
iEnergyStorage -> iEnergyStorage.receiveEnergy(stackEnergyNeed, false)
|
||||
);
|
||||
}
|
||||
cell.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
cEnergy -> cEnergy.extractEnergy(stackEnergyNeed, false)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static boolean check(ItemStack stack) {
|
||||
|
|
|
@ -541,6 +541,13 @@ public class FireMessage {
|
|||
boolean zoom = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom;
|
||||
double spread = GunsTool.getGunDoubleTag(stack, "Spread");
|
||||
|
||||
AtomicBoolean flag = new AtomicBoolean(false);
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
iEnergyStorage -> flag.set(iEnergyStorage.getEnergyStored() >= 1500)
|
||||
);
|
||||
|
||||
boolean chargeFire = zoom && flag.get();
|
||||
|
||||
Level level = player.level();
|
||||
if (!level.isClientSide()) {
|
||||
GunGrenadeEntity gunGrenadeEntity = new GunGrenadeEntity(player, level,
|
||||
|
@ -555,7 +562,7 @@ public class FireMessage {
|
|||
}
|
||||
|
||||
gunGrenadeEntity.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
gunGrenadeEntity.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) GunsTool.getGunDoubleTag(stack, "Velocity", 0),
|
||||
gunGrenadeEntity.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (chargeFire ? 3 : 1) * (float) GunsTool.getGunDoubleTag(stack, "Velocity", 0),
|
||||
(float) (zoom ? 0.1 : spread));
|
||||
level.addFreshEntity(gunGrenadeEntity);
|
||||
}
|
||||
|
@ -575,6 +582,13 @@ public class FireMessage {
|
|||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_VERYFAR.get(), SoundSource.PLAYERS, 10, 1);
|
||||
}
|
||||
|
||||
if (chargeFire) {
|
||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||
energy -> energy.extractEnergy(1500, false)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
GunsTool.setGunIntTag(stack, "Ammo", GunsTool.getGunIntTag(stack, "Ammo", 0) - 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 6);
|
||||
|
||||
|
|
|
@ -2664,5 +2664,37 @@
|
|||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondary_cataclysm_fire_1p_charge": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:secondary_cataclysm/secondary_cataclysm_charge_fire_1p",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondary_cataclysm_fire_3p_charge": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:secondary_cataclysm/secondary_cataclysm_charge_fire_3p",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondary_cataclysm_far_charge": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:secondary_cataclysm/secondary_cataclysm_charge_far",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"secondary_cataclysm_veryfar_charge": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:secondary_cataclysm/secondary_cataclysm_charge_veryfar",
|
||||
"stream": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue