添加战术冲刺重量判定
This commit is contained in:
parent
09d28532d4
commit
33c8345f04
1 changed files with 5 additions and 13 deletions
|
@ -128,21 +128,13 @@ public class PlayerEventHandler {
|
||||||
private static void handleTacticalSprint(Player player) {
|
private static void handleTacticalSprint(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
int sprint_cost;
|
int sprintCost;
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
double weight = stack.getOrCreateTag().getDouble("weight");
|
double weight = stack.getOrCreateTag().getDouble("weight") + stack.getOrCreateTag().getDouble("custom_weight");
|
||||||
if (weight == 0) {
|
sprintCost = (int) (2 + 0.2 * weight);
|
||||||
sprint_cost = 3;
|
|
||||||
} else if (weight == 1) {
|
|
||||||
sprint_cost = 4;
|
|
||||||
} else if (weight == 2) {
|
|
||||||
sprint_cost = 5;
|
|
||||||
} else {
|
} else {
|
||||||
sprint_cost = 2;
|
sprintCost = 2;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sprint_cost = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.isSprinting()) {
|
if (!player.isSprinting()) {
|
||||||
|
@ -165,7 +157,7 @@ public class PlayerEventHandler {
|
||||||
|
|
||||||
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprint) {
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprint) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime - sprint_cost, 0, 1000);
|
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime - sprintCost, 0, 1000);
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 2, 0, false, false));
|
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 2, 0, false, false));
|
||||||
|
|
Loading…
Add table
Reference in a new issue