use of net.minecraft.server.v1_15_R1.IBlockData in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot113_2 method getBlockNames.
/**
* Get block short name list
*/
@Override
public String[] getBlockNames() {
int cnt = Block.REGISTRY_ID.a();
String[] names = new String[cnt];
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
names[i] = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
Log.info(i + ": blk=" + names[i] + ", bd=" + bd.toString());
}
return names;
}
use of net.minecraft.server.v1_15_R1.IBlockData in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot114_1 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();
// Loop through block data states
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
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();
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
if ((!bd.p().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
// Test if fluid type for block is not empty
bs.setWaterlogged();
}
if (mat == Material.AIR) {
bs.setAir();
}
if (mat == Material.LEAVES) {
bs.setLeaves();
}
if (bd.getBlock() instanceof BlockLogAbstract) {
bs.setLog();
}
if (mat.isSolid()) {
bs.setSolid();
}
dataToState.put(bd, bs);
lastBlockState.put(bname, (lastbs == null) ? bs : lastbs);
Log.verboseinfo(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + bs.isWaterlogged());
}
}
use of net.minecraft.server.v1_15_R1.IBlockData in project dynmap by webbukkit.
the class BukkitVersionHelperSpigot114_1 method getBlockNames.
/**
* Get block short name list
*/
@Override
public String[] getBlockNames() {
int cnt = Block.REGISTRY_ID.a();
String[] names = new String[cnt];
for (int i = 0; i < cnt; i++) {
IBlockData bd = Block.getByCombinedId(i);
names[i] = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
Log.info(i + ": blk=" + names[i] + ", bd=" + bd.toString());
}
return names;
}
use of net.minecraft.server.v1_15_R1.IBlockData in project MechanicsMain by WeaponMechanics.
the class Block_1_11_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData blockData = null;
if (mask != null) {
WorldServer world = ((CraftWorld) mask.getWorld()).getHandle();
BlockPosition pos = new BlockPosition(mask.getX(), mask.getY(), mask.getZ());
blockData = world.c(pos).getBlock().getBlockData();
}
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, blockData));
}
return packets;
}
use of net.minecraft.server.v1_15_R1.IBlockData in project MechanicsMain by WeaponMechanics.
the class Block_1_11_R1 method getMultiBlockMaskPacket.
@SuppressWarnings("deprecation")
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable Material mask, byte data) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData theMask = mask == null ? null : net.minecraft.server.v1_11_R1.Block.getByCombinedId(mask.getId() | data << 12);
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
Aggregations