mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-06-26 06:14:42 +02:00
More complete go on speed attributes.
* Undo the sprint boost modifier until we add it (minimize code change). * Implement methods for MCAccess implementations down to 1_6_R1.
This commit is contained in:
parent
2450636f3c
commit
cb62547fc0
|
@ -243,6 +243,11 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
// TODO: Ahhh...
|
||||
|
|
|
@ -117,6 +117,11 @@ public class MCAccessCB2512 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -117,6 +117,11 @@ public class MCAccessCB2545 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -118,6 +118,11 @@ public class MCAccessCB2602 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -119,6 +119,11 @@ public class MCAccessCB2645 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -121,6 +121,11 @@ public class MCAccessCB2691 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -119,6 +119,11 @@ public class MCAccessCB2763 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
return player.isSprinting() ? 1.3 : 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -6,6 +6,9 @@ import net.minecraft.server.v1_6_R1.DamageSource;
|
|||
import net.minecraft.server.v1_6_R1.EntityComplexPart;
|
||||
import net.minecraft.server.v1_6_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R1.MobEffectList;
|
||||
import net.minecraft.server.v1_6_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_6_R1.AttributeModifier;
|
||||
import net.minecraft.server.v1_6_R1.GenericAttributes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,12 +17,14 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.craftbukkit.v1_6_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -116,8 +121,18 @@ public class MCAccessCB2794 implements MCAccess{
|
|||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d);
|
||||
return attr.e() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,9 @@ import net.minecraft.server.v1_6_R2.DamageSource;
|
|||
import net.minecraft.server.v1_6_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_6_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R2.MobEffectList;
|
||||
import net.minecraft.server.v1_6_R2.AttributeInstance;
|
||||
import net.minecraft.server.v1_6_R2.AttributeModifier;
|
||||
import net.minecraft.server.v1_6_R2.GenericAttributes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,12 +17,14 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -117,8 +122,18 @@ public class MCAccessCB2808 implements MCAccess{
|
|||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,9 @@ import net.minecraft.server.v1_6_R3.DamageSource;
|
|||
import net.minecraft.server.v1_6_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_6_R3.MobEffectList;
|
||||
import net.minecraft.server.v1_6_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_6_R3.AttributeModifier;
|
||||
import net.minecraft.server.v1_6_R3.GenericAttributes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,12 +17,14 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -118,8 +123,18 @@ public class MCAccessCB2882 implements MCAccess{
|
|||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,9 @@ import net.minecraft.server.v1_7_R1.DamageSource;
|
|||
import net.minecraft.server.v1_7_R1.EntityComplexPart;
|
||||
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R1.MobEffectList;
|
||||
import net.minecraft.server.v1_7_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_7_R1.AttributeModifier;
|
||||
import net.minecraft.server.v1_7_R1.GenericAttributes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,12 +17,14 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -118,8 +123,18 @@ public class MCAccessCB2922 implements MCAccess{
|
|||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.minecraft.server.v1_7_R2.DamageSource;
|
|||
import net.minecraft.server.v1_7_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_7_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R2.MobEffectList;
|
||||
import net.minecraft.server.v1_7_R2.AttributeModifier;
|
||||
import net.minecraft.server.v1_7_R2.GenericAttributes;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -14,12 +16,14 @@ import org.bukkit.command.CommandMap;
|
|||
import org.bukkit.craftbukkit.v1_7_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -122,6 +126,16 @@ public class MCAccessCB3026 implements MCAccess{
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package fr.neatmonster.nocheatplus.compat.cb3043;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_7_R3.AttributeModifier;
|
||||
import net.minecraft.server.v1_7_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R3.Block;
|
||||
import net.minecraft.server.v1_7_R3.DamageSource;
|
||||
import net.minecraft.server.v1_7_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R3.GenericAttributes;
|
||||
import net.minecraft.server.v1_7_R3.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -13,6 +16,7 @@ import org.bukkit.World;
|
|||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -20,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -137,8 +142,18 @@ public class MCAccessCB3043 implements MCAccess{
|
|||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.server.v1_7_R4.EntityComplexPart;
|
|||
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R4.GenericAttributes;
|
||||
import net.minecraft.server.v1_7_R4.MobEffectList;
|
||||
import net.minecraft.server.v1_7_R4.AttributeModifier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -146,6 +148,16 @@ public class MCAccessCB3100 implements MCAccess{
|
|||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus.compat.cbdev;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R3.AttributeModifier;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -147,6 +149,16 @@ public class MCAccessCBDev implements MCAccess{
|
|||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.server.v1_8_R1.EntityComplexPart;
|
|||
import net.minecraft.server.v1_8_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R1.GenericAttributes;
|
||||
import net.minecraft.server.v1_8_R1.MobEffectList;
|
||||
import net.minecraft.server.v1_8_R1.AttributeModifier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -147,6 +149,16 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
|
|||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R2.AttributeModifier;
|
||||
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R2.Block;
|
||||
import net.minecraft.server.v1_8_R2.DamageSource;
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -147,6 +149,16 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
|
|||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R3.AttributeModifier;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
|
@ -147,6 +149,16 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
|
|||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSprintAttributeMultiplier(Player player) {
|
||||
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
|
|
@ -108,7 +108,8 @@ public class MovingData extends ACheckData {
|
|||
public int bunnyhopDelay;
|
||||
public double jumpAmplifier;
|
||||
/** Last time the player was actually sprinting. */
|
||||
public long timeSprinting = 0;
|
||||
public long timeSprinting = 0;
|
||||
public double multSprinting = 1.3; // Multiplier at the last time sprinting.
|
||||
|
||||
/** Tick at which walk/fly speeds got changed last time. */
|
||||
public int speedTick = 0;
|
||||
|
|
|
@ -436,12 +436,15 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||
// Hard to confine assumesprint further (some logics change with hdist or sprinting).
|
||||
if (player.getFoodLevel() > 5) {
|
||||
data.timeSprinting = time;
|
||||
data.multSprinting = mcAccess.getSprintAttributeMultiplier(player);
|
||||
}
|
||||
else if (time < data.timeSprinting) {
|
||||
// TODO: Ensure that its not reset within latency/cooldown.
|
||||
data.timeSprinting = 0;
|
||||
}
|
||||
// else: keep sprinting time.
|
||||
else {
|
||||
// keep sprinting time.
|
||||
}
|
||||
}
|
||||
else{
|
||||
// Reset if not actually sprinting.
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SurvivalFly extends Check {
|
|||
public static final double walkSpeed = 0.221D;
|
||||
|
||||
public static final double modSneak = 0.13D / walkSpeed;
|
||||
public static final double modSprint = 0.29D / walkSpeed; // TODO: without bunny 0.29 / practical is 0.35
|
||||
// public static final double modSprint = 0.29D / walkSpeed; // TODO: without bunny 0.29 / practical is 0.35
|
||||
|
||||
public static final double modBlock = 0.16D / walkSpeed;
|
||||
public static final double modSwim = 0.115D / walkSpeed;
|
||||
|
@ -60,21 +60,21 @@ public class SurvivalFly extends Check {
|
|||
public static final double hBufMax = 1.0;
|
||||
|
||||
// Vertical speeds/modifiers.
|
||||
public static final double climbSpeed = walkSpeed * modSprint; // TODO..
|
||||
public static final double climbSpeed = walkSpeed * 1.3; // TODO: Check if the factor is needed!
|
||||
|
||||
// Other.
|
||||
/** Bunny-hop delay. */
|
||||
private static final int bunnyHopMax = 10;
|
||||
/** Divisor vs. last hDist for minimum slow down. */
|
||||
private static final double bunnyDivFriction = 160.0; // Rather in-air, blocks would differ by friction.
|
||||
|
||||
|
||||
// Gravity.
|
||||
public static final double gravity = 0.0774; // TODO: Model / check.
|
||||
|
||||
|
||||
// Friction by medium.
|
||||
public static final double FRICTION_MEDIUM_AIR = 0.98; // TODO: Check
|
||||
public static final double FRICTION_MEDIUM_LIQUID = 0.89; // Rough estimate for horizontal move sprint-jump into water.
|
||||
|
||||
|
||||
// TODO: Friction by block to walk on (horizontal only, possibly to be in BlockProperties rather).
|
||||
|
||||
/** To join some tags with moving check violations. */
|
||||
|
@ -139,11 +139,6 @@ public class SurvivalFly extends Check {
|
|||
final boolean resetTo = toOnGround || to.isResetCond();
|
||||
final boolean resetFrom;
|
||||
|
||||
// Use the player-specific walk speed.
|
||||
// TODO: Might get from listener.
|
||||
// TODO: Use in lostground?
|
||||
final double walkSpeed = SurvivalFly.walkSpeed * ((double) data.walkSpeed / 0.2) * mcAccess.getSpeedAttributeMultiplier(player);
|
||||
|
||||
// Determine if the player is actually sprinting.
|
||||
final boolean sprinting;
|
||||
if (data.lostSprintCount > 0) {
|
||||
|
@ -156,13 +151,13 @@ public class SurvivalFly extends Check {
|
|||
tags.add("invalidate_lostsprint");
|
||||
sprinting = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
tags.add("lostsprint");
|
||||
sprinting = true;
|
||||
if (data.lostSprintCount < 3 && to.isOnGround() || to.isResetCond()) {
|
||||
data.lostSprintCount = 0;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.lostSprintCount --;
|
||||
}
|
||||
}
|
||||
|
@ -174,10 +169,15 @@ public class SurvivalFly extends Check {
|
|||
}
|
||||
sprinting = true;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
sprinting = false;
|
||||
}
|
||||
|
||||
|
||||
// Use the player-specific walk speed.
|
||||
// TODO: Might get from listener.
|
||||
// TODO: Use in lostground?
|
||||
final double walkSpeed = SurvivalFly.walkSpeed * ((double) data.walkSpeed / 0.2) * mcAccess.getSpeedAttributeMultiplier(player) * (sprinting ? 1.0 / data.multSprinting : 1.0);
|
||||
|
||||
setNextFriction(from, to, data, cc);
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -193,7 +193,7 @@ public class SurvivalFly extends Check {
|
|||
else if (isSamePos) {
|
||||
resetFrom = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// TODO: More refined conditions possible ?
|
||||
// TODO: Consider if (!resetTo) ?
|
||||
// Check lost-ground workarounds.
|
||||
|
@ -241,7 +241,7 @@ public class SurvivalFly extends Check {
|
|||
hDistanceAboveLimit = res[1];
|
||||
hFreedom = res[2];
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.clearActiveHorVel();
|
||||
hFreedom = 0.0;
|
||||
if (resetFrom && data.bunnyhopDelay <= 6) {
|
||||
|
@ -326,7 +326,7 @@ public class SurvivalFly extends Check {
|
|||
vAllowedDistance = res[0];
|
||||
vDistanceAboveLimit = res[1];
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Check y-distance for normal jumping, like in air.
|
||||
// TODO: Can it be easily transformed to a more accurate max. absolute height?
|
||||
vAllowedDistance = 1.35D + data.getVerticalFreedom();
|
||||
|
@ -408,7 +408,7 @@ public class SurvivalFly extends Check {
|
|||
final Location vLoc = handleViolation(now, result, player, from, to, data, cc);
|
||||
if (vLoc != null) return vLoc;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Slowly reduce the level with each event, if violations have not recently happened.
|
||||
if (now - data.sfVLTime > cc.survivalFlyVLFreeze) {
|
||||
data.survivalFlyVL *= 0.95D;
|
||||
|
@ -436,7 +436,7 @@ public class SurvivalFly extends Check {
|
|||
// Consent with ground.
|
||||
data.mediumLiftOff = MediumLiftOff.GROUND;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.mediumLiftOff = MediumLiftOff.LIMIT_JUMP;
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ public class SurvivalFly extends Check {
|
|||
else if (to.isNextToGround(0.15, 0.4)) {
|
||||
data.mediumLiftOff = MediumLiftOff.GROUND;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.mediumLiftOff = MediumLiftOff.LIMIT_JUMP;
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ public class SurvivalFly extends Check {
|
|||
// TODO: Where exactly to put noFallAssumeGround ?
|
||||
data.mediumLiftOff = MediumLiftOff.GROUND;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Keep medium.
|
||||
// TODO: Is above stairs ?
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ public class SurvivalFly extends Check {
|
|||
data.sfLowJump = false;
|
||||
// not resetting nolowjump (?)...
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.sfJumpPhase++;
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ public class SurvivalFly extends Check {
|
|||
data.lastFrictionVertical = data.nextFrictionVertical;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set data.nextFriction according to media.
|
||||
* @param from
|
||||
|
@ -563,7 +563,7 @@ public class SurvivalFly extends Check {
|
|||
else {
|
||||
// TODO: Friction for walking on blocks (!).
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -604,7 +604,7 @@ public class SurvivalFly extends Check {
|
|||
// The hard way.
|
||||
hAllowedDistance *= modDepthStrider[level];
|
||||
if (sprinting) {
|
||||
hAllowedDistance *= modSprint;
|
||||
hAllowedDistance *= data.multSprinting;
|
||||
}
|
||||
}
|
||||
// (Friction is used as is.)
|
||||
|
@ -621,7 +621,7 @@ public class SurvivalFly extends Check {
|
|||
hAllowedDistance = walkSpeed * cc.survivalFlyWalkingSpeed / 100D;
|
||||
}
|
||||
else {
|
||||
hAllowedDistance = walkSpeed * modSprint * cc.survivalFlySprintingSpeed / 100D;
|
||||
hAllowedDistance = walkSpeed * data.multSprinting * cc.survivalFlySprintingSpeed / 100D;
|
||||
}
|
||||
friction = 0.0; // Ensure friction can't be used to speed. TODO: Set.
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ public class SurvivalFly extends Check {
|
|||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// TODO: Just to exclude source of error, might be redundant.
|
||||
data.vDistAcc.clear();
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ public class SurvivalFly extends Check {
|
|||
// i1 = 0;
|
||||
// i2 = 1;
|
||||
// }
|
||||
// else{
|
||||
// else {
|
||||
i1 = 1;
|
||||
i2 = 2;
|
||||
// }
|
||||
|
@ -822,7 +822,7 @@ public class SurvivalFly extends Check {
|
|||
// Note: aDiff should be < 0.0625 here.
|
||||
return Math.max(Math.abs(-0.0625 - diff), 0.001);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 0.0625 + diff;
|
||||
}
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ public class SurvivalFly extends Check {
|
|||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Decrease
|
||||
tags.add("ychdec");
|
||||
// Detect low jumping.
|
||||
|
@ -1163,13 +1163,13 @@ public class SurvivalFly extends Check {
|
|||
tags.add("web_step");
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// TODO: Could prevent not moving down if not on ground (or on ladder or in liquid?).
|
||||
vAllowedDistance = from.isOnGround() ? 0.1D : 0;
|
||||
}
|
||||
vDistanceAboveLimit = yDistance - vAllowedDistance;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Descending in web.
|
||||
// TODO: Implement something (at least for being in web with the feet or block above)?
|
||||
}
|
||||
|
@ -1352,7 +1352,7 @@ public class SurvivalFly extends Check {
|
|||
if (setBackSafe) {
|
||||
data.setSetBack(from);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Keep Set-back.
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ public class SurvivalFly extends Check {
|
|||
// Set-back + view direction of to (more smooth).
|
||||
return data.getSetBack(to);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
data.clearAccounting();
|
||||
data.sfJumpPhase = 0;
|
||||
// Cancelled by other plugin, or no cancel set by configuration.
|
||||
|
@ -1429,12 +1429,12 @@ public class SurvivalFly extends Check {
|
|||
data.prepareSetBack(newTo);
|
||||
player.teleport(newTo, TeleportCause.PLUGIN);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Solve by extra actions ? Special case (probably never happens)?
|
||||
player.kickPlayer("Hovering?");
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,13 @@ public interface MCAccess {
|
|||
*/
|
||||
public double getSpeedAttributeMultiplier(Player player);
|
||||
|
||||
/**
|
||||
* Modifier for sprinting.
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public double getSprintAttributeMultiplier(Player player);
|
||||
|
||||
public int getInvulnerableTicks(Player player);
|
||||
|
||||
public void setInvulnerableTicks(Player player, int ticks);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package fr.neatmonster.nocheatplus.utilities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AttribUtil {
|
||||
public static final UUID ID_SPRINT_BOOST = IdUtil.UUIDFromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
|
||||
/**
|
||||
* Get a multiplier for an AttributeModifier.
|
||||
* @param operator Exclusively allows operator 2. Otherwise will throw an IllegalArgumentException.
|
||||
* @param value
|
||||
* @throws IllegalArgumentException if the modifier is not 2.
|
||||
* @return
|
||||
*/
|
||||
public static double getMultiplier(int operator, double value) {
|
||||
switch(operator) {
|
||||
case 2:
|
||||
return 1.0 + value;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported operator: " + operator);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user