NoCheatPlus/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/BlockCacheBukkitModern.java

62 lines
1.6 KiB
Java
Raw Normal View History

2018-08-21 00:02:05 +02:00
package fr.neatmonster.nocheatplus.compat.bukkit;
import java.util.Map;
import org.bukkit.Material;
2018-08-21 00:02:05 +02:00
import org.bukkit.World;
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitShapeModel;
2018-08-21 00:02:05 +02:00
/**
* BlockCache for MCAccessBukkitModern.
*
* @author asofold
*
*/
public class BlockCacheBukkitModern extends BlockCacheBukkit {
private Map<Material, BukkitShapeModel> shapeModels;
public BlockCacheBukkitModern(Map<Material, BukkitShapeModel> shapeModels) {
super(null);
this.shapeModels = shapeModels;
}
2018-08-21 00:02:05 +02:00
public BlockCacheBukkitModern(World world) {
super(world);
}
@Override
public int fetchData(int x, int y, int z) {
// TODO: Might fake here too.
return super.fetchData(x, y, z);
}
@Override
public double[] fetchBounds(int x, int y, int z) {
// minX, minY, minZ, maxX, maxY, maxZ
2018-08-21 00:02:05 +02:00
// TODO: Fetch what's possible to fetch/guess (...).
// TODO: Consider to store the last used block/stuff within BlockCacheBukkit already.
//final Block block = world.getBlockAt(x, y, z);
//final BlockState state = block.getState();
//final MaterialData materialData = state.getData();
//final BlockData blockData = state.getBlockData();
Material mat = getType(x, y, z);
final BukkitShapeModel shapeModel = shapeModels.get(mat);
if (shapeModel == null) {
return super.fetchBounds(x, y, z);
}
else {
return shapeModel.getShape(this, world, x, y, z);
}
2018-08-21 00:02:05 +02:00
}
// TODO: Might refine standsOnEntity as well.
2018-08-21 00:02:05 +02:00
}