Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.pepsoft.worldpainter.dynmap;
import com.google.common.collect.ImmutableMap;
import org.dynmap.renderer.DynmapBlockState;
import org.pepsoft.minecraft.Material;
import java.util.*;
import static java.util.stream.Collectors.joining;
import static org.pepsoft.minecraft.Constants.MC_AIR;
import static org.pepsoft.minecraft.Constants.MC_CAVE_AIR;
import static org.pepsoft.minecraft.Material.MINECRAFT;
public class DynmapBlockStateHelper {
/**
* Initialise the Dynmap {@link DynmapBlockState}s for all currently loaded {@link Material}s. This can be done
* only once, after which Dynmap will only be able to render the materials known at that time.
*/
public static void initialise() {
// Do nothing (loading the class has done the initialisation)
}
static DynmapBlockState getDynmapBlockState(Material material) {
return IDENTITY_TO_BLOCK_STATE.get(material.identity);
}
private static final Map IDENTITY_TO_BLOCK_STATE;
static {
final Map identityToBlockState = new HashMap<>();
final Map> blockStatesByName = new HashMap<>();
final Map blockStatesBasesByName = new HashMap<>();
for (String simpleName: Material.getAllSimpleNamesForNamespace(MINECRAFT)) {
final Material prototype = Material.getPrototype(MINECRAFT + ':' + simpleName);
if ((prototype.propertyDescriptors == null) || prototype.propertyDescriptors.isEmpty()) {
// Simple material
final DynmapBlockState blockState = new DynmapBlockState(null,
0,
prototype.name,
null,
prototype.simpleName,
prototype.blockType);
setFlags(blockState, prototype);
blockStatesBasesByName.put(prototype.name, blockState);
blockStatesByName.computeIfAbsent(prototype.name, k -> new HashSet<>()).add(blockState);
identityToBlockState.put(prototype.identity, blockState);
} else {
// Create all possible permutations of properties
// Material.propertyDescriptors is sorted by property name, which is important to Dynmap as it expects
// both the block variants and the properties in the statename to be in an exact order for the rendering
// logic to work properly
List