62 lines
1.6 KiB
Java
62 lines
1.6 KiB
Java
package fr.neatmonster.nocheatplus.compat.bukkit;
|
|
|
|
import java.util.Map;
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.World;
|
|
|
|
import fr.neatmonster.nocheatplus.compat.bukkit.model.BukkitShapeModel;
|
|
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
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
|
|
|
|
// 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);
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: Might refine standsOnEntity as well.
|
|
|
|
}
|