Improve CraftTweaker documentation

This commit is contained in:
modmuss50 2018-04-02 10:42:02 +01:00
parent 980db3cd60
commit 20849b4a11
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
20 changed files with 70 additions and 0 deletions

View file

@ -295,6 +295,7 @@ build.dependsOn signJar
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'
import com.google.gson.JsonArray
import groovy.util.XmlSlurper
import org.apache.commons.io.FileUtils
@ -356,6 +357,9 @@ task mtDocGen {
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("type").asString.equals("METHOD") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenMethod;")){
def method = sanitsiseMethodName(annotation.asJsonObject.get("target").asString)
if(hasZenDoc(annotation, annoations)){
method = getZenDoc(annotation, annoations)
}
def zen_name = getZenMetName(clzz)
builder.append(zen_name + "." + method)
builder.append("\n")
@ -371,6 +375,32 @@ task mtDocGen {
}
}
boolean hasZenDoc(JsonObject currentAnnotation, JsonArray annoations){
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){
return true
}
}
return false
}
String getZenDoc(JsonObject currentAnnotation, JsonArray annoations){
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){
def methodName = annotation.asJsonObject.get("target").asString.split("\\(")[0]
def methodParams = annotation.asJsonObject.get("value").asJsonObject.get("value").asString
if(!methodParams.startsWith("(")){
methodParams = "(" + methodParams
}
if(!methodParams.endsWith(")")){
methodParams = methodParams + ")"
}
return methodName + methodParams
}
}
return ""
}
//Gets the zenMethod class name from the class json object
String getZenMetName(JsonObject jsonObject){
def annoations = jsonObject.get("annotations").asJsonArray

View file

@ -53,11 +53,13 @@ public class CTAlloySmelter extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTAssemblingMachine extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTBlastFurnace extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTCentrifuge extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTChemicalReactor extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -49,11 +49,13 @@ public class CTCompressor extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -52,11 +52,13 @@ public class CTDistillationTower extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -49,11 +49,13 @@ public class CTExtractor extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -64,26 +64,31 @@ public class CTFluidGen {
}
@ZenMethod
@ZenDocumentation("ILiquidStack fluid")
public static void removeThermalFluid(ILiquidStack fluid) {
removeFluid(EFluidGenerator.THERMAL, fluid);
}
@ZenMethod
@ZenDocumentation("ILiquidStack fluid")
public static void removeGasFluid(ILiquidStack fluid) {
removeFluid(EFluidGenerator.GAS, fluid);
}
@ZenMethod
@ZenDocumentation("ILiquidStack fluid")
public static void removeSemiFluid(ILiquidStack fluid) {
removeFluid(EFluidGenerator.SEMIFLUID, fluid);
}
@ZenMethod
@ZenDocumentation("ILiquidStack fluid")
public static void removeDieselFluid(ILiquidStack fluid) {
removeFluid(EFluidGenerator.DIESEL, fluid);
}
@ZenMethod
@ZenDocumentation("ILiquidStack fluid")
public static void removePlasmaFluid(ILiquidStack fluid) {
removeFluid(EFluidGenerator.PLASMA, fluid);
}

View file

@ -50,16 +50,19 @@ public class CTFusionReactor {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeTopInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveTopInput(iIngredient));
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeBottomInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveBottomInput(iIngredient));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output)));
}

View file

@ -50,11 +50,13 @@ public class CTGrinder extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTImplosionCompressor extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -48,11 +48,13 @@ public class CTIndustrialElectrolyzer extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -92,6 +92,7 @@ public class CTIndustrialGrinder extends CTGeneric {
* @param iIngredient Recipe input for which we should remove recipe
*/
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) { CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName())); }
/**
@ -99,6 +100,7 @@ public class CTIndustrialGrinder extends CTGeneric {
* @param output Recipe output for which we should remove recipe
*/
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -72,11 +72,13 @@ public class CTIndustrialSawmill extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -58,6 +58,7 @@ public class CTRollingMachine {
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
List<ResourceLocation> toRemove = new ArrayList<>();
for (Map.Entry<ResourceLocation, IRecipe> recipe : RollingMachineRecipe.instance.getRecipeList().entrySet()) {

View file

@ -43,11 +43,13 @@ import techreborn.compat.crafttweaker.CTGeneric.Remove;
public class CTScrapbox {
@ZenMethod
@ZenDocumentation("IIngredient input")
public static void addScrapboxDrop(IIngredient input) {
RecipeHandler.addRecipe(new ScrapboxRecipe(CraftTweakerMC.getItemStack(input), 20, 2));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -46,11 +46,13 @@ public class CTVacuumFreezer extends CTGeneric {
}
@ZenMethod
@ZenDocumentation("IIngredient iIngredient")
public static void removeInputRecipe(IIngredient iIngredient) {
CraftTweakerAPI.apply(new RemoveInput(iIngredient, getMachineName()));
}
@ZenMethod
@ZenDocumentation("IItemStack output")
public static void removeRecipe(IItemStack output) {
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
}

View file

@ -14,6 +14,7 @@ public class RecipeSettings {
}
@ZenMethod
@ZenDocumentation("boolean useOreDict")
public void setUseOreDict(boolean useOreDict){
baseRecipe.setOreDict(useOreDict);
}