移除玩家冲刺procedure
This commit is contained in:
parent
ee83b49df9
commit
fb0831c6db
26 changed files with 64 additions and 83 deletions
|
@ -2,6 +2,6 @@
|
|||
"_fv": 57,
|
||||
"_type": "procedure",
|
||||
"definition": {
|
||||
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">player_ticks</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"item_nbt_num_get\"><value name=\"item\"><block type=\"entity_iteminhand\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">fireanim</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">unspringtable</field></block></value><value name=\"tagValue\"><block type=\"math_number\"><field name=\"NUM\">20</field></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"entity_issneaking\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"entity_isriding\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"B\"><block type=\"entity_isinwater\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"B\"><block type=\"logic_binary_ops\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get_logic\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:zooming</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">unspringtable</field></block></value><value name=\"tagValue\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"entity_nbt_num_get\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">unspringtable</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">unspringtable</field></block></value><value name=\"tagValue\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"entity_nbt_num_get\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">unspringtable</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get_logic\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:zooming</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_set_sprinting\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"boolean\"><block type=\"logic_boolean\"><field name=\"BOOL\">FALSE</field></block></value></block></statement></block></next></block></next></block></next></block></next></block></xml>"
|
||||
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">player_ticks</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"item_nbt_num_get\"><value name=\"item\"><block type=\"entity_iteminhand\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">fireanim</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">noRun</field></block></value><value name=\"tagValue\"><block type=\"math_number\"><field name=\"NUM\">20</field></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"logic_binary_ops\"><field name=\"OP\">OR</field><value name=\"A\"><block type=\"entity_issneaking\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"entity_isriding\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"B\"><block type=\"entity_isinwater\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><value name=\"B\"><block type=\"logic_binary_ops\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get_logic\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:zooming</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">noRun</field></block></value><value name=\"tagValue\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"math_binary_ops\"><field name=\"OP\">GT</field><value name=\"A\"><block type=\"entity_nbt_num_get\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">noRun</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">0</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_nbt_num_set\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">noRun</field></block></value><value name=\"tagValue\"><block type=\"math_dual_ops\"><field name=\"OP\">MINUS</field><value name=\"A\"><block type=\"entity_nbt_num_get\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">noRun</field></block></value></block></value><value name=\"B\"><block type=\"math_number\"><field name=\"NUM\">1</field></block></value></block></value></block></statement><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"variables_get_logic\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" is_player_var=\"true\" has_entity=\"true\"></mutation><field name=\"VAR\">global:zooming</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value><value name=\"B\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value></block></value><statement name=\"DO0\"><block type=\"entity_set_sprinting\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"boolean\"><block type=\"logic_boolean\"><field name=\"BOOL\">FALSE</field></block></value></block></statement></block></next></block></next></block></next></block></next></block></xml>"
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package net.mcreator.target.event;
|
|||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -42,27 +43,50 @@ public class PlayerEventHandler {
|
|||
}
|
||||
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
Level level = player.level();
|
||||
handlePlayerProne(player);
|
||||
handlePlayerSprint(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getBbHeight() <= 1) {
|
||||
player.getPersistentData().putDouble("prone", 3);
|
||||
}
|
||||
private static void handlePlayerProne(Player player) {
|
||||
Level level = player.level();
|
||||
|
||||
if (player.isShiftKeyDown() && level.getBlockState(BlockPos.containing(player.getX() + 0.7 * player.getLookAngle().x, player.getY() + 0.5, player.getZ() + 0.7 * player.getLookAngle().z)).canOcclude()
|
||||
&& !level.getBlockState(BlockPos.containing(player.getX() + 0.7 * player.getLookAngle().x, player.getY() + 1.5, player.getZ() + 0.7 * player.getLookAngle().z)).canOcclude()) {
|
||||
player.getPersistentData().putDouble("prone", 3);
|
||||
}
|
||||
if (player.getBbHeight() <= 1) {
|
||||
player.getPersistentData().putDouble("prone", 3);
|
||||
}
|
||||
|
||||
if (player.getPersistentData().getDouble("prone") > 0) {
|
||||
player.getPersistentData().putDouble("prone", (player.getPersistentData().getDouble("prone") - 1));
|
||||
}
|
||||
if (player.isShiftKeyDown() && level.getBlockState(BlockPos.containing(player.getX() + 0.7 * player.getLookAngle().x, player.getY() + 0.5, player.getZ() + 0.7 * player.getLookAngle().z)).canOcclude()
|
||||
&& !level.getBlockState(BlockPos.containing(player.getX() + 0.7 * player.getLookAngle().x, player.getY() + 1.5, player.getZ() + 0.7 * player.getLookAngle().z)).canOcclude()) {
|
||||
player.getPersistentData().putDouble("prone", 3);
|
||||
}
|
||||
|
||||
boolean flag = !(player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).refresh;
|
||||
if (player.getPersistentData().getDouble("prone") > 0) {
|
||||
player.getPersistentData().putDouble("prone", (player.getPersistentData().getDouble("prone") - 1));
|
||||
}
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.refresh = flag;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
boolean flag = !(player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).refresh;
|
||||
|
||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.refresh = flag;
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
|
||||
private static void handlePlayerSprint(Player player) {
|
||||
if (player.getMainHandItem().getOrCreateTag().getDouble("fireanim") > 0) {
|
||||
player.getPersistentData().putDouble("noRun", 20);
|
||||
}
|
||||
|
||||
if (player.isShiftKeyDown() || player.isPassenger() || player.isInWater() || (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
|
||||
player.getPersistentData().putDouble("noRun", 1);
|
||||
}
|
||||
|
||||
if (player.getPersistentData().getDouble("noRun") > 0) {
|
||||
player.getPersistentData().putDouble("noRun", (player.getPersistentData().getDouble("noRun") - 1));
|
||||
}
|
||||
|
||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
|
||||
player.setSprinting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class AK47Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak47.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class Aa12Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa12.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public class Abekiri extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ab.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ab.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Devotion extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload2"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.devotion.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class Hk416Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public class HuntingRifle extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.hunting_rifle.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.hunting_rifle.run"));
|
||||
}
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.hunting_rifle.idle"));
|
||||
|
|
|
@ -96,7 +96,7 @@ public class Kraber extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.kraber.reload2"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.kraber.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class M4Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class M60Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m60.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public class M79Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m79.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m79.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ public class M870Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m870.finish"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m870.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class M98bItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m98b.reload2"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m98b.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public class MarlinItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.marlin.finish"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.marlin.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class Minigun extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.minigun.draw"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.minigun.run"));
|
||||
}
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.minigun.idle"));
|
||||
|
|
|
@ -97,7 +97,7 @@ public class Mk14Item extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.model.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.model.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class RpgItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.rpg.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public class RpkItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak47.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public class SentinelItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.charge"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class SksItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload2"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sks.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class SvdItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.svd.reload2"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.svd.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class Taser extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.taser.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.taser.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Trachelium extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.trachelium.reload"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.trachelium.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class VectorItem extends GunItem implements GeoItem {
|
|||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.changefirerate"));
|
||||
}
|
||||
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("unspringtable") == 0) {
|
||||
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.vec.run"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class UnsprintableProcedure {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
execute(event, event.player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute(Entity entity) {
|
||||
execute(null, entity);
|
||||
}
|
||||
|
||||
private static void execute(@Nullable Event event, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("fireanim") > 0) {
|
||||
entity.getPersistentData().putDouble("unspringtable", 20);
|
||||
}
|
||||
if (entity.isShiftKeyDown() || entity.isPassenger() || entity.isInWater() || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
|
||||
entity.getPersistentData().putDouble("unspringtable", 1);
|
||||
}
|
||||
if (entity.getPersistentData().getDouble("unspringtable") > 0) {
|
||||
entity.getPersistentData().putDouble("unspringtable", (entity.getPersistentData().getDouble("unspringtable") - 1));
|
||||
}
|
||||
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
|
||||
entity.setSprinting(false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue