[BLEEDING] Fix native access modules.

This commit is contained in:
asofold 2017-12-18 01:14:23 +01:00
parent 1b41fc52a1
commit ce98d2aa54
42 changed files with 810 additions and 667 deletions

View File

@ -42,7 +42,6 @@ public class BlockCacheBukkit extends BlockCache {
return this;
}
@SuppressWarnings("deprecation")
@Override
public Material fetchTypeId(final int x, final int y, final int z) {
// TODO: consider setting type id and data at once.

View File

@ -30,12 +30,53 @@ import net.minecraft.server.v1_4_5.Material;
import net.minecraft.server.v1_4_5.TileEntity;
import net.minecraft.server.v1_4_5.Vec3DPool;
public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2512 extends BlockCache {
/** 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_4_5.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(int x, int y, int z) {
return BlockCacheCB2512.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB2512.this.getData(x, y, z);
}
@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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
}
};
public BlockCacheCB2512(World world) {
setAccess(world);
@ -43,6 +84,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +95,8 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +108,11 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_4_5.Block block = net.minecraft.server.v1_4_5.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z); // TODO: use THIS instead of world.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
@ -111,31 +154,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{
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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
bukkitWorld = null;
}
}

View File

@ -84,15 +84,17 @@ public class MCAccessCB2512 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,12 +30,54 @@ import net.minecraft.server.v1_4_6.Material;
import net.minecraft.server.v1_4_6.TileEntity;
import net.minecraft.server.v1_4_6.Vec3DPool;
public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2545 extends BlockCache {
/** 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_4_6.World world;
protected World bukkitWorld;
private IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(final int x, final int y, final int z) {
return BlockCacheCB2545.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(final int x, final int y, final int z) {
return BlockCacheCB2545.this.getData(x, y, z);
}
@Override
public Material getMaterial(final int x, final int y, final int z) {
return BlockCacheCB2545.this.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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
}
};
public BlockCacheCB2545(World world) {
setAccess(world);
@ -43,6 +85,7 @@ public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
@Override
public BlockCache setAccess(World world) {
bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,10 @@ public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
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 int id = iBlockAccess.getTypeId(x, y, z);
final net.minecraft.server.v1_4_6.Block block = net.minecraft.server.v1_4_6.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z); // TODO: use THIS instead of world.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
@ -111,31 +154,7 @@ public class BlockCacheCB2545 extends BlockCache implements IBlockAccess{
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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
bukkitWorld = null;
}
}

View File

@ -84,15 +84,17 @@ public class MCAccessCB2545 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -31,19 +31,62 @@ import org.bukkit.entity.Entity;
import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
public class BlockCacheCB2602 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2602 extends BlockCache {
/** 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_4_R1.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(int x, int y, int z) {
return BlockCacheCB2602.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB2602.this.getData(x, y, z);
}
@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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
}
};
public BlockCacheCB2602(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -54,8 +97,8 @@ public class BlockCacheCB2602 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -67,10 +110,13 @@ public class BlockCacheCB2602 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_4_R1.Block block = net.minecraft.server.v1_4_R1.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
if (block == null) {
return null;
}
block.updateShape(iBlockAccess, x, y, z); // TODO: use THIS instead of world.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.v(), block.x(), block.z(), block.w(), block.y(), block.A()};
@ -113,31 +159,7 @@ public class BlockCacheCB2602 extends BlockCache implements IBlockAccess{
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 boolean isBlockFacePowered(final int arg0, final int arg1, final int arg2, final int arg3) {
return world.isBlockFacePowered(arg0, arg1, arg2, arg3);
}
@Override
public boolean t(final int x, final int y, final int z) {
return world.t(x, y, z);
bukkitWorld = null;
}
}

View File

@ -85,15 +85,17 @@ public class MCAccessCB2602 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,19 +30,62 @@ import net.minecraft.server.v1_5_R1.Material;
import net.minecraft.server.v1_5_R1.TileEntity;
import net.minecraft.server.v1_5_R1.Vec3DPool;
public class BlockCacheCB2645 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2645 extends BlockCache {
/** 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_5_R1.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(int x, int y, int z) {
return BlockCacheCB2645.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB2645.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2645(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2645 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,11 @@ public class BlockCacheCB2645 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_5_R1.Block block = net.minecraft.server.v1_5_R1.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, 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()};
@ -116,31 +160,7 @@ public class BlockCacheCB2645 extends BlockCache implements IBlockAccess{
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);
bukkitWorld = null;
}
}

View File

@ -36,7 +36,7 @@ import net.minecraft.server.v1_5_R1.EntityComplexPart;
import net.minecraft.server.v1_5_R1.EntityPlayer;
import net.minecraft.server.v1_5_R1.MobEffectList;
public class MCAccessCB2645 implements MCAccess{
public class MCAccessCB2645 implements MCAccess {
/**
* Constructor to let it fail.
@ -84,15 +84,17 @@ public class MCAccessCB2645 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,19 +30,62 @@ import net.minecraft.server.v1_5_R2.Material;
import net.minecraft.server.v1_5_R2.TileEntity;
import net.minecraft.server.v1_5_R2.Vec3DPool;
public class BlockCacheCB2691 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2691 extends BlockCache {
/** 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_5_R2.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(final int x, final int y, final int z) {
return BlockCacheCB2691.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(final int x, final int y, final int z) {
return BlockCacheCB2691.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2691(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2691 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,11 @@ public class BlockCacheCB2691 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_5_R2.Block block = net.minecraft.server.v1_5_R2.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, 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()};
@ -116,31 +160,7 @@ public class BlockCacheCB2691 extends BlockCache implements IBlockAccess{
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);
bukkitWorld = null;
}
}

View File

@ -86,15 +86,17 @@ public class MCAccessCB2691 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,12 +30,54 @@ import net.minecraft.server.v1_5_R3.Material;
import net.minecraft.server.v1_5_R3.TileEntity;
import net.minecraft.server.v1_5_R3.Vec3DPool;
public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2763 extends BlockCache {
/** 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_5_R3.World world;
protected World bukkitWorld;
private IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(final int x, final int y, final int z) {
return BlockCacheCB2763.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(final int x, final int y, final int z) {
return BlockCacheCB2763.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2763(World world) {
setAccess(world);
@ -43,6 +85,7 @@ public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
@Override
public BlockCache setAccess(World world) {
bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,10 @@ public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
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 int id = iBlockAccess.getTypeId(x, y, z);
final net.minecraft.server.v1_5_R3.Block block = net.minecraft.server.v1_5_R3.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, 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()};
@ -118,29 +161,4 @@ public class BlockCacheCB2763 extends BlockCache implements IBlockAccess{
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);
}
}

View File

@ -84,15 +84,17 @@ public class MCAccessCB2763 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,19 +30,62 @@ import net.minecraft.server.v1_6_R1.Material;
import net.minecraft.server.v1_6_R1.TileEntity;
import net.minecraft.server.v1_6_R1.Vec3DPool;
public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2794 extends BlockCache {
/** 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;
protected World bukkitWorld;
IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(final int x, final int y, final int z) {
return BlockCacheCB2794.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(final int x, final int y, final int z) {
return BlockCacheCB2794.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2794(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,11 @@ public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
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.
block.updateShape(iBlockAccess, x, y, z);
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
@ -116,31 +160,7 @@ public class BlockCacheCB2794 extends BlockCache implements IBlockAccess{
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);
bukkitWorld = null;
}
}

View File

@ -36,7 +36,7 @@ import net.minecraft.server.v1_6_R1.EntityComplexPart;
import net.minecraft.server.v1_6_R1.EntityPlayer;
import net.minecraft.server.v1_6_R1.MobEffectList;
public class MCAccessCB2794 implements MCAccess{
public class MCAccessCB2794 implements MCAccess {
/**
* Constructor to let it fail.
@ -84,15 +84,17 @@ public class MCAccessCB2794 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,19 +30,62 @@ import net.minecraft.server.v1_6_R2.Material;
import net.minecraft.server.v1_6_R2.TileEntity;
import net.minecraft.server.v1_6_R2.Vec3DPool;
public class BlockCacheCB2808 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2808 extends BlockCache {
/** 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_R2.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(final int x, final int y, final int z) {
return BlockCacheCB2808.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(final int x, final int y, final int z) {
return BlockCacheCB2808.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2808(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2808 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,11 @@ public class BlockCacheCB2808 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_6_R2.Block block = net.minecraft.server.v1_6_R2.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, 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()};
@ -116,31 +160,7 @@ public class BlockCacheCB2808 extends BlockCache implements IBlockAccess{
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);
bukkitWorld = null;
}
}

View File

@ -36,7 +36,7 @@ import net.minecraft.server.v1_6_R2.EntityComplexPart;
import net.minecraft.server.v1_6_R2.EntityPlayer;
import net.minecraft.server.v1_6_R2.MobEffectList;
public class MCAccessCB2808 implements MCAccess{
public class MCAccessCB2808 implements MCAccess {
/**
* Constructor to let it fail.
@ -85,15 +85,17 @@ public class MCAccessCB2808 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -30,19 +30,62 @@ import net.minecraft.server.v1_6_R3.Material;
import net.minecraft.server.v1_6_R3.TileEntity;
import net.minecraft.server.v1_6_R3.Vec3DPool;
public class BlockCacheCB2882 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2882 extends BlockCache {
/** 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_R3.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@SuppressWarnings("deprecation")
@Override
public int getTypeId(int x, int y, int z) {
return BlockCacheCB2882.this.getTypeId(x, y, z).getId();
}
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB2882.this.getData(x, y, z);
}
@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);
}
};
public BlockCacheCB2882(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +96,8 @@ public class BlockCacheCB2882 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public org.bukkit.Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -66,10 +109,11 @@ public class BlockCacheCB2882 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_6_R3.Block block = net.minecraft.server.v1_6_R3.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z);
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.u(), block.w(), block.y(), block.v(), block.x(), block.z()};
@ -116,31 +160,7 @@ public class BlockCacheCB2882 extends BlockCache implements IBlockAccess{
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);
bukkitWorld = null;
}
}

View File

@ -86,15 +86,17 @@ public class MCAccessCB2882 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.byId[id];
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
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];
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.byId[id.getId()];
if (block == null || block.material == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.material.isLiquid());
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.cb2922;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
@ -30,19 +31,51 @@ import net.minecraft.server.v1_7_R1.IBlockAccess;
import net.minecraft.server.v1_7_R1.TileEntity;
import net.minecraft.server.v1_7_R1.Vec3DPool;
public class BlockCacheCB2922 extends BlockCache implements IBlockAccess{
public class BlockCacheCB2922 extends BlockCache {
/** 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_7_R1.WorldServer world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB2922.this.getData(x, y, z);
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
}
@Override
public Vec3DPool getVec3DPool() {
return world.getVec3DPool();
}
};
public BlockCacheCB2922(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -53,8 +86,8 @@ public class BlockCacheCB2922 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -64,12 +97,12 @@ public class BlockCacheCB2922 extends BlockCache implements IBlockAccess{
@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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_7_R1.Block block = net.minecraft.server.v1_7_R1.Block.e(id);
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z); // data from cache.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
@ -116,26 +149,7 @@ public class BlockCacheCB2922 extends BlockCache implements IBlockAccess{
public void cleanup() {
super.cleanup();
world = null;
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
}
@Override
public Vec3DPool getVec3DPool() {
return world.getVec3DPool();
bukkitWorld = null;
}
}

View File

@ -86,15 +86,17 @@ public class MCAccessCB2922 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.getMaterial().isSolid());
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.getMaterial().isLiquid());
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.cb3026;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
@ -29,19 +30,46 @@ import net.minecraft.server.v1_7_R2.EntityBoat;
import net.minecraft.server.v1_7_R2.IBlockAccess;
import net.minecraft.server.v1_7_R2.TileEntity;
public class BlockCacheCB3026 extends BlockCache implements IBlockAccess{
public class BlockCacheCB3026 extends BlockCache {
/** 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_7_R2.WorldServer world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB3026.this.getData(x, y, z);
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
}
};
public BlockCacheCB3026(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -52,8 +80,8 @@ public class BlockCacheCB3026 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -65,10 +93,11 @@ public class BlockCacheCB3026 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_7_R2.Block block = net.minecraft.server.v1_7_R2.Block.e(id);
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z); // getData from cache.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
@ -115,21 +144,7 @@ public class BlockCacheCB3026 extends BlockCache implements IBlockAccess{
public void cleanup() {
super.cleanup();
world = null;
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
bukkitWorld = null;
}
}

View File

@ -36,7 +36,7 @@ import net.minecraft.server.v1_7_R2.EntityComplexPart;
import net.minecraft.server.v1_7_R2.EntityPlayer;
import net.minecraft.server.v1_7_R2.MobEffectList;
public class MCAccessCB3026 implements MCAccess{
public class MCAccessCB3026 implements MCAccess {
/**
* Constructor to let it fail.
@ -86,15 +86,17 @@ public class MCAccessCB3026 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.getMaterial().isSolid());
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) return AlmostBoolean.MAYBE;
else return AlmostBoolean.match(block.getMaterial().isLiquid());
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.cb3043;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
@ -29,19 +30,46 @@ import net.minecraft.server.v1_7_R3.EntityBoat;
import net.minecraft.server.v1_7_R3.IBlockAccess;
import net.minecraft.server.v1_7_R3.TileEntity;
public class BlockCacheCB3043 extends BlockCache implements IBlockAccess{
public class BlockCacheCB3043 extends BlockCache {
/** 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_7_R3.WorldServer world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB3043.this.getData(x, y, z);
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
}
};
public BlockCacheCB3043(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -52,8 +80,8 @@ public class BlockCacheCB3043 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -65,10 +93,11 @@ public class BlockCacheCB3043 extends BlockCache implements IBlockAccess{
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);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_7_R3.Block block = net.minecraft.server.v1_7_R3.Block.e(id);
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
block.updateShape(iBlockAccess, x, y, z); // getData from cache.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
@ -115,21 +144,7 @@ public class BlockCacheCB3043 extends BlockCache implements IBlockAccess{
public void cleanup() {
super.cleanup();
world = null;
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
bukkitWorld = null;
}
}

View File

@ -36,7 +36,7 @@ import net.minecraft.server.v1_7_R3.EntityComplexPart;
import net.minecraft.server.v1_7_R3.EntityPlayer;
import net.minecraft.server.v1_7_R3.MobEffectList;
public class MCAccessCB3043 implements MCAccess{
public class MCAccessCB3043 implements MCAccess {
/**
* Constructor to let it fail.
@ -86,8 +86,9 @@ public class MCAccessCB3043 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}
@ -97,8 +98,9 @@ public class MCAccessCB3043 implements MCAccess{
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.e(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.e(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.cb3100;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
@ -29,19 +30,46 @@ import net.minecraft.server.v1_7_R4.EntityBoat;
import net.minecraft.server.v1_7_R4.IBlockAccess;
import net.minecraft.server.v1_7_R4.TileEntity;
public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
public class BlockCacheCB3100 extends BlockCache {
/** 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_7_R4.WorldServer world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@Override
public int getData(int x, int y, int z) {
return BlockCacheCB3100.this.getData(x, y, z);
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
}
};
public BlockCacheCB3100(World world) {
setAccess(world);
}
@Override
public BlockCache setAccess(World world) {
this.bukkitWorld = world;
if (world != null) {
this.maxBlockY = world.getMaxHeight() - 1;
this.world = ((CraftWorld) world).getHandle();
@ -52,8 +80,8 @@ public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
}
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@Override
@ -63,13 +91,14 @@ public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_7_R4.Block block = net.minecraft.server.v1_7_R4.Block.getById(id);
if (block == null) {
// TODO: Convention for null bounds -> full ?
return null;
}
block.updateShape(this, x, y, z);
block.updateShape(iBlockAccess, x, y, z); // getData from cache.
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
@ -118,21 +147,7 @@ public class BlockCacheCB3100 extends BlockCache implements IBlockAccess{
public void cleanup() {
super.cleanup();
world = null;
}
@Override
public TileEntity getTileEntity(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@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 Block getType(int x, int y, int z) {
return world.getType(x, y, z);
bukkitWorld = null;
}
}

View File

@ -37,7 +37,7 @@ import net.minecraft.server.v1_7_R4.EntityComplexPart;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.MobEffectList;
public class MCAccessCB3100 implements MCAccess{
public class MCAccessCB3100 implements MCAccess {
/**
* Constructor to let it fail.
@ -87,8 +87,9 @@ public class MCAccessCB3100 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}
@ -98,8 +99,9 @@ public class MCAccessCB3100 implements MCAccess{
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.cbdev;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity;
@ -32,11 +33,37 @@ import net.minecraft.server.v1_11_R1.IBlockAccess;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.TileEntity;
public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
public class BlockCacheCBDev extends BlockCache {
protected net.minecraft.server.v1_11_R1.World world;
protected World bukkitWorld;
private final IBlockAccess iBlockAccess = new IBlockAccess() {
@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);
}
};
public BlockCacheCBDev(World world) {
setAccess(world);
}
@ -54,10 +81,9 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -68,8 +94,9 @@ 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_11_R1.Block block = net.minecraft.server.v1_11_R1.Block.getById(id);
final Material id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_11_R1.Block block = net.minecraft.server.v1_11_R1.Block.getById(id.getId());
if (block == null) {
// TODO: Convention for null blocks -> full ?
return null;
@ -77,7 +104,7 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
final BlockPosition pos = new BlockPosition(x, y, z);
// TODO: Deprecation warning below (reason / substitute?).
@SuppressWarnings("deprecation")
final AxisAlignedBB bb = block.b(getType(pos), this, pos);
final AxisAlignedBB bb = block.b(iBlockAccess.getType(pos), iBlockAccess, pos);
if (bb == null) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; // Special case.
//return null;
@ -132,26 +159,4 @@ public class BlockCacheCBDev extends BlockCache implements IBlockAccess {
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);
}
}

View File

@ -149,8 +149,9 @@ public class MCAccessCBDev implements MCAccess {
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final net.minecraft.server.v1_11_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_11_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}
@ -160,8 +161,9 @@ public class MCAccessCBDev implements MCAccess {
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final net.minecraft.server.v1_11_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_11_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_10_R1;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
@ -27,14 +28,11 @@ 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 {
public class BlockCacheSpigotCB1_10_R1 extends BlockCache {
protected net.minecraft.server.v1_10_R1.World world;
protected World bukkitWorld;
public BlockCacheSpigotCB1_10_R1(World world) {
@ -54,10 +52,9 @@ public class BlockCacheSpigotCB1_10_R1 extends BlockCache implements IBlockAcces
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -68,7 +65,8 @@ public class BlockCacheSpigotCB1_10_R1 extends BlockCache implements IBlockAcces
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
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 ?
@ -77,7 +75,7 @@ public class BlockCacheSpigotCB1_10_R1 extends BlockCache implements IBlockAcces
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);
final AxisAlignedBB bb = block.a(world.getType(pos), world, pos);
if (bb == null) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; // Special case.
//return null;
@ -132,26 +130,4 @@ public class BlockCacheSpigotCB1_10_R1 extends BlockCache implements IBlockAcces
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);
}
}

View File

@ -144,8 +144,9 @@ public class MCAccessSpigotCB1_10_R1 implements MCAccess {
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}
@ -155,8 +156,9 @@ public class MCAccessSpigotCB1_10_R1 implements MCAccess {
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_10_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
@ -26,15 +27,12 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
import net.minecraft.server.v1_8_R1.BlockPosition;
import net.minecraft.server.v1_8_R1.EntityBoat;
import net.minecraft.server.v1_8_R1.EnumDirection;
import net.minecraft.server.v1_8_R1.IBlockAccess;
import net.minecraft.server.v1_8_R1.IBlockData;
import net.minecraft.server.v1_8_R1.TileEntity;
public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess{
public class BlockCacheSpigotCB1_8_R1 extends BlockCache {
protected net.minecraft.server.v1_8_R1.WorldServer world;
protected World bukkitWorld; // WHACKS
protected World bukkitWorld;
public BlockCacheSpigotCB1_8_R1(World world) {
setAccess(world);
@ -53,10 +51,9 @@ public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -67,13 +64,14 @@ public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_8_R1.Block block = net.minecraft.server.v1_8_R1.Block.getById(id);
if (block == null) {
// TODO: Convention for null bounds -> full ?
return null;
}
block.updateShape(this, new BlockPosition(x, y, z));
block.updateShape(world, new BlockPosition(x, y, z));
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.z(), block.B(), block.D(), block.A(), block.C(), block.E()};
@ -125,24 +123,4 @@ public class BlockCacheSpigotCB1_8_R1 extends BlockCache implements IBlockAccess
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) {
return world.getType(pos);
}
@Override
public boolean isEmpty(BlockPosition pos) {
return world.isEmpty(pos);
}
}

View File

@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R1.EntityComplexPart;
import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.MobEffectList;
public class MCAccessSpigotCB1_8_R1 implements MCAccess{
public class MCAccessSpigotCB1_8_R1 implements MCAccess {
/**
* Constructor to let it fail.
@ -88,8 +88,9 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}
@ -99,8 +100,9 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
@ -26,15 +27,12 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
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;
public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess{
public class BlockCacheSpigotCB1_8_R2 extends BlockCache {
protected net.minecraft.server.v1_8_R2.WorldServer world;
protected World bukkitWorld; // WHACKS
protected World bukkitWorld;
public BlockCacheSpigotCB1_8_R2(World world) {
setAccess(world);
@ -53,10 +51,9 @@ public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -67,13 +64,14 @@ public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_8_R2.Block block = net.minecraft.server.v1_8_R2.Block.getById(id);
if (block == null) {
// TODO: Convention for null bounds -> full ?
return null;
}
block.updateShape(this, new BlockPosition(x, y, z));
block.updateShape(world, new BlockPosition(x, y, z));
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.B(), block.D(), block.F(), block.C(), block.E(), block.G()};
@ -125,24 +123,4 @@ public class BlockCacheSpigotCB1_8_R2 extends BlockCache implements IBlockAccess
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) {
return world.getType(pos);
}
@Override
public boolean isEmpty(BlockPosition pos) {
return world.isEmpty(pos);
}
}

View File

@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R2.EntityComplexPart;
import net.minecraft.server.v1_8_R2.EntityPlayer;
import net.minecraft.server.v1_8_R2.MobEffectList;
public class MCAccessSpigotCB1_8_R2 implements MCAccess{
public class MCAccessSpigotCB1_8_R2 implements MCAccess {
/**
* Constructor to let it fail.
@ -88,8 +88,9 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}
@ -99,8 +100,9 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@ -26,14 +27,11 @@ import fr.neatmonster.nocheatplus.utilities.map.BlockCache;
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;
public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess{
public class BlockCacheSpigotCB1_8_R3 extends BlockCache {
protected net.minecraft.server.v1_8_R3.WorldServer world;
protected World bukkitWorld;
public BlockCacheSpigotCB1_8_R3(World world) {
@ -53,10 +51,9 @@ public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -67,13 +64,14 @@ public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
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;
}
block.updateShape(this, new BlockPosition(x, y, z));
block.updateShape(world, new BlockPosition(x, y, z));
// minX, minY, minZ, maxX, maxY, maxZ
return new double[]{block.B(), block.D(), block.F(), block.C(), block.E(), block.G()};
@ -125,24 +123,4 @@ public class BlockCacheSpigotCB1_8_R3 extends BlockCache implements IBlockAccess
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) {
return world.getType(pos);
}
@Override
public boolean isEmpty(BlockPosition pos) {
return world.isEmpty(pos);
}
}

View File

@ -37,7 +37,7 @@ import net.minecraft.server.v1_8_R3.EntityComplexPart;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MobEffectList;
public class MCAccessSpigotCB1_8_R3 implements MCAccess{
public class MCAccessSpigotCB1_8_R3 implements MCAccess {
/**
* Test for availability in constructor.
@ -108,8 +108,9 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}
@ -119,8 +120,9 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final Block block = Block.getById(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final Block block = Block.getById(id.getId());
if (block == null || block.getMaterial() == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
@ -27,14 +28,11 @@ import net.minecraft.server.v1_9_R1.AxisAlignedBB;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.EntityBoat;
import net.minecraft.server.v1_9_R1.EntityShulker;
import net.minecraft.server.v1_9_R1.EnumDirection;
import net.minecraft.server.v1_9_R1.IBlockAccess;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.TileEntity;
public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess {
public class BlockCacheSpigotCB1_9_R1 extends BlockCache {
protected net.minecraft.server.v1_9_R1.WorldServer world;
protected World bukkitWorld;
public BlockCacheSpigotCB1_9_R1(World world) {
@ -54,10 +52,9 @@ public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -68,14 +65,15 @@ public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_9_R1.Block block = net.minecraft.server.v1_9_R1.Block.getById(id);
if (block == null) {
// TODO: Convention for null blocks -> full ?
return null;
}
final BlockPosition pos = new BlockPosition(x, y, z);
final AxisAlignedBB bb = block.a(getType(pos), this, pos);
final AxisAlignedBB bb = block.a(world.getType(pos), world, pos);
if (bb == null) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; // Special case.
//return null;
@ -130,26 +128,4 @@ public class BlockCacheSpigotCB1_9_R1 extends BlockCache implements IBlockAccess
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);
}
}

View File

@ -142,8 +142,9 @@ public class MCAccessSpigotCB1_9_R1 implements MCAccess {
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final net.minecraft.server.v1_9_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_9_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}
@ -153,8 +154,9 @@ public class MCAccessSpigotCB1_9_R1 implements MCAccess {
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final net.minecraft.server.v1_9_R1.Material material = getMaterial(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_9_R1.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -17,6 +17,7 @@ package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
@ -27,14 +28,11 @@ import net.minecraft.server.v1_9_R2.AxisAlignedBB;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.EntityBoat;
import net.minecraft.server.v1_9_R2.EntityShulker;
import net.minecraft.server.v1_9_R2.EnumDirection;
import net.minecraft.server.v1_9_R2.IBlockAccess;
import net.minecraft.server.v1_9_R2.IBlockData;
import net.minecraft.server.v1_9_R2.TileEntity;
public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess {
public class BlockCacheSpigotCB1_9_R2 extends BlockCache {
protected net.minecraft.server.v1_9_R2.WorldServer world;
protected World bukkitWorld;
public BlockCacheSpigotCB1_9_R2(World world) {
@ -54,10 +52,9 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
return this;
}
@SuppressWarnings("deprecation")
@Override
public int fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockTypeIdAt(x, y, z);
public Material fetchTypeId(final int x, final int y, final int z) {
return bukkitWorld.getBlockAt(x, y, z).getType();
}
@SuppressWarnings("deprecation")
@ -68,7 +65,8 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
@Override
public double[] fetchBounds(final int x, final int y, final int z){
final int id = getTypeId(x, y, z);
@SuppressWarnings("deprecation")
final int id = getTypeId(x, y, z).getId();
final net.minecraft.server.v1_9_R2.Block block = net.minecraft.server.v1_9_R2.Block.getById(id);
if (block == null) {
// TODO: Convention for null blocks -> full ?
@ -77,7 +75,7 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
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);
final AxisAlignedBB bb = block.a(world.getType(pos), world, pos);
if (bb == null) {
return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; // Special case.
//return null;
@ -132,26 +130,4 @@ public class BlockCacheSpigotCB1_9_R2 extends BlockCache implements IBlockAccess
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);
}
}

View File

@ -144,8 +144,9 @@ public class MCAccessSpigotCB1_9_R2 implements MCAccess {
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
final net.minecraft.server.v1_9_R2.Material material = getMaterial(id);
public AlmostBoolean isBlockSolid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_9_R2.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}
@ -155,8 +156,9 @@ public class MCAccessSpigotCB1_9_R2 implements MCAccess {
}
@Override
public AlmostBoolean isBlockLiquid(final int id) {
final net.minecraft.server.v1_9_R2.Material material = getMaterial(id);
public AlmostBoolean isBlockLiquid(final Material id) {
@SuppressWarnings("deprecation")
final net.minecraft.server.v1_9_R2.Material material = getMaterial(id.getId());
if (material == null) {
return AlmostBoolean.MAYBE;
}

View File

@ -40,15 +40,15 @@ public class RawConfigFile extends YamlConfiguration {
}
/**
* Attempt to get a Material from a string.<br>
* Will attempt to match the name but also type ids.
* Attempt to get a Material from a string.
*
* @param content
* @return
*/
@SuppressWarnings("deprecation")
public static Material parseMaterial(String content) {
content = content.trim().toUpperCase();
try {
// TODO: Custom lookup (both vanilla and Bukkit/Spigot).
return Material.matchMaterial(prepareMatchMaterial(content));
}
catch (Exception e) {}