use of com.ferreusveritas.dynamictrees.api.cells.ICellKit in project DynamicTrees by DynamicTreesTeam.
the class LeavesPropertiesJson method resolve.
public void resolve() {
if (jsonObj != null) {
for (Entry<String, JsonElement> entry : jsonObj.entrySet()) {
String key = entry.getKey();
JsonElement element = entry.getValue();
if ("color".equals(key)) {
if (element.isJsonPrimitive()) {
colorPrimitive = element.getAsJsonPrimitive();
}
} else if ("leaves".equals(key)) {
if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isString()) {
getPrimitiveLeaves(element.getAsString()).assignTo(this);
} else if (element.isJsonObject()) {
getPrimitiveLeaves(element.getAsJsonObject()).assignTo(this);
}
} else if ("cellkit".equals(key)) {
ICellKit kit = TreeRegistry.findCellKit(element.getAsString());
if (kit != null) {
cellKit = kit;
}
} else if ("smother".equals(key)) {
smotherLeavesMax = MathHelper.clamp(element.getAsInt(), 0, 64);
} else if ("light".equals(key)) {
lightRequirement = MathHelper.clamp(element.getAsInt(), 0, 15);
} else if ("connectAny".equals(key)) {
if (element.isJsonPrimitive()) {
connectAnyRadius = element.getAsBoolean();
}
} else if ("flammability".equals(key)) {
if (element.isJsonPrimitive()) {
flammability = element.getAsInt();
}
} else if ("fireSpreadSpeed".equals(key)) {
if (element.isJsonPrimitive()) {
fireSpreadSpeed = element.getAsInt();
}
}
}
// Free up json object since it is no longer used
jsonObj = null;
}
}
use of com.ferreusveritas.dynamictrees.api.cells.ICellKit in project DynamicTrees by DynamicTreesTeam.
the class TreeBuilder method build.
/**
* Builds a {@link TreeFamily} according to the specs provided. Called last in the builder chain. Repeated calls can
* be made but be sure to change the Name and Sequence for the tree before creating multiple trees.
*
* @return The newly built {@link TreeFamily}
*/
public TreeFamily build() {
if (name == null) {
System.err.println("Error: Attempted to build an nameless tree");
return TreeFamily.NULLFAMILY;
}
if (seqNum == -1 && dynamicLeavesProperties == null) {
System.err.println("Error: Attempted to build an unsequenced tree(or a tree without dynamic leaves properties)");
return TreeFamily.NULLFAMILY;
}
TreeFamily treeFamily = new TreeFamily(name) {
{
if (dynamicLeavesProperties == null) {
dynamicLeavesProperties = new LeavesProperties(primitiveLeavesBlockState) {
@Override
public int getLightRequirement() {
return dynamicLeavesLightRequirement;
}
public int getSmotherLeavesMax() {
return dynamicLeavesSmotherMax;
}
@Override
public ICellKit getCellKit() {
return TreeRegistry.findCellKit(dynamicLeavesCellKit);
}
};
LeavesPaging.getLeavesBlockForSequence(ModConstants.MODID, seqNum, dynamicLeavesProperties);
}
this.setPrimitiveLog(primitiveLogBlockState);
dynamicLeavesProperties.setTree(this);
if (stickItemStack != null) {
setStick(stickItemStack);
}
}
@Override
public void createSpecies() {
setCommonSpecies(speciesCreator != null ? speciesCreator.create(this) : new Species(name, this, dynamicLeavesProperties));
if (speciesCreateSeed) {
getCommonSpecies().generateSeed();
getCommonSpecies().setupStandardSeedDropping();
}
for (ISpeciesCreator creator : extraSpeciesCreators) {
Species species = creator.create(this);
extraSpecies.put(species.getRegistryName().getResourcePath(), species);
}
}
@Override
public void registerSpecies(IForgeRegistry<Species> speciesRegistry) {
super.registerSpecies(speciesRegistry);
extraSpecies.values().forEach(s -> speciesRegistry.register(s));
}
@Override
public List<Item> getRegisterableItems(List<Item> itemList) {
for (Species species : extraSpecies.values()) {
// Since we generated the species internally we need to let the seed out to be registered.
Seed seed = species.getSeed();
if (seed != Seed.NULLSEED) {
itemList.add(seed);
}
}
return super.getRegisterableItems(itemList);
}
};
return treeFamily;
}
Aggregations