Update BlockGenerator and add the 1.17 blocks.

This commit is contained in:
Articdive 2021-06-11 17:47:26 +02:00
parent 7a76040457
commit 1a67ab806a
No known key found for this signature in database
GPG Key ID: B069585F0F7D90DE
17 changed files with 3474 additions and 1150 deletions

View File

@ -3,16 +3,7 @@ package net.minestom.codegen.attribute;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader; import com.squareup.javapoet.*;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -51,7 +42,7 @@ public final class AttributeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry"); ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray attributes = GSON.fromJson(new JsonReader(new InputStreamReader(attributesFile)), JsonArray.class); JsonArray attributes = GSON.fromJson(new InputStreamReader(attributesFile), JsonArray.class);
List<JavaFile> filesToWrite = new ArrayList<>(); List<JavaFile> filesToWrite = new ArrayList<>();
ClassName attributeClassName = ClassName.get("net.minestom.server.attribute", "Attribute"); ClassName attributeClassName = ClassName.get("net.minestom.server.attribute", "Attribute");

View File

@ -1,12 +1,8 @@
package net.minestom.codegen.blocks; package net.minestom.codegen.blocks;
import com.google.gson.JsonArray; import com.google.gson.*;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import net.minestom.codegen.util.NameUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -16,10 +12,7 @@ import javax.lang.model.element.Modifier;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public final class BlockGenerator extends MinestomCodeGenerator { public final class BlockGenerator extends MinestomCodeGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(BlockGenerator.class); private static final Logger LOGGER = LoggerFactory.getLogger(BlockGenerator.class);
@ -55,375 +48,228 @@ public final class BlockGenerator extends MinestomCodeGenerator {
return; return;
} }
// Important classes we use alot // Important classes we use alot
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDCN = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName blockPropertyCN = ClassName.get("net.minestom.server.instance.block", "BlockProperty");
ClassName blockCN = ClassName.get("net.minestom.server.instance.block", "Block");
ClassName blockImplCN = ClassName.get("net.minestom.server.instance.block", "BlockImpl");
JsonArray blocks = GSON.fromJson(new JsonReader(new InputStreamReader(blocksFile)), JsonArray.class); JsonArray blockProperties;
blockProperties = GSON.fromJson(new InputStreamReader(blockPropertyFile), JsonArray.class);
ClassName blockClassName = ClassName.get("net.minestom.server.instance.block", "Block"); ClassName blockPropertiesCN = ClassName.get("net.minestom.server.instance.block", "BlockProperties");
ClassName blockAltClassName = ClassName.get("net.minestom.server.instance.block", "BlockAlternative"); // Particle
List<JavaFile> filesToWrite = new ArrayList<>(); TypeSpec.Builder blockPropertiesClass = TypeSpec.classBuilder(blockPropertiesCN)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
// Block // Add @SuppressWarnings("unused")
TypeSpec.Builder blockClass = TypeSpec.enumBuilder(blockClassName) .addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "$S", "unused").build())
.addSuperinterface(ClassName.get("net.kyori.adventure.key", "Keyed")) .addJavadoc("AUTOGENERATED by " + getClass().getSimpleName());
.addModifiers(Modifier.PUBLIC).addJavadoc("AUTOGENERATED by " + getClass().getSimpleName()); // Add private constructor
blockPropertiesClass.addMethod(
blockClass.addField(
FieldSpec.builder(namespaceIDClassName, "id")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).addAnnotation(NotNull.class).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.SHORT, "defaultID")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.DOUBLE, "hardness")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.DOUBLE, "resistance")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.BOOLEAN, "isAir")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.BOOLEAN, "isSolid")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.BOOLEAN, "blockEntity")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(TypeName.BOOLEAN, "singleState")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL).build()
);
blockClass.addField(
FieldSpec.builder(ParameterizedTypeName.get(ClassName.get("java.util", "List"), blockAltClassName), "alternatives")
.initializer("new $T<>()", ClassName.get("java.util", "ArrayList"))
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
.addAnnotation(NotNull.class)
.build()
);
// static field
blockClass.addField(
FieldSpec.builder(ArrayTypeName.of(blockClassName), "VALUES")
.addModifiers(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
.initializer("values()")
.build()
);
// Block constructor
blockClass.addMethod(
MethodSpec.constructorBuilder() MethodSpec.constructorBuilder()
.addParameter(ParameterSpec.builder(namespaceIDClassName, "id").addAnnotation(NotNull.class).build()) .addModifiers(Modifier.PRIVATE)
.addParameter(TypeName.SHORT, "defaultID") .build()
.addParameter(TypeName.DOUBLE, "hardness") );
.addParameter(TypeName.DOUBLE, "resistance") // This stores the classes of the field names, e.g. WATERLOGGED --> Boolean
.addParameter(TypeName.BOOLEAN, "isAir") Map<String, Class<?>> propertyClassMap = new HashMap<>();
.addParameter(TypeName.BOOLEAN, "isSolid") Map<String, String> propertyKeyMap = new HashMap<>();
.addParameter(TypeName.BOOLEAN, "blockEntity") Map<String, String[]> propertyValueMap = new HashMap<>();
.addParameter(TypeName.BOOLEAN, "singleState") // Use data
for (JsonElement e : blockProperties) {
JsonObject blockProperty = e.getAsJsonObject();
.addStatement("this.id = id") String propertyName = blockProperty.get("name").getAsString();
.addStatement("this.defaultID = defaultID") JsonArray blockValues = blockProperty.get("values").getAsJsonArray();
.addStatement("this.hardness = hardness") JsonPrimitive firstElement = blockValues.get(0).getAsJsonPrimitive();
.addStatement("this.resistance = resistance")
.addStatement("this.isAir = isAir") Class<?> type;
.addStatement("this.isSolid = isSolid") StringBuilder values = new StringBuilder();
.addStatement("this.blockEntity = blockEntity") if (firstElement.isBoolean()) {
.addStatement("this.singleState = singleState") type = Boolean.class;
.beginControlFlow("if (singleState)") values = new StringBuilder("true, false");
.addStatement("addBlockAlternative(new $T(defaultID))", blockAltClassName) } else if (firstElement.isNumber()) {
.endControlFlow() type = Integer.class;
.addStatement("$T.blocks.put(id, this)", registriesClassName) for (JsonElement blockValue : blockValues) {
.build() int i = blockValue.getAsInt();
); values.append(i).append(", ");
// Override key method (adventure) }
blockClass.addMethod( // Delete final ', '
MethodSpec.methodBuilder("key") values.delete(values.lastIndexOf(","), values.length());
.returns(ClassName.get("net.kyori.adventure.key", "Key")) } else {
.addAnnotation(Override.class) type = String.class;
.addAnnotation(NotNull.class) for (JsonElement blockValue : blockValues) {
.addStatement("return this.id") String s = blockValue.getAsString();
.addModifiers(Modifier.PUBLIC) values.append("\"").append(s).append("\", ");
.build() }
); // Delete final ', '
// addBlockState method values.delete(values.lastIndexOf(","), values.length());
blockClass.addMethod( }
MethodSpec.methodBuilder("addBlockAlternative") String propertyKey = blockProperty.get("key").getAsString();
.addParameter(ParameterSpec.builder(blockAltClassName, "alternative").addAnnotation(NotNull.class).build())
propertyKeyMap.put(propertyName, propertyKey);
propertyClassMap.put(propertyName, type);
propertyValueMap.put(propertyName, values.toString().split(", "));
// Adds the field to the main class
// e.g. BlockProperty<Boolean> WATERLOGGED = new BlockProperty<Boolean>("waterlogged", true, false)
blockPropertiesClass.addField(
FieldSpec.builder(
ParameterizedTypeName.get(blockPropertyCN, TypeName.get(type)),
propertyName
).initializer(
"new $T<>($S, $L)",
blockPropertyCN,
propertyKey,
values
).addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).build()
);
}
JsonArray blocks;
blocks = GSON.fromJson(new InputStreamReader(blocksFile), JsonArray.class);
ClassName blocksCN = ClassName.get("net.minestom.server.instance.block", "BlockConstants");
// BlockConstants class
TypeSpec.Builder blockConstantsClass = TypeSpec.interfaceBuilder(blocksCN)
// Add @SuppressWarnings("unused")
.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "$S", "unused").build())
.addJavadoc("AUTOGENERATED by " + getClass().getSimpleName());
.addStatement("this.alternatives.add(alternative)")
.addStatement("BlockArray.blocks[alternative.getId()] = this")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.build()
);
// getId method
blockClass.addMethod(
MethodSpec.methodBuilder("getBlockId")
.returns(TypeName.SHORT)
.addStatement("return defaultID")
.addModifiers(Modifier.PUBLIC)
.build()
);
// getName method
blockClass.addMethod(
MethodSpec.methodBuilder("getName")
.addAnnotation(NotNull.class)
.returns(ClassName.get(String.class))
.addStatement("return this.id.asString()")
.addModifiers(Modifier.PUBLIC)
.build()
);
// getHardness method
blockClass.addMethod(
MethodSpec.methodBuilder("getHardness")
.returns(TypeName.DOUBLE)
.addStatement("return this.hardness")
.addModifiers(Modifier.PUBLIC)
.build()
);
// getResistance method
blockClass.addMethod(
MethodSpec.methodBuilder("getResistance")
.returns(TypeName.DOUBLE)
.addStatement("return this.resistance")
.addModifiers(Modifier.PUBLIC)
.build()
);
// breakInstantaneously method
blockClass.addMethod(
MethodSpec.methodBuilder("breaksInstantaneously")
.returns(TypeName.BOOLEAN)
.addStatement("return this.hardness == 0")
.addModifiers(Modifier.PUBLIC)
.build()
);
// getBlockStates method
blockClass.addMethod(
MethodSpec.methodBuilder("getAlternatives")
.returns(ParameterizedTypeName.get(ClassName.get(List.class), blockAltClassName))
.addAnnotation(NotNull.class)
.addStatement("return this.alternatives")
.addModifiers(Modifier.PUBLIC, Modifier.FINAL) // Should this be final, for now I guess so.
.build()
);
// isAir method
blockClass.addMethod(
MethodSpec.methodBuilder("isAir")
.returns(TypeName.BOOLEAN)
// UPDATE: Make sure they didn't add new AIR types.
.addStatement("return isAir")
.addModifiers(Modifier.PUBLIC)
.build()
);
// isLiquid method
blockClass.addMethod(
MethodSpec.methodBuilder("isLiquid")
.returns(TypeName.BOOLEAN)
// UPDATE: Make sure they didn't add new liquids.
.addStatement("return this == WATER || this == LAVA")
.addModifiers(Modifier.PUBLIC)
.build()
);
// isSolid method
blockClass.addMethod(
MethodSpec.methodBuilder("isSolid")
.returns(TypeName.BOOLEAN)
// UPDATE: Make sure they didn't add new liquids.
.addStatement("return isSolid")
.addModifiers(Modifier.PUBLIC)
.build()
);
// hasBlockEntity method
blockClass.addMethod(
MethodSpec.methodBuilder("hasBlockEntity")
.returns(TypeName.BOOLEAN)
.addStatement("return blockEntity")
.addModifiers(Modifier.PUBLIC)
.build()
);
// getAlternative method
blockClass.addMethod(
MethodSpec.methodBuilder("getAlternative")
.returns(blockAltClassName)
.addParameter(TypeName.SHORT, "blockId")
.addAnnotation(Nullable.class)
.beginControlFlow("for ($T alt : alternatives) ", blockAltClassName)
.beginControlFlow("if (alt.getId() == blockId)")
.addStatement("return alt")
.endControlFlow()
.endControlFlow()
.addStatement("return null")
.addModifiers(Modifier.PUBLIC)
.build()
);
// withProperties method
blockClass.addMethod(
MethodSpec.methodBuilder("withProperties")
.returns(TypeName.SHORT)
.addParameter(
ParameterSpec.builder(ArrayTypeName.of(String.class), "properties").addAnnotation(NotNull.class).build()
).varargs()
.beginControlFlow("for ($T alt : alternatives)", blockAltClassName)
.beginControlFlow("if ($T.equals(alt.getProperties(), properties))", Arrays.class)
.addStatement("return alt.getId()")
.endControlFlow()
.endControlFlow()
.addStatement("return this.defaultID")
.addModifiers(Modifier.PUBLIC)
.build()
);
// fromStateId method
blockClass.addMethod(
MethodSpec.methodBuilder("fromStateId")
.returns(blockClassName)
.addParameter(TypeName.SHORT, "blockStateId")
.addStatement("return BlockArray.blocks[blockStateId]")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.build()
);
// fromId Method
blockClass.addMethod(
MethodSpec.methodBuilder("fromId")
.returns(blockClassName)
.addAnnotation(Nullable.class)
.addParameter(TypeName.SHORT, "id")
.beginControlFlow("if(id >= 0 && id < VALUES.length)")
.addStatement("return VALUES[id]")
.endControlFlow()
.addStatement("return null")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.build()
);
// toString method
blockClass.addMethod(
MethodSpec.methodBuilder("toString")
.addAnnotation(NotNull.class)
.addAnnotation(Override.class)
.returns(String.class)
// this resolves to [Namespace]
.addStatement("return \"[\" + this.id + \"]\"")
.addModifiers(Modifier.PUBLIC)
.build()
);
// Staticblock in Block enum
CodeBlock.Builder staticBlock = CodeBlock.builder();
// Use data // Use data
for (JsonElement b : blocks) { for (JsonElement b : blocks) {
JsonObject block = b.getAsJsonObject(); JsonObject block = b.getAsJsonObject();
String blockName = block.get("name").getAsString(); String blockName = block.get("name").getAsString();
JsonArray states = block.get("states").getAsJsonArray(); // Handle the properties
// Enum constant in Block // Create a subclass for each Block and reference the main BlockProperty.
blockClass.addEnumConstant(blockName, TypeSpec.anonymousClassBuilder( JsonArray properties = block.get("properties").getAsJsonArray();
"$T.from($S), (short) $L, $L, $L, $L, $L, $L, $L", if (properties.size() != 0) {
namespaceIDClassName, // Create a subclass called "blockName"
block.get("id").getAsString(), // e.g. subclass AIR in BlockProperties
block.get("defaultBlockState").getAsShort(), TypeSpec.Builder subClass = TypeSpec.classBuilder(blockPropertiesCN.nestedClass(blockName))
states.get(0).getAsJsonObject().get("destroySpeed").getAsDouble(), .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
block.get("explosionResistance").getAsDouble(), .addJavadoc(
states.get(0).getAsJsonObject().get("isAir").getAsBoolean(), "Represents the $L {@link $T $L} that {@link $T#$N} can have:\n",
states.get(0).getAsJsonObject().get("isSolid").getAsBoolean(), properties.size(),
block.get("blockEntity").getAsBoolean(), blockPropertyCN,
states.size() == 1 properties.size() > 1 ? "properties" : "property",
).build() blocksCN,
); blockName
if (states.size() > 1) { ).addJavadoc("<ul>\n");
ClassName blockStateSpecificClassName = ClassName.get(
"net.minestom.server.instance.block.states",
NameUtil.convertSnakeCaseToCamelCase(blockName.toLowerCase())
);
// Common blockStateSpecificClass structure // Store a list of values for the getProperties() method.
TypeSpec.Builder blockStateSpecificClass = TypeSpec.classBuilder(blockStateSpecificClassName) StringBuilder values = new StringBuilder();
.addAnnotation( // Go through all properties the block has.
AnnotationSpec.builder(Deprecated.class) for (JsonElement property : properties) {
.addMember("since", "$S", "forever") String propertyName = property.getAsString().toUpperCase(Locale.ROOT);
.addMember("forRemoval", "$L", false).build()
)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL).addJavadoc("Completely internal. DO NOT USE. IF YOU ARE A USER AND FACE A PROBLEM WHILE USING THIS CODE, THAT'S ON YOU.");
// initStates method // Add a static field that delegates to the BlockProperties static definition
MethodSpec.Builder initStatesMethod = MethodSpec.methodBuilder("initStates") FieldSpec.Builder field = FieldSpec.builder(
.addJavadoc("Completely internal. DO NOT USE. IF YOU ARE A USER AND FACE A PROBLEM WHILE USING THIS CODE, THAT'S ON YOU.") ParameterizedTypeName.get(blockPropertyCN, TypeName.get(propertyClassMap.get(propertyName))),
.addAnnotation( propertyName)
AnnotationSpec.builder(Deprecated.class) .initializer("$T.$N", blockPropertiesCN, propertyName)
.addMember("since", "$S", "forever") .addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.addMember("forRemoval", "$L", false).build() .addJavadoc("Definition: \"$L\" = [", propertyKeyMap.get(propertyName));
) // Results in "key" = ["value1", "value2"...]
.addModifiers(Modifier.PUBLIC, Modifier.STATIC); String[] propertyVals = propertyValueMap.get(propertyName);
for (int i = 0; i < propertyVals.length; i++) {
// init States methods in block specific classes if (i == propertyVals.length - 1) {
for (JsonElement s : states) { field.addJavadoc("$L]", propertyVals[i].toLowerCase());
JsonObject state = s.getAsJsonObject(); } else {
field.addJavadoc("$L, ", propertyVals[i].toLowerCase());
// block state properties
JsonObject properties = state.get("properties").getAsJsonObject();
if (properties.size() != 0) {
StringBuilder propertiesStr = new StringBuilder();
// has properties
for (Map.Entry<String, JsonElement> entry : properties.entrySet()) {
String key = entry.getKey();
String value = entry.getValue().getAsString().toLowerCase();
propertiesStr.append('"').append(key).append('=').append(value).append("\", ");
} }
// Delete last comma and space
propertiesStr.deleteCharAt(propertiesStr.length() - 1);
propertiesStr.deleteCharAt(propertiesStr.length() - 1);
initStatesMethod.addStatement(
"$T.$N.addBlockAlternative(new $T((short) $L, **REPLACE**))".replace("**REPLACE**", propertiesStr.toString()),
blockClassName,
blockName,
blockAltClassName,
state.get("id").getAsShort()
);
} else {
// has no properties
initStatesMethod.addStatement(
"$T.$N.addBlockAlternative(new $T((short) $L))",
blockClassName,
blockName,
blockAltClassName,
state.get("id").getAsShort()
);
} }
// Add field to subclass
subClass.addField(field.build());
values.append(propertyName).append(", ");
subClass.addJavadoc("<li>{@link $T#$N}</li>\n", blockPropertiesCN, propertyName);
} }
subClass.addJavadoc("</ul>");
// Add initStates method // Delete final ', '
blockStateSpecificClass.addMethod(initStatesMethod.build()); values.delete(values.lastIndexOf(","), values.length());
// Add a static method to get all the properties
// Add initStates method refence to static block subClass.addMethod(
staticBlock.addStatement("$T.initStates()", blockStateSpecificClassName); MethodSpec.methodBuilder("getProperties")
.returns(
// Add BlockStates to list of files we need to write: // List<BlockProperty<?>>
filesToWrite.add( ParameterizedTypeName.get(
JavaFile.builder("net.minestom.server.instance.block.states", blockStateSpecificClass.build() ClassName.get(List.class),
) // BlockProperty<?>
.indent(" ") ParameterizedTypeName.get(blockPropertyCN, TypeVariableName.get("?"))
.skipJavaLangImports(true) )
.build()); )
.addStatement(
"return $T.of($L)",
// If it has multiple properties --> Arrays.asList() else Collections.singletonList()
ClassName.get(List.class),
values
)
.addModifiers(Modifier.STATIC)
.build()
);
blockPropertiesClass.addType(subClass.build());
}
JsonArray states = block.getAsJsonArray("states");
// Now handle the fields in Blocks.
// If we don't have properties
if (properties.size() == 0) {
// This is a block like Stone that only has 1 BlockState.
blockConstantsClass.addField(
FieldSpec.builder(blockCN, blockName)
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer(
// Blocks.STONE = new BlockImpl(NamespaceID.from("minecraft:stone"), 1, Collections.emptyList())
"$T.create($T.from($S), (short) $L, (short) $L, (short) $L, (short) $L, $T.emptyList())",
blockImplCN,
namespaceIDCN,
block.get("id").getAsString(),
// Block id
block.get("numericalID").getAsShort(),
// First state id
states.get(0).getAsJsonObject().get("id").getAsShort(),
// Last state id
states.get(states.size() - 1).getAsJsonObject().get("id").getAsShort(),
// Default state id
block.get("defaultBlockState").getAsShort(),
ClassName.get(Collections.class)
)
.build()
);
} else {
// This is a block that has multiple properties.
blockConstantsClass.addField(
FieldSpec.builder(blockCN, blockName)
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer(
// Blocks.GRASS_BLOCK = new BlockImpl(NamespaceID.from("minecraft:grass_block"), 9, 8, varargsProperty)
"$T.create($T.from($S), (short) $L, (short) $L, (short) $L, (short) $L, $T.$N.getProperties())",
blockImplCN,
namespaceIDCN,
block.get("id").getAsString(),
// Block id
block.get("numericalID").getAsShort(),
// First id
block.getAsJsonArray("states").get(0).getAsJsonObject().get("id").getAsShort(),
// Last state id
states.get(states.size() - 1).getAsJsonObject().get("id").getAsShort(),
// DefaultBlockStateId
block.get("defaultBlockState").getAsShort(),
blockPropertiesCN,
blockName
)
.build()
);
} }
} }
blockClass.addStaticBlock(staticBlock.build()); writeFiles(
// Add ignore deprecations annotation List.of(
blockClass.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "$S", "deprecation").build()); JavaFile.builder("net.minestom.server.instance.block", blockPropertiesClass.build())
.indent(" ")
.skipJavaLangImports(true)
// Add Block & BlockState to list of files we need to write: .build(),
filesToWrite.add( JavaFile.builder("net.minestom.server.instance.block", blockConstantsClass.build())
JavaFile.builder("net.minestom.server.instance.block", blockClass.build()) .indent(" ")
.indent(" ") .skipJavaLangImports(true)
.skipJavaLangImports(true) .build()
.build() ),
outputFolder
); );
// Write files to outputFolder
writeFiles(filesToWrite, outputFolder);
} }
} }

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.entity;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import net.minestom.codegen.util.NameUtil; import net.minestom.codegen.util.NameUtil;
@ -201,7 +200,7 @@ public final class EntityTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray entities = GSON.fromJson(new JsonReader(new InputStreamReader(entitiesFile)), JsonArray.class); JsonArray entities = GSON.fromJson(new InputStreamReader(entitiesFile), JsonArray.class);
ClassName entityClassName = ClassName.get("net.minestom.server.entity", "EntityType"); ClassName entityClassName = ClassName.get("net.minestom.server.entity", "EntityType");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.entity;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -43,7 +44,7 @@ public final class VillagerProfessionGenerator extends MinestomCodeGenerator {
ClassName rawVillagerProfessionDataClassName = ClassName.get("net.minestom.server.raw_data", "RawVillagerProfessionData"); ClassName rawVillagerProfessionDataClassName = ClassName.get("net.minestom.server.raw_data", "RawVillagerProfessionData");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry"); ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray villagerProfessions = GSON.fromJson(new JsonReader(new InputStreamReader(villagerProfessionsFile)), JsonArray.class); JsonArray villagerProfessions = GSON.fromJson(new InputStreamReader(villagerProfessionsFile), JsonArray.class);
ClassName villagerProfessionClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerProfession"); ClassName villagerProfessionClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerProfession");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.entity;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -41,7 +42,7 @@ public final class VillagerTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry"); ClassName registryClassName = ClassName.get("net.minestom.server.registry", "Registry");
JsonArray villagerTypes = GSON.fromJson(new JsonReader(new InputStreamReader(villagerTypesFile)), JsonArray.class); JsonArray villagerTypes = GSON.fromJson(new InputStreamReader(villagerTypesFile), JsonArray.class);
ClassName villagerTypeClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerType"); ClassName villagerTypeClassName = ClassName.get("net.minestom.server.entity.metadata.villager", "VillagerType");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.fluid;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class FluidGenerator extends MinestomCodeGenerator { public final class FluidGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class FluidGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray fluids = GSON.fromJson(new JsonReader(new InputStreamReader(fluidsFile)), JsonArray.class); JsonArray fluids = GSON.fromJson(new InputStreamReader(fluidsFile), JsonArray.class);
ClassName fluidClassName = ClassName.get("net.minestom.server.fluid", "Fluid"); ClassName fluidClassName = ClassName.get("net.minestom.server.fluid", "Fluid");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.item;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class EnchantmentGenerator extends MinestomCodeGenerator { public final class EnchantmentGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class EnchantmentGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray enchantments = GSON.fromJson(new JsonReader(new InputStreamReader(enchantmentsFile)), JsonArray.class); JsonArray enchantments = GSON.fromJson(new InputStreamReader(enchantmentsFile), JsonArray.class);
ClassName enchantmentClassName = ClassName.get("net.minestom.server.item", "Enchantment"); ClassName enchantmentClassName = ClassName.get("net.minestom.server.item", "Enchantment");
// Enchantment // Enchantment

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.item;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -43,7 +44,7 @@ public final class MaterialGenerator extends MinestomCodeGenerator {
ClassName blockCN = ClassName.get("net.minestom.server.instance.block", "Block"); ClassName blockCN = ClassName.get("net.minestom.server.instance.block", "Block");
ParameterizedTypeName blocksCNSupplier = ParameterizedTypeName.get(ClassName.get(Supplier.class), blockCN); ParameterizedTypeName blocksCNSupplier = ParameterizedTypeName.get(ClassName.get(Supplier.class), blockCN);
JsonArray items = GSON.fromJson(new JsonReader(new InputStreamReader(itemsFile)), JsonArray.class); JsonArray items = GSON.fromJson(new InputStreamReader(itemsFile), JsonArray.class);
ClassName itemClassName = ClassName.get("net.minestom.server.item", "Material"); ClassName itemClassName = ClassName.get("net.minestom.server.item", "Material");
// Item // Item

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.particle;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class ParticleGenerator extends MinestomCodeGenerator { public final class ParticleGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class ParticleGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray particles = GSON.fromJson(new JsonReader(new InputStreamReader(particlesFile)), JsonArray.class); JsonArray particles = GSON.fromJson(new InputStreamReader(particlesFile), JsonArray.class);
ClassName particleClassName = ClassName.get("net.minestom.server.particle", "Particle"); ClassName particleClassName = ClassName.get("net.minestom.server.particle", "Particle");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.potion;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class PotionEffectGenerator extends MinestomCodeGenerator { public final class PotionEffectGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class PotionEffectGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray potionEffects = GSON.fromJson(new JsonReader(new InputStreamReader(potionEffectsFile)), JsonArray.class); JsonArray potionEffects = GSON.fromJson(new InputStreamReader(potionEffectsFile), JsonArray.class);
ClassName potionEffectClassName = ClassName.get("net.minestom.server.potion", "PotionEffect"); ClassName potionEffectClassName = ClassName.get("net.minestom.server.potion", "PotionEffect");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.potion;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class PotionTypeGenerator extends MinestomCodeGenerator { public final class PotionTypeGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class PotionTypeGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray potions = GSON.fromJson(new JsonReader(new InputStreamReader(potionsFile)), JsonArray.class); JsonArray potions = GSON.fromJson(new InputStreamReader(potionsFile), JsonArray.class);
ClassName potionTypeClassName = ClassName.get("net.minestom.server.potion", "PotionType"); ClassName potionTypeClassName = ClassName.get("net.minestom.server.potion", "PotionType");
// Particle // Particle

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.sound;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +11,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.lang.model.element.Modifier; import javax.lang.model.element.Modifier;
import java.io.*; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections; import java.util.Collections;
public final class SoundEventGenerator extends MinestomCodeGenerator { public final class SoundEventGenerator extends MinestomCodeGenerator {
@ -40,7 +41,7 @@ public final class SoundEventGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray sounds = GSON.fromJson(new JsonReader(new InputStreamReader(soundsFile)), JsonArray.class); JsonArray sounds = GSON.fromJson(new InputStreamReader(soundsFile), JsonArray.class);
ClassName soundClassName = ClassName.get("net.minestom.server.sound", "SoundEvent"); ClassName soundClassName = ClassName.get("net.minestom.server.sound", "SoundEvent");
// Sound // Sound
TypeSpec.Builder soundClass = TypeSpec.enumBuilder(soundClassName) TypeSpec.Builder soundClass = TypeSpec.enumBuilder(soundClassName)

View File

@ -3,7 +3,6 @@ package net.minestom.codegen.statistics;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import net.minestom.codegen.MinestomCodeGenerator; import net.minestom.codegen.MinestomCodeGenerator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -42,7 +41,7 @@ public final class StatisticGenerator extends MinestomCodeGenerator {
ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID"); ClassName namespaceIDClassName = ClassName.get("net.minestom.server.utils", "NamespaceID");
ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries"); ClassName registriesClassName = ClassName.get("net.minestom.server.registry", "Registries");
JsonArray statistics = GSON.fromJson(new JsonReader(new InputStreamReader(statisticsFile)), JsonArray.class); JsonArray statistics = GSON.fromJson(new InputStreamReader(statisticsFile), JsonArray.class);
ClassName statisticClassName = ClassName.get("net.minestom.server.statistic", "StatisticType"); ClassName statisticClassName = ClassName.get("net.minestom.server.statistic", "StatisticType");
// Particle // Particle

View File

@ -122,7 +122,7 @@ public class PFBlockDescription implements IBlockDescription {
&& !Block.CHEST.compare(block) && !Block.ENDER_CHEST.compare(block) && !Block.GRINDSTONE.compare(block) && !Block.CHEST.compare(block) && !Block.ENDER_CHEST.compare(block) && !Block.GRINDSTONE.compare(block)
&& !Block.TRAPPED_CHEST.compare(block) && !Block.SOUL_SAND.compare(block) && !Block.TRAPPED_CHEST.compare(block) && !Block.SOUL_SAND.compare(block)
&& !Block.SOUL_SOIL.compare(block) && !Block.LANTERN.compare(block) && !Block.COCOA.compare(block) && !Block.SOUL_SOIL.compare(block) && !Block.LANTERN.compare(block) && !Block.COCOA.compare(block)
&& !Block.CONDUIT.compare(block) && !Block.GRASS_PATH.compare(block) && !Block.FARMLAND.compare(block) && !Block.CONDUIT.compare(block) && !Block.DIRT_PATH.compare(block) && !Block.FARMLAND.compare(block)
&& !Block.END_ROD.compare(block) && !Block.STONECUTTER.compare(block) && !Block.BELL.compare(block); && !Block.END_ROD.compare(block) && !Block.STONECUTTER.compare(block) && !Block.BELL.compare(block);
} }

View File

@ -131,7 +131,7 @@ public class PFBlockObject implements IBlockObject {
&& !Block.CHEST.compare(block) && !Block.ENDER_CHEST.compare(block) && !Block.GRINDSTONE.compare(block) && !Block.CHEST.compare(block) && !Block.ENDER_CHEST.compare(block) && !Block.GRINDSTONE.compare(block)
&& !Block.TRAPPED_CHEST.compare(block) && !Block.SOUL_SAND.compare(block) && !Block.TRAPPED_CHEST.compare(block) && !Block.SOUL_SAND.compare(block)
&& !Block.SOUL_SOIL.compare(block) && !Block.LANTERN.compare(block) && !Block.COCOA.compare(block) && !Block.SOUL_SOIL.compare(block) && !Block.LANTERN.compare(block) && !Block.COCOA.compare(block)
&& !Block.CONDUIT.compare(block) && !Block.GRASS_PATH.compare(block) && !Block.FARMLAND.compare(block) && !Block.CONDUIT.compare(block) && !Block.DIRT_PATH.compare(block) && !Block.FARMLAND.compare(block)
&& !Block.END_ROD.compare(block) && !Block.STONECUTTER.compare(block) && !Block.BELL.compare(block); && !Block.END_ROD.compare(block) && !Block.STONECUTTER.compare(block) && !Block.BELL.compare(block);
} }