mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-26 02:17:42 +01:00
Re-add 1.6.1 native support (removing is not worth the support load).
This commit is contained in:
parent
94b10b3cde
commit
a97995c99a
37
NCPCompatCB2794/pom.xml
Normal file
37
NCPCompatCB2794/pom.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcompatcb2794</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>NCPCompatCB2794</name>
|
||||||
|
<version>static</version>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>nocheatplus-parent</artifactId>
|
||||||
|
<version>static</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcore</artifactId>
|
||||||
|
<version>static</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
<version>1.6.1-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.6.1-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<description>Compatibility for CB 2794 (MC 1.6.1).
|
||||||
|
|
||||||
|
Version updating is done for the NoCheatPlus sub-module.</description>
|
||||||
|
</project>
|
@ -0,0 +1,127 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.compat.cb2794;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_6_R1.AxisAlignedBB;
|
||||||
|
import net.minecraft.server.v1_6_R1.EntityBoat;
|
||||||
|
import net.minecraft.server.v1_6_R1.IBlockAccess;
|
||||||
|
import net.minecraft.server.v1_6_R1.Material;
|
||||||
|
import net.minecraft.server.v1_6_R1.TileEntity;
|
||||||
|
import net.minecraft.server.v1_6_R1.Vec3DPool;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_6_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftEntity;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||||
|
|
||||||
|
public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
|
||||||
|
|
||||||
|
/** Box for one time use, no nesting, no extra storing this(!). */
|
||||||
|
protected static final AxisAlignedBB useBox = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
protected net.minecraft.server.v1_6_R1.World world;
|
||||||
|
|
||||||
|
public BlockCacheCB2794(World world) {
|
||||||
|
setAccess(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAccess(World world) {
|
||||||
|
this.world = world == null ? null : ((CraftWorld) world).getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fetchTypeId(final int x, final int y, final int z) {
|
||||||
|
return world.getTypeId(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fetchData(final int x, final int y, final int z) {
|
||||||
|
return world.getData(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double[] fetchBounds(final int x, final int y, final int z){
|
||||||
|
|
||||||
|
// TODO: change api for this / use nodes (!)
|
||||||
|
final int id = getTypeId(x, y, z);
|
||||||
|
final net.minecraft.server.v1_6_R1.Block block = net.minecraft.server.v1_6_R1.Block.byId[id];
|
||||||
|
if (block == null) return null;
|
||||||
|
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
|
||||||
|
|
||||||
|
// minX, minY, minZ, maxX, maxY, maxZ
|
||||||
|
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||||
|
try{
|
||||||
|
// TODO: Probably check other ids too before doing this ?
|
||||||
|
|
||||||
|
final net.minecraft.server.v1_6_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
|
final AxisAlignedBB box = useBox.b(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
final List list = world.getEntities(mcEntity, box);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
final Iterator iterator = list.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
final net.minecraft.server.v1_6_R1.Entity other = (net.minecraft.server.v1_6_R1.Entity) iterator.next();
|
||||||
|
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Still check this for some reason.
|
||||||
|
final AxisAlignedBB otherBox = other.boundingBox;
|
||||||
|
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable t){
|
||||||
|
// Ignore exceptions (Context: DisguiseCraft).
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cleanup() {
|
||||||
|
super.cleanup();
|
||||||
|
world = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getMaterial(final int x, final int y, final int z) {
|
||||||
|
return world.getMaterial(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity(final int x, final int y, final int z) {
|
||||||
|
return world.getTileEntity(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vec3DPool getVec3DPool() {
|
||||||
|
return world.getVec3DPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockPower(final int arg0, final int arg1, final int arg2, final int arg3) {
|
||||||
|
return world.getBlockPower(arg0, arg1, arg2, arg3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean u(final int arg0, final int arg1, final int arg2) {
|
||||||
|
return world.u(arg0, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.compat.cb2794;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_6_R1.AxisAlignedBB;
|
||||||
|
import net.minecraft.server.v1_6_R1.Block;
|
||||||
|
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 org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
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.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.BlockCache;
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||||
|
|
||||||
|
public class MCAccessCB2794 implements MCAccess{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to let it fail.
|
||||||
|
*/
|
||||||
|
public MCAccessCB2794(){
|
||||||
|
getCommandMap();
|
||||||
|
ReflectionUtil.checkMembers("net.minecraft.server.v1_6_R1.", new String[]{"Entity" , "dead"});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCVersion() {
|
||||||
|
// 1_6_R1
|
||||||
|
return "1.6.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServerVersionTag() {
|
||||||
|
return "CB2794";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandMap getCommandMap() {
|
||||||
|
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockCache getBlockCache(final World world) {
|
||||||
|
return new BlockCacheCB2794(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getHeight(final Entity entity) {
|
||||||
|
final net.minecraft.server.v1_6_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b));
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
|
||||||
|
} else return entityHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isBlockSolid(final int id) {
|
||||||
|
final Block block = Block.byId[id];
|
||||||
|
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
|
||||||
|
else return AlmostBoolean.match(block.material.isSolid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isBlockLiquid(final int id) {
|
||||||
|
final Block block = Block.byId[id];
|
||||||
|
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
|
||||||
|
else return AlmostBoolean.match(block.material.isLiquid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth(final Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle().width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isIllegalBounds(final Player player) {
|
||||||
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (entityPlayer.dead) return AlmostBoolean.NO;
|
||||||
|
// TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
|
||||||
|
final AxisAlignedBB box = entityPlayer.boundingBox;
|
||||||
|
if (!entityPlayer.isSleeping()){
|
||||||
|
// This can not really test stance but height of bounding box.
|
||||||
|
final double dY = Math.abs(box.e - box.b);
|
||||||
|
if (dY > 1.8) return AlmostBoolean.YES; // dY > 1.65D ||
|
||||||
|
if (dY < 0.1D && entityPlayer.length >= 0.1) return AlmostBoolean.YES;
|
||||||
|
}
|
||||||
|
return AlmostBoolean.MAYBE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getJumpAmplifier(final Player player) {
|
||||||
|
final net.minecraft.server.v1_6_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
|
||||||
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
|
else return Double.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
|
final net.minecraft.server.v1_6_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
|
else return Double.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInvulnerableTicks(final Player player) {
|
||||||
|
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInvulnerableTicks(final Player player, final int ticks) {
|
||||||
|
((CraftPlayer) player).getHandle().invulnerableTicks = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isComplexPart(final Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle() instanceof EntityComplexPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldBeZombie(final Player player) {
|
||||||
|
final net.minecraft.server.v1_6_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
return !mcPlayer.dead && mcPlayer.getHealth() <= 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDead(final Player player, final int deathTicks) {
|
||||||
|
final net.minecraft.server.v1_6_R1.EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
mcPlayer.deathTicks = deathTicks;
|
||||||
|
mcPlayer.dead = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getKeepAliveTime(final Player player) {
|
||||||
|
// TODO: Implement if possible.
|
||||||
|
return Long.MIN_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasGravity(final Material mat) {
|
||||||
|
// TODO: Test/check.
|
||||||
|
return mat.hasGravity();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -68,6 +68,11 @@
|
|||||||
<artifactId>ncpcompatcb2763</artifactId>
|
<artifactId>ncpcompatcb2763</artifactId>
|
||||||
<version>static</version>
|
<version>static</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcompatcb2794</artifactId>
|
||||||
|
<version>static</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.neatmonster</groupId>
|
<groupId>fr.neatmonster</groupId>
|
||||||
<artifactId>ncpcompatcbdev</artifactId>
|
<artifactId>ncpcompatcbdev</artifactId>
|
||||||
|
@ -11,6 +11,7 @@ import fr.neatmonster.nocheatplus.compat.cb2602.MCAccessCB2602;
|
|||||||
import fr.neatmonster.nocheatplus.compat.cb2645.MCAccessCB2645;
|
import fr.neatmonster.nocheatplus.compat.cb2645.MCAccessCB2645;
|
||||||
import fr.neatmonster.nocheatplus.compat.cb2691.MCAccessCB2691;
|
import fr.neatmonster.nocheatplus.compat.cb2691.MCAccessCB2691;
|
||||||
import fr.neatmonster.nocheatplus.compat.cb2763.MCAccessCB2763;
|
import fr.neatmonster.nocheatplus.compat.cb2763.MCAccessCB2763;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.cb2794.MCAccessCB2794;
|
||||||
import fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev;
|
import fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||||
@ -52,7 +53,7 @@ public class MCAccessFactory {
|
|||||||
|
|
||||||
// TEST //
|
// TEST //
|
||||||
// Only add as long as no stable module has been added.
|
// Only add as long as no stable module has been added.
|
||||||
// 1.6.1
|
// 1.6.2
|
||||||
try{
|
try{
|
||||||
return new MCAccessCBDev();
|
return new MCAccessCBDev();
|
||||||
}
|
}
|
||||||
@ -61,6 +62,14 @@ public class MCAccessFactory {
|
|||||||
};
|
};
|
||||||
// TEST END //
|
// TEST END //
|
||||||
|
|
||||||
|
// 1.6.1
|
||||||
|
try{
|
||||||
|
return new MCAccessCB2794();
|
||||||
|
}
|
||||||
|
catch(Throwable t){
|
||||||
|
throwables.add(t);
|
||||||
|
};
|
||||||
|
|
||||||
// 1.5.2
|
// 1.5.2
|
||||||
try{
|
try{
|
||||||
return new MCAccessCB2763();
|
return new MCAccessCB2763();
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
<include>fr.neatmonster:ncpcompatcb2645</include>
|
<include>fr.neatmonster:ncpcompatcb2645</include>
|
||||||
<include>fr.neatmonster:ncpcompatcb2691</include>
|
<include>fr.neatmonster:ncpcompatcb2691</include>
|
||||||
<include>fr.neatmonster:ncpcompatcb2763</include>
|
<include>fr.neatmonster:ncpcompatcb2763</include>
|
||||||
|
<include>fr.neatmonster:ncpcompatcb2794</include>
|
||||||
<include>fr.neatmonster:ncpcompatcbdev</include>
|
<include>fr.neatmonster:ncpcompatcbdev</include>
|
||||||
<include>fr.neatmonster:ncpplugin</include>
|
<include>fr.neatmonster:ncpplugin</include>
|
||||||
<!-- <include>fr.neatmonster:nocheatplus-parent</include> -->
|
<!-- <include>fr.neatmonster:nocheatplus-parent</include> -->
|
||||||
|
1
pom.xml
1
pom.xml
@ -25,6 +25,7 @@
|
|||||||
<module>NCPCompatCB2645</module>
|
<module>NCPCompatCB2645</module>
|
||||||
<module>NCPCompatCB2691</module>
|
<module>NCPCompatCB2691</module>
|
||||||
<module>NCPCompatCB2763</module>
|
<module>NCPCompatCB2763</module>
|
||||||
|
<module>NCPCompatCB2794</module>
|
||||||
<module>NCPCompatCBDev</module>
|
<module>NCPCompatCBDev</module>
|
||||||
<module>NCPPlugin</module>
|
<module>NCPPlugin</module>
|
||||||
<module>NoCheatPlus</module>
|
<module>NoCheatPlus</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user