mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 19:43:07 +00:00
Add flight checker to prevent abilities from affecting flying players
This commit is contained in:
1 parent
e722279009
commit
21b1571868
3 files changed
+24
-3
No files matched your search
@@ -9,6 +9,7 @@ import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.controllers.AttributeController;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.util.AttributeAttackUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -106,7 +107,9 @@ public class ScriptPlayerEventHandler {
|
||||
Ability current = playerData.abilityData.getCurrentAbility();
|
||||
if (current == null || !current.hasAbilityMovement()) {
|
||||
player.motionX = 0;
|
||||
player.motionY = Math.min(player.motionY, 0); // Prevent jumping, allow gravity
|
||||
if (!AbilityController.Instance.isPlayerFlying(player)) {
|
||||
player.motionY = Math.min(player.motionY, 0);
|
||||
}
|
||||
player.motionZ = 0;
|
||||
player.velocityChanged = true;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.client.renderer.lightning.LightningBolt;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityController;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
@@ -133,9 +134,10 @@ public class ClientTickHandler {
|
||||
mc.thePlayer.motionZ = 0;
|
||||
}
|
||||
|
||||
// Prevent jumping: clamp upward motion when locked (allow gravity)
|
||||
// Prevent jumping when locked (allow gravity only if not flying)
|
||||
if ((ClientAbilityState.movementLocked || ClientAbilityState.positionLocked)
|
||||
&& !ClientAbilityState.hasAbilityMovement) {
|
||||
&& !ClientAbilityState.hasAbilityMovement
|
||||
&& !AbilityController.Instance.isPlayerFlying(mc.thePlayer)) {
|
||||
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user