Add a dedicated compatibility module for 1.10.x (1.10 R1).
* Auto generate the sub-module file structure. * Add rest manually. Rest * Enter new classes into factories. * Add entries for modules and dependencies to the root pon and the NCPPlugin pom, to make the new module represent 1.10 R1. * Point the 1.10_r1 build profiles to the new module. * Add a new module for 1.11, point to cbdev (which still is 1.10.2, though). Next steps (next MC release, probably): * At least auto generate a file, containing all entries to make for the new module, for convenient use with copy and paste. * (Later: alter the files automatically, possibly interactive. Needs more care, e.g. if profile entries already exist. The factory entries can have a marker each.)
This commit is contained in:
parent
c296170ef7
commit
5089447aa1
|
@ -0,0 +1,52 @@
|
|||
<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>ncpcompatspigotcb1_10_r1</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>NCPCompatSpigotCB1_10_R1</name>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus-parent</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcore</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<description>Compatibility for SpigotCB1_10_R1.
|
||||
|
||||
To add a new compat module two other pom.xml files have to be modified:
|
||||
- Root pom (parent): Add as module within profile with id 'all'.
|
||||
- NCPPlugin: Add as dependency for the profile with id 'all'.
|
||||
- (Add a new profile for this specific module, altering both poms mentioned above. If the profile already exists, pointing at ncpcompatspigotcb1_10_R1, a new profile can be made with updating NCPCompatSpigotCB1_10_R1 then.)
|
||||
|
||||
The NCPPlugin sub-project contains the relevant factories (MCAccessFactory, EntityAccessFactory, AttributeAccessFactory).</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.AttribUtil;
|
||||
import fr.neatmonster.nocheatplus.components.modifier.IAttributeAccess;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
import net.minecraft.server.v1_10_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_10_R1.AttributeModifier;
|
||||
import net.minecraft.server.v1_10_R1.GenericAttributes;
|
||||
|
||||
public class AttributeAccess implements IAttributeAccess {
|
||||
|
||||
public AttributeAccess() {
|
||||
if (ReflectionUtil.getClass("net.minecraft.server.v1_10_R1.AttributeInstance") == null) {
|
||||
throw new RuntimeException("Service not available.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSpeedAttributeMultiplier(Player player) {
|
||||
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||
final double val = attr.getValue() / attr.b();
|
||||
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
|
||||
if (mod == null) {
|
||||
return val;
|
||||
} else {
|
||||
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_10_R1.EntityShulker;
|
||||
import net.minecraft.server.v1_10_R1.EnumDirection;
|
||||
import net.minecraft.server.v1_10_R1.IBlockAccess;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.TileEntity;
|
||||
|
||||
public class BlockCacheSpigotCB1_10_R1 extends BlockCache implements IBlockAccess {
|
||||
|
||||
protected net.minecraft.server.v1_10_R1.World world;
|
||||
protected World bukkitWorld;
|
||||
|
||||
public BlockCacheSpigotCB1_10_R1(World world) {
|
||||
setAccess(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache setAccess(World world) {
|
||||
if (world != null) {
|
||||
this.maxBlockY = world.getMaxHeight() - 1;
|
||||
this.world = ((CraftWorld) world).getHandle();
|
||||
this.bukkitWorld = world;
|
||||
} else {
|
||||
this.world = null;
|
||||
this.bukkitWorld = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int fetchTypeId(final int x, final int y, final int z) {
|
||||
return bukkitWorld.getBlockTypeIdAt(x, y, z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int fetchData(final int x, final int y, final int z) {
|
||||
return bukkitWorld.getBlockAt(x, y, z).getData();
|
||||
}
|
||||
|
||||
@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_10_R1.Block block = net.minecraft.server.v1_10_R1.Block.getById(id);
|
||||
if (block == null) {
|
||||
// TODO: Convention for null blocks -> full ?
|
||||
return null;
|
||||
}
|
||||
final BlockPosition pos = new BlockPosition(x, y, z);
|
||||
// TODO: Deprecation warning below (reason / substitute?).
|
||||
@SuppressWarnings("deprecation")
|
||||
final AxisAlignedBB bb = block.a(getType(pos), this, pos);
|
||||
if (bb == null) {
|
||||
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; // Special case.
|
||||
//return null;
|
||||
}
|
||||
// minX, minY, minZ, maxX, maxY, maxZ
|
||||
return new double[]{bb.a, bb.b, bb.c, bb.d, bb.e, bb.f};
|
||||
}
|
||||
|
||||
@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: Find some simplification!
|
||||
|
||||
final net.minecraft.server.v1_10_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
final AxisAlignedBB box = new AxisAlignedBB(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_10_R1.Entity other = (net.minecraft.server.v1_10_R1.Entity) iterator.next();
|
||||
if (mcEntity == other || !(other instanceof EntityBoat) && !(other instanceof EntityShulker)) { // && !(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.getBoundingBox();
|
||||
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;
|
||||
bukkitWorld = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockPower(BlockPosition pos, EnumDirection dir) {
|
||||
return world.getBlockPower(pos, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(BlockPosition pos) {
|
||||
return world.getTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockData getType(BlockPosition pos) {
|
||||
// TODO: Can this be cached ?
|
||||
return world.getType(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(BlockPosition pos) {
|
||||
// TODO: Can (and should) this be cached ?
|
||||
return world.isEmpty(pos);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.neatmonster.nocheatplus.components.entity.IEntityAccessLastPositionAndLook;
|
||||
import fr.neatmonster.nocheatplus.components.location.IGetPositionWithLook;
|
||||
import fr.neatmonster.nocheatplus.components.location.ISetPositionWithLook;
|
||||
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||
|
||||
public class EntityAccessLastPositionAndLook implements IEntityAccessLastPositionAndLook {
|
||||
|
||||
public EntityAccessLastPositionAndLook() {
|
||||
ReflectionUtil.checkMembers(net.minecraft.server.v1_10_R1.Entity.class, double.class, new String[] {
|
||||
"lastX", "lastY", "lastZ"
|
||||
});
|
||||
ReflectionUtil.checkMembers(net.minecraft.server.v1_10_R1.Entity.class, float.class, new String[] {
|
||||
"lastYaw", "lastPitch"
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPositionAndLook(final Entity entity, final ISetPositionWithLook location) {
|
||||
// TODO: Error handling / conventions.
|
||||
final net.minecraft.server.v1_10_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
location.setX(nmsEntity.lastX);
|
||||
location.setY(nmsEntity.lastY);
|
||||
location.setZ(nmsEntity.lastZ);
|
||||
location.setYaw(nmsEntity.lastYaw);
|
||||
location.setPitch(nmsEntity.lastPitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionAndLook(Entity entity, IGetPositionWithLook location) {
|
||||
final net.minecraft.server.v1_10_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
nmsEntity.lastX = location.getX();
|
||||
nmsEntity.lastY = location.getY();
|
||||
nmsEntity.lastZ = location.getZ();
|
||||
nmsEntity.lastYaw = location.getYaw();
|
||||
nmsEntity.lastPitch = location.getPitch();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_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.ReflectionUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.location.LocUtil;
|
||||
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.Block;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityComplexPart;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.IBlockAccess;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.MobEffectList;
|
||||
|
||||
public class MCAccessSpigotCB1_10_R1 implements MCAccess {
|
||||
|
||||
private final MobEffectList JUMP;
|
||||
private final MobEffectList FASTER_MOVEMENT;
|
||||
|
||||
/**
|
||||
* Test for availability in constructor.
|
||||
*/
|
||||
public MCAccessSpigotCB1_10_R1() {
|
||||
// try {
|
||||
getCommandMap();
|
||||
if (ReflectionUtil.getMethod(Block.class, "a", IBlockData.class, IBlockAccess.class, BlockPosition.class).getReturnType() != AxisAlignedBB.class) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
if (ReflectionUtil.getConstructor(BlockPosition.class, int.class, int.class, int.class) == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.EntityLiving.class,
|
||||
new String[]{"getHeadHeight"}, float.class);
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.EntityPlayer.class,
|
||||
new String[]{"getHealth"}, float.class);
|
||||
ReflectionUtil.checkMembers(net.minecraft.server.v1_10_R1.AxisAlignedBB.class, double.class,
|
||||
"a", "b", "c", "d", "e", "f");
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.AttributeInstance.class,
|
||||
new String[]{"b"}, double.class);
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.AttributeModifier.class,
|
||||
new String[]{"c"}, int.class);
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.AttributeModifier.class,
|
||||
new String[]{"d"}, double.class);
|
||||
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_10_R1.Material.class,
|
||||
new String[]{"isSolid", "isLiquid"}, boolean.class);
|
||||
// TODO: Confine the following by types as well.
|
||||
ReflectionUtil.checkMembers("net.minecraft.server.v1_10_R1.",
|
||||
new String[] {"Entity" , "length", "width", "locY"});
|
||||
ReflectionUtil.checkMembers("net.minecraft.server.v1_10_R1.",
|
||||
new String[] {"EntityPlayer" , "dead", "deathTicks", "invulnerableTicks"});
|
||||
|
||||
// obc: getHandle() for CraftWorld, CraftPlayer, CraftEntity.
|
||||
// nms: Several: AxisAlignedBB, WorldServer
|
||||
// nms: Block.getById(int), BlockPosition(int, int, int), WorldServer.getEntities(Entity, AxisAlignedBB)
|
||||
// nms: AttributeInstance.a(UUID), EntityComplexPart, EntityPlayer.getAttributeInstance(IAttribute).
|
||||
|
||||
// } catch(Throwable t) {
|
||||
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().severe(Streams.INIT, t);
|
||||
// throw new RuntimeException("NO WERK");
|
||||
// }
|
||||
JUMP = MobEffectList.getByName("jump_boost");
|
||||
if (JUMP == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
FASTER_MOVEMENT = MobEffectList.getByName("speed");
|
||||
if (FASTER_MOVEMENT == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMCVersion() {
|
||||
// 1.10 (1_10_R1)
|
||||
return "1.10-1.10.2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerVersionTag() {
|
||||
return "Spigot-CB-1.10_R1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandMap getCommandMap() {
|
||||
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache() {
|
||||
return getBlockCache(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCache getBlockCache(final World world) {
|
||||
return new BlockCacheSpigotCB1_10_R1(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight(final Entity entity) {
|
||||
final net.minecraft.server.v1_10_R1.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) {
|
||||
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
|
||||
} else {
|
||||
return entityHeight;
|
||||
}
|
||||
}
|
||||
|
||||
private net.minecraft.server.v1_10_R1.Material getMaterial(int blockId) {
|
||||
final Block block = Block.getById(blockId);
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
// (Currently no update state, since we don't have any position.)
|
||||
return block.getBlockData().getMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlmostBoolean isBlockSolid(final int id) {
|
||||
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id);
|
||||
if (material == null) {
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
else {
|
||||
return AlmostBoolean.match(material.isSolid());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlmostBoolean isBlockLiquid(final int id) {
|
||||
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id);
|
||||
if (material == null) {
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
else {
|
||||
return AlmostBoolean.match(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.getBoundingBox();
|
||||
if (LocUtil.isBadCoordinate(box.a, box.b, box.c, box.d, box.e, box.f)) {
|
||||
return AlmostBoolean.YES;
|
||||
}
|
||||
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 EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (mcPlayer.hasEffect(JUMP)) {
|
||||
return mcPlayer.getEffect(JUMP).getAmplifier();
|
||||
}
|
||||
else {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFasterMovementAmplifier(final Player player) {
|
||||
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (mcPlayer.hasEffect(FASTER_MOVEMENT)) {
|
||||
return mcPlayer.getEffect(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, (float) damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplexPart(final Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle() instanceof EntityComplexPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeZombie(final Player player) {
|
||||
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||
return !mcPlayer.dead && mcPlayer.getHealth() <= 0.0f ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead(final Player player, final int deathTicks) {
|
||||
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||
mcPlayer.deathTicks = deathTicks;
|
||||
mcPlayer.dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity(final Material mat) {
|
||||
return mat.hasGravity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlmostBoolean dealFallDamageFiresAnEvent() {
|
||||
return AlmostBoolean.YES;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void correctDirection(final Player player) {
|
||||
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||
// // Main direction.
|
||||
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
|
||||
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
|
||||
// // Consider setting the lastYaw here too.
|
||||
// }
|
||||
|
||||
}
|
|
@ -130,6 +130,24 @@
|
|||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<!-- Non minimal below. -->
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- Non minimal above. -->
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>spigot1_11_r1</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>spigot1_11_r1</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<!-- Non minimal below. -->
|
||||
<dependency>
|
||||
|
@ -258,6 +276,11 @@
|
|||
<artifactId>ncpcompatspigotcb1_9_r2</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatspigotcb1_10_r1</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>ncpcompatcbdev</artifactId>
|
||||
|
|
|
@ -39,6 +39,7 @@ public class AttributeAccessFactory {
|
|||
catch (Throwable t) {}
|
||||
RegistryHelper.setupGenericInstance(new String[] {
|
||||
"fr.neatmonster.nocheatplus.compat.cbdev.AttributeAccess",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1.AttributeAccess",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2.AttributeAccess",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1.AttributeAccess",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3.AttributeAccess",
|
||||
|
|
|
@ -41,6 +41,7 @@ public class EntityAccessFactory {
|
|||
public void setupEntityAccess(final MCAccess mcAccess, final MCAccessConfig config) {
|
||||
RegistryHelper.setupGenericInstance(new String[] {
|
||||
"fr.neatmonster.nocheatplus.compat.cbdev.EntityAccessLastPositionAndLook",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1.EntityAccessLastPositionAndLook",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2.EntityAccessLastPositionAndLook",
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1.EntityAccessLastPositionAndLook",
|
||||
}, new String[] {
|
||||
|
|
|
@ -115,6 +115,7 @@ public class MCAccessFactory {
|
|||
"fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev", // latest / tests.
|
||||
|
||||
// Dedicated: CB (Spigot)
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1.MCAccessSpigotCB1_10_R1", // 1.10-1.10.2 (1_10_R1)
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2.MCAccessSpigotCB1_9_R2", // 1.9.4 (1_9_R2)
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1.MCAccessSpigotCB1_9_R1", // 1.9-1.9.3 (1_9_R1)
|
||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3.MCAccessSpigotCB1_8_R3", // 1.8.4-1.8.8 (1_8_R3)
|
||||
|
|
|
@ -43,7 +43,8 @@ _For some building environments you might need to both set the profiles and set
|
|||
| `-P spigot1_8_r3 -P ncp_base` | `spigot1_8_r3` and `ncp_base` | Just Spigot 1.8 R3 (MC 1.8.4-1.8.8). |
|
||||
| `-P spigot1_9_r1 -P ncp_base` | `spigot1_9_r1` and `ncp_base` | Just Spigot 1.9 R1 (MC 1.9-1.9.3). |
|
||||
| `-P spigot1_9_r2 -P ncp_base` | `spigot1_9_r2` and `ncp_base` | Just Spigot 1.9 R2 (MC 1.9.4). |
|
||||
| `-P spigot1_10_r1 -P ncp_base` | `spigot1_10_r1` and `ncp_base` | Just Spigot 1.10 R1 (MC 1.10). |
|
||||
| `-P spigot1_10_r1 -P ncp_base` | `spigot1_10_r1` and `ncp_base` | Just Spigot 1.10 R1 (MC 1.10-1.10.2). |
|
||||
| `-P spigot1_11_r1 -P ncp_base` | `spigot1_11_r1` and `ncp_base` | Just Spigot 1.11 R1 (MC 1.11-1.11.2). |
|
||||
| `-P cbdev -P ncp_base` | `cbdev` and `ncp_base` | The latest version in development. |
|
||||
|
||||
(On the long run, only the latest module for a major Minecraft release may be be kept, such as 1_8_r3 for all of 1.8.x.)
|
||||
|
|
|
@ -15,6 +15,12 @@ This program is free software: you can redistribute it and/or modify
|
|||
|
||||
CONTENT:
|
||||
* Rude script to create a new dedicated compatibility module using NCPCompatCBDev.
|
||||
* Currently missing:
|
||||
* MCAccessFactory entry.
|
||||
* EntityAccessFactory entry.
|
||||
* AttributeAccessFactory entry.
|
||||
* Update root+NCPPlugin pom (module/dependency with profile all
|
||||
+ point an existing profile for this version to the new module).
|
||||
'''
|
||||
|
||||
import sys
|
||||
|
@ -36,8 +42,8 @@ def replace(item, repl_def):
|
|||
|
||||
def copy_and_replace_content(full_src, full_dst, repl_content):
|
||||
# Read.
|
||||
f = open(full_src, "r")
|
||||
content = f.read()
|
||||
f = open(full_src, "rb")
|
||||
content = f.read() # .decode("utf-8")
|
||||
f.close()
|
||||
# TODO: Above leaks on errors (suggested use is command line).
|
||||
content = replace(content, repl_content)
|
||||
|
@ -46,17 +52,23 @@ def copy_and_replace_content(full_src, full_dst, repl_content):
|
|||
f.close()
|
||||
# TODO: Above leaks on errors (suggested use is command line).
|
||||
|
||||
def copy_and_replace(src_dir, dst_dir, repl_filename, repl_content):
|
||||
def copy_and_replace(src_dir, dst_dir, repl_filename, repl_content,
|
||||
filter_filename = ("target", ), filter_ext = (".class",)):
|
||||
"""
|
||||
All exact case replacements.
|
||||
@param src_dir:
|
||||
@param dst_dir:
|
||||
@param repl_filename: Also includes directories.
|
||||
@param repl_content:
|
||||
@param filter_filename: Filter for file names and directories (exact match).
|
||||
@param filter_extension: filter for extensions (exact match).
|
||||
"""
|
||||
names = os.listdir(src_dir)
|
||||
for name in names:
|
||||
full_src = os.path.join(src_dir, name)
|
||||
if name in filter_filename or os.path.splitext(name)[1] in filter_ext:
|
||||
print("Skip filter: " + full_src)
|
||||
continue
|
||||
if os.path.islink(full_src):
|
||||
print("[WARNING] Skip link: " + full_src)
|
||||
continue
|
||||
|
@ -106,13 +118,15 @@ def main_interactive(path):
|
|||
# Create replacement definitions.
|
||||
repl_filename = [(src_name, dst_name_with_rev), (src_name.lower(), dst_name.lower() + (("_" + dst_rev) if dst_rev else ""))]
|
||||
repl_content = [
|
||||
# TODO: DOESNT FUCKING WORK artifactId
|
||||
("the development version (latest of the supported Minecraft versions)", dst_name_with_rev),
|
||||
] + repl_filename
|
||||
] + repl_filename + [
|
||||
("<artifactId>ncpcompat" + dst_name.lower() + (("_" + dst_rev) if dst_rev else "") + "</artifactId>", "<artifactId>ncpcompat" + dst_name_with_rev.lower() + "</artifactId>"),
|
||||
]
|
||||
# Run.
|
||||
"""
|
||||
TODO:
|
||||
- Factory entries.
|
||||
- Fix for artifactId tag in pom.xml (force all lower case).
|
||||
TODO: Factory entries. Adapt build profiles.
|
||||
Perhaps just create a text file with all typical entries for copy and paste.
|
||||
"""
|
||||
try:
|
||||
# TODO: May leak file descriptors :p.
|
||||
|
@ -132,7 +146,7 @@ def main():
|
|||
Parse command line parameter(s).
|
||||
"""
|
||||
if len(sys.argv) > 1:
|
||||
path = u"".join(sys.argv[1:])
|
||||
path = "".join(sys.argv[1:])
|
||||
if path and path[0] == path[-1] == "\"":
|
||||
path = path[1:-1]
|
||||
else:
|
||||
|
|
15
pom.xml
15
pom.xml
|
@ -99,6 +99,20 @@
|
|||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- Non minimal below. -->
|
||||
<module>NCPCompatSpigotCB1_10_R1</module>
|
||||
<!-- Non minimal above. -->
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>spigot1_11_r1</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>spigot1_11_r1</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<!-- Non minimal below. -->
|
||||
<module>NCPCompatCBDev</module>
|
||||
|
@ -147,6 +161,7 @@
|
|||
<module>NCPCompatSpigotCB1_8_R3</module>
|
||||
<module>NCPCompatSpigotCB1_9_R1</module>
|
||||
<module>NCPCompatSpigotCB1_9_R2</module>
|
||||
<module>NCPCompatSpigotCB1_10_R1</module>
|
||||
<module>NCPCompatCBDev</module>
|
||||
<!-- Non minimal above. -->
|
||||
</modules>
|
||||
|
|
Loading…
Reference in New Issue