mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 18:01:33 +01:00
[BLEEDING] First go on generic speed attribute support.
This commit is contained in:
parent
a259f90d66
commit
2450636f3c
@ -237,6 +237,12 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
||||
return PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.SPEED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Reflection (scan for the attribute to get on startup and check for methods.)
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
// TODO: Ahhh...
|
||||
|
@ -112,6 +112,11 @@ public class MCAccessCB2512 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -148,11 +153,11 @@ public class MCAccessCB2512 implements MCAccess{
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,11 @@ public class MCAccessCB2545 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -148,11 +153,11 @@ public class MCAccessCB2545 implements MCAccess{
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,11 @@ public class MCAccessCB2602 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -149,11 +154,11 @@ public class MCAccessCB2602 implements MCAccess{
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,11 @@ public class MCAccessCB2645 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -150,11 +155,11 @@ public class MCAccessCB2645 implements MCAccess{
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,11 @@ public class MCAccessCB2691 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -152,11 +157,11 @@ public class MCAccessCB2691 implements MCAccess{
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,11 @@ public class MCAccessCB2763 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
@ -151,11 +156,11 @@ public class MCAccessCB2763 implements MCAccess{
|
||||
public boolean hasGravity(final Material mat) {
|
||||
// TODO: TEST: return mat.hasGravity();
|
||||
switch(mat){
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case SAND:
|
||||
case GRAVEL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,12 @@ public class MCAccessCB2794 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -115,6 +115,12 @@ public class MCAccessCB2808 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -116,6 +116,12 @@ public class MCAccessCB2882 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -116,6 +116,12 @@ public class MCAccessCB2922 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -116,6 +116,12 @@ public class MCAccessCB3026 implements MCAccess{
|
||||
else return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -135,6 +135,12 @@ public class MCAccessCB3043 implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
// TODO: Implement.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package fr.neatmonster.nocheatplus.compat.cb3100;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.AttributeInstance;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.Block;
|
||||
import net.minecraft.server.v1_7_R4.DamageSource;
|
||||
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 org.bukkit.Bukkit;
|
||||
@ -13,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -137,6 +140,12 @@ public class MCAccessCB3100 implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(final Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -3,24 +3,24 @@ package fr.neatmonster.nocheatplus.compat.cbdev;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R2.EntityBoat;
|
||||
import net.minecraft.server.v1_8_R2.EnumDirection;
|
||||
import net.minecraft.server.v1_8_R2.IBlockAccess;
|
||||
import net.minecraft.server.v1_8_R2.IBlockData;
|
||||
import net.minecraft.server.v1_8_R2.TileEntity;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.EntityBoat;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
import net.minecraft.server.v1_8_R3.IBlockAccess;
|
||||
import net.minecraft.server.v1_8_R3.IBlockData;
|
||||
import net.minecraft.server.v1_8_R3.TileEntity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
public class BlockCacheCBDev extends BlockCache implements IBlockAccess{
|
||||
|
||||
protected net.minecraft.server.v1_8_R2.WorldServer world;
|
||||
protected net.minecraft.server.v1_8_R3.WorldServer world;
|
||||
protected World bukkitWorld; // WHACKS
|
||||
|
||||
public BlockCacheCBDev(World world) {
|
||||
@ -54,7 +54,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess{
|
||||
@Override
|
||||
public double[] fetchBounds(final int x, final int y, final int z){
|
||||
final int id = getTypeId(x, y, z);
|
||||
final net.minecraft.server.v1_8_R2.Block block = net.minecraft.server.v1_8_R2.Block.getById(id);
|
||||
final net.minecraft.server.v1_8_R3.Block block = net.minecraft.server.v1_8_R3.Block.getById(id);
|
||||
if (block == null) {
|
||||
// TODO: Convention for null bounds -> full ?
|
||||
return null;
|
||||
@ -70,7 +70,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess{
|
||||
try{
|
||||
// TODO: Find some simplification!
|
||||
|
||||
final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
final net.minecraft.server.v1_8_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@ -78,7 +78,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess{
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Iterator iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final net.minecraft.server.v1_8_R2.Entity other = (net.minecraft.server.v1_8_R2.Entity) iterator.next();
|
||||
final net.minecraft.server.v1_8_R3.Entity other = (net.minecraft.server.v1_8_R3.Entity) iterator.next();
|
||||
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||
continue;
|
||||
}
|
||||
|
@ -1,19 +1,22 @@
|
||||
package fr.neatmonster.nocheatplus.compat.cbdev;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R2.Block;
|
||||
import net.minecraft.server.v1_8_R2.DamageSource;
|
||||
import net.minecraft.server.v1_8_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_8_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R2.MobEffectList;
|
||||
import net.minecraft.server.v1_8_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
import net.minecraft.server.v1_8_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.GenericAttributes;
|
||||
import net.minecraft.server.v1_8_R3.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,16 +33,16 @@ public class MCAccessCBDev implements MCAccess{
|
||||
*/
|
||||
public MCAccessCBDev() {
|
||||
getCommandMap();
|
||||
ReflectionUtil.checkMembers("net.minecraft.server.v1_8_R2.", new String[] {"Entity" , "dead"});
|
||||
ReflectionUtil.checkMembers("net.minecraft.server.v1_8_R3.", new String[] {"Entity" , "dead"});
|
||||
// block bounds, original: minX, maxX, minY, maxY, minZ, maxZ
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_8_R2.Block.class,
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_8_R3.Block.class,
|
||||
new String[]{"B", "C", "D", "E", "F", "G"}, double.class);
|
||||
// TODO: Nail it down further.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMCVersion() {
|
||||
// 1.8.3 (1_8_R2)
|
||||
// 1.8.4-1.8.6 (1_8_R3)
|
||||
return "1.8.3";
|
||||
}
|
||||
|
||||
@ -60,7 +63,7 @@ public class MCAccessCBDev implements MCAccess{
|
||||
|
||||
@Override
|
||||
public double getHeight(final Entity entity) {
|
||||
final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
final net.minecraft.server.v1_8_R3.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
|
||||
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
|
||||
if (entity instanceof LivingEntity) {
|
||||
@ -138,6 +141,12 @@ public class MCAccessCBDev implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
|
||||
|
||||
import net.minecraft.server.v1_8_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R1.Block;
|
||||
import net.minecraft.server.v1_8_R1.DamageSource;
|
||||
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 org.bukkit.Bukkit;
|
||||
@ -13,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -138,6 +141,12 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R2.Block;
|
||||
import net.minecraft.server.v1_8_R2.DamageSource;
|
||||
import net.minecraft.server.v1_8_R2.EntityComplexPart;
|
||||
import net.minecraft.server.v1_8_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R2.GenericAttributes;
|
||||
import net.minecraft.server.v1_8_R2.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -13,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -138,6 +141,12 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.AttributeInstance;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
import net.minecraft.server.v1_8_R3.EntityComplexPart;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.GenericAttributes;
|
||||
import net.minecraft.server.v1_8_R3.MobEffectList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -13,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -138,6 +141,12 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||
return attr.getValue() / attr.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInvulnerableTicks(final Player player) {
|
||||
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||
|
@ -142,7 +142,7 @@ public class SurvivalFly extends Check {
|
||||
// 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);
|
||||
final double walkSpeed = SurvivalFly.walkSpeed * ((double) data.walkSpeed / 0.2) * mcAccess.getSpeedAttributeMultiplier(player);
|
||||
|
||||
// Determine if the player is actually sprinting.
|
||||
final boolean sprinting;
|
||||
|
@ -92,6 +92,13 @@ public interface MCAccess {
|
||||
*/
|
||||
public double getFasterMovementAmplifier(Player player);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return A multiplier for the allowed speed, should be 1.0 if not possible to determine.
|
||||
*/
|
||||
public double getSpeedAttributeMultiplier(Player player);
|
||||
|
||||
public int getInvulnerableTicks(Player player);
|
||||
|
||||
public void setInvulnerableTicks(Player player, int ticks);
|
||||
|
Loading…
Reference in New Issue
Block a user