use of com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot116 method initializeBlockStates.
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
@Override
public void initializeBlockStates() {
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
int cnt = Block.REGISTRY_ID.a();
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
// Loop through block data states
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
Block b = bd.getBlock();
String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
// See if we have seen this one
DynmapBlockState lastbs = lastBlockState.get(bname);
int idx = 0;
if (lastbs != null) {
// Yes
// Get number of states so far, since this is next
idx = lastbs.getStateCount();
}
// Build state name
String sb = "";
String fname = bd.toString();
int off1 = fname.indexOf('[');
if (off1 >= 0) {
int off2 = fname.indexOf(']');
sb = fname.substring(off1 + 1, off2);
}
Material mat = bd.getMaterial();
// getLightBlock
int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
// Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
if (mat.isSolid()) {
bld.setSolid();
}
if (mat == Material.AIR) {
bld.setAir();
}
if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
bld.setLog();
}
if (mat == Material.LEAVES) {
bld.setLeaves();
}
if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
// Test if fluid type for block is not empty
bld.setWaterlogged();
}
// Build state
DynmapBlockState dbs = bld.build();
dataToState.put(bd, dbs);
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
}
}
use of com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot116_2 method initializeBlockStates.
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
@Override
public void initializeBlockStates() {
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
int cnt = Block.REGISTRY_ID.a();
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
// Loop through block data states
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
Block b = bd.getBlock();
String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
// See if we have seen this one
DynmapBlockState lastbs = lastBlockState.get(bname);
int idx = 0;
if (lastbs != null) {
// Yes
// Get number of states so far, since this is next
idx = lastbs.getStateCount();
}
// Build state name
String sb = "";
String fname = bd.toString();
int off1 = fname.indexOf('[');
if (off1 >= 0) {
int off2 = fname.indexOf(']');
sb = fname.substring(off1 + 1, off2);
}
Material mat = bd.getMaterial();
// getLightBlock
int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
// Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
if (mat.isSolid()) {
bld.setSolid();
}
if (mat == Material.AIR) {
bld.setAir();
}
if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
bld.setLog();
}
if (mat == Material.LEAVES) {
bld.setLeaves();
}
if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
// Test if fluid type for block is not empty
bld.setWaterlogged();
}
// Build state
DynmapBlockState dbs = bld.build();
dataToState.put(bd, dbs);
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
}
}
use of com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block in project MechanicsMain by WeaponMechanics.
the class v1_9_R2 method getHitBox.
@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
if (block.isEmpty() || block.isLiquid())
return null;
WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
IBlockData blockData = worldServer.getType(blockPosition);
Block nmsBlock = blockData.getBlock();
// Passable block check -> false means passable (thats why !)
if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
return null;
AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
// 1.12 -> e
// 1.11 -> d
// 1.9 - 1.10 -> c
int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
hitBox.setBlockHitBox(block);
return hitBox;
}
use of com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block in project MechanicsMain by WeaponMechanics.
the class v1_10_R1 method getHitBox.
@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
if (block.isEmpty() || block.isLiquid())
return null;
WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
IBlockData blockData = worldServer.getType(blockPosition);
Block nmsBlock = blockData.getBlock();
// Passable block check -> false means passable (thats why !)
if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
return null;
AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
// 1.12 -> e
// 1.11 -> d
// 1.9 - 1.10 -> c
int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
hitBox.setBlockHitBox(block);
return hitBox;
}
use of com.cinchapi.concourse.server.storage.format.StorageFormatV2.Block in project MechanicsMain by WeaponMechanics.
the class v1_11_R1 method getHitBox.
@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
if (block.isEmpty() || block.isLiquid())
return null;
WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
IBlockData blockData = worldServer.getType(blockPosition);
Block nmsBlock = blockData.getBlock();
// Passable block check -> false means passable (thats why !)
if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
return null;
AxisAlignedBB aabb = blockData.d(worldServer, blockPosition);
// 1.12 -> e
// 1.11 -> d
// 1.9 - 1.10 -> c
int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
hitBox.setBlockHitBox(block);
return hitBox;
}
Aggregations