generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tinkers' Construct Documentation (#157)
* Basic docs * Finish docs * Add example script * Add .register() * Split entity melting * Changes * Update en_us.lang * Gen example script * Fix errors * Split casting into different files * Better descriptions * forgor the script 💀 * Use resource handler * add register description * use clear for entity melting * Improve alloying description * alloying removal examples * Ahhh * Use description defaults * use clear() * ` * the schizophrenia is getting worse * Add missing lang key * add property annotations
Showing
13 changed files
with
694 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
// Auto generated groovyscript example file | ||
// MODS_LOADED: tconstruct | ||
|
||
println 'mod \'tconstruct\' detected, running script' | ||
|
||
// Alloying: | ||
// Modifies what fluids can be mixed together in the Smeltery. | ||
|
||
mods.tconstruct.alloying.removeByInputs(fluid('cobalt')*2,fluid('ardite')*2) | ||
mods.tconstruct.alloying.removeByInputsAndOutput(fluid('knightslime')*72,fluid('iron')*72,fluid('stone')*144,fluid('purpleslime')*125) | ||
mods.tconstruct.alloying.removeByOutput(fluid('pigiron')) | ||
// mods.tconstruct.alloying.removeAll() | ||
|
||
mods.tconstruct.alloying.recipeBuilder() | ||
.fluidOutput(fluid('iron') * 3) | ||
.fluidInput(fluid('clay') * 1,fluid('lava') * 2) | ||
.register() | ||
|
||
|
||
mods.tconstruct.alloying.add(fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60) | ||
|
||
// Casting Basin: | ||
// Pours out fluid into a basin to solidify it into a solid, optionally with a cast itemstack. | ||
|
||
mods.tconstruct.casting_basin.removeByCast(item('minecraft:planks:0')) | ||
mods.tconstruct.casting_basin.removeByInput(fluid('clay')) | ||
mods.tconstruct.casting_basin.removeByOutput(item('minecraft:iron_block')) | ||
// mods.tconstruct.casting_basin.removeAll() | ||
|
||
mods.tconstruct.casting_basin.recipeBuilder() | ||
.fluidInput(fluid('water')) | ||
.output(item('minecraft:dirt')) | ||
.cast(item('minecraft:cobblestone')) | ||
.coolingTime(40) | ||
.register() | ||
|
||
|
||
// Casting Table: | ||
// Pours out fluid onto a table to solidify it into a solid, optionally with a cast itemstack. | ||
|
||
mods.tconstruct.casting_table.removeByCast(item('minecraft:bucket')) | ||
mods.tconstruct.casting_table.removeByInput(fluid('iron')) | ||
mods.tconstruct.casting_table.removeByOutput(item('minecraft:gold_ingot')) | ||
// mods.tconstruct.casting_table.removeAll() | ||
|
||
mods.tconstruct.casting_table.recipeBuilder() | ||
.fluidInput(fluid('lava') * 50) | ||
.output(item('minecraft:diamond')) | ||
.coolingTime(750) | ||
.consumesCast(true) | ||
.cast(ore('gemEmerald')) | ||
.register() | ||
|
||
|
||
// Drying Rack: | ||
// Convert an item into a different item by hanging it out to dry. | ||
|
||
// mods.tconstruct.drying.removeAll() | ||
|
||
mods.tconstruct.drying.recipeBuilder() | ||
.input(item('minecraft:clay')) | ||
.output(item('minecraft:dirt')) | ||
.time(45) | ||
.register() | ||
|
||
|
||
|
||
// Entity Melting: | ||
// Allows mobs to create a bit of fluid when hurt by the Smeltery. | ||
|
||
// mods.tconstruct.entity_melting.removeAll() | ||
|
||
mods.tconstruct.entity_melting.recipeBuilder() | ||
.fluidOutput(fluid('iron') * 500) | ||
.input(resource('minecraft:pig')) | ||
.register() | ||
|
||
|
||
// Melting: | ||
// Modifies what items can be melted down in the Smeltery. | ||
|
||
// mods.tconstruct.melting.removeAll() | ||
|
||
mods.tconstruct.melting.recipeBuilder() | ||
.input(item('minecraft:gravel')) | ||
.fluidOutput(fluid('lava') * 25) | ||
.time(80) | ||
.register() | ||
|
||
|
||
|
||
// Smeltery Fuel: | ||
// Modifies what fluids are accepted as fuels for the Smeltery and how long each fuels the Smeltery. | ||
|
||
// mods.tconstruct.smeltery_fuel.removeAll() | ||
|
||
mods.tconstruct.smeltery_fuel.addFuel(fluid('water'), 250) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
293 changes: 0 additions & 293 deletions
293
src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Casting.java
This file was deleted.
Oops, something went wrong.
164 changes: 164 additions & 0 deletions
164
src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyBlacklist; | ||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; | ||
import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; | ||
import com.cleanroommc.groovyscript.helper.Alias; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidRegistry; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import org.jetbrains.annotations.Nullable; | ||
import slimeknights.tconstruct.library.smeltery.CastingRecipe; | ||
import slimeknights.tconstruct.library.smeltery.ICastingRecipe; | ||
|
||
@RegistryDescription | ||
public class CastingBasin extends VirtualizedRegistry<ICastingRecipe> { | ||
|
||
@RecipeBuilderDescription(example = @Example(".fluidInput(fluid('water')).output(item('minecraft:dirt')).cast(item('minecraft:cobblestone')).coolingTime(40)")) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
public CastingBasin() { | ||
super(Alias.generateOfClass(CastingBasin.class).andGenerate("Basin")); | ||
} | ||
|
||
@Override | ||
@GroovyBlacklist | ||
public void onReload() { | ||
removeScripted().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::remove); | ||
restoreFromBackup().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::add); | ||
} | ||
|
||
public void add(ICastingRecipe recipe) { | ||
if (recipe == null) return; | ||
addScripted(recipe); | ||
TinkerRegistryAccessor.getBasinCastRegistry().add(recipe); | ||
} | ||
|
||
public boolean remove(ICastingRecipe recipe) { | ||
if (recipe == null) return false; | ||
addBackup(recipe); | ||
TinkerRegistryAccessor.getBasinCastRegistry().remove(recipe); | ||
return true; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:iron_block')")) | ||
public boolean removeByOutput(ItemStack output) { | ||
if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { | ||
boolean found = ItemStack.areItemStacksEqual(recipe.getResult(ItemStack.EMPTY, FluidRegistry.WATER), output); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") | ||
.add("could not find recipe with output {}", output) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("fluid('clay')")) | ||
public boolean removeByInput(FluidStack input) { | ||
if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { | ||
boolean found = recipe.getFluid(ItemStack.EMPTY, input.getFluid()).isFluidEqual(input); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") | ||
.add("could not find recipe with input {}", input) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:planks:0')")) | ||
public boolean removeByCast(IIngredient cast) { | ||
ItemStack castStack = cast.getMatchingStacks()[0]; | ||
if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { | ||
boolean found = recipe.matches(castStack, recipe.getFluid(castStack, FluidRegistry.WATER).getFluid()); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") | ||
.add("could not find recipe with cast {}", cast) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
TinkerRegistryAccessor.getBasinCastRegistry().forEach(this::addBackup); | ||
TinkerRegistryAccessor.getBasinCastRegistry().clear(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<ICastingRecipe> streamRecipes() { | ||
return new SimpleObjectStream<>(TinkerRegistryAccessor.getBasinCastRegistry()).setRemover(this::remove); | ||
} | ||
|
||
@Property(property = "fluidInput", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public class RecipeBuilder extends AbstractRecipeBuilder<ICastingRecipe> { | ||
|
||
@Property | ||
private IIngredient cast; | ||
@Property(defaultValue = "200", valid = @Comp(value = "1", type = Comp.Type.GTE)) | ||
private int time = 200; | ||
@Property | ||
private boolean consumesCast = false; | ||
|
||
@RecipeBuilderMethodDescription(field = "time") | ||
public RecipeBuilder coolingTime(int time) { | ||
this.time = Math.max(time, 1); | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder consumesCast(boolean consumesCast) { | ||
this.consumesCast = consumesCast; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder consumesCast() { | ||
return consumesCast(!consumesCast); | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder cast(IIngredient ingredient) { | ||
this.cast = ingredient; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Tinkers Construct Casting Basin recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateFluids(msg, 1, 1, 0, 0); | ||
validateItems(msg, 0, 0, 1, 1); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable ICastingRecipe register() { | ||
if (!validate()) return null; | ||
CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient(cast) | ||
: null, fluidInput.get(0), time, consumesCast, false); | ||
add(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
163 changes: 163 additions & 0 deletions
163
src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyBlacklist; | ||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.IIngredient; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; | ||
import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; | ||
import com.cleanroommc.groovyscript.helper.Alias; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.fluids.FluidRegistry; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import org.jetbrains.annotations.Nullable; | ||
import slimeknights.tconstruct.library.smeltery.CastingRecipe; | ||
import slimeknights.tconstruct.library.smeltery.ICastingRecipe; | ||
|
||
@RegistryDescription | ||
public class CastingTable extends VirtualizedRegistry<ICastingRecipe> { | ||
|
||
@RecipeBuilderDescription(example = @Example(".fluidInput(fluid('lava') * 50).output(item('minecraft:diamond')).coolingTime(750).consumesCast(true).cast(ore('gemEmerald'))")) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
public CastingTable() { | ||
super(Alias.generateOfClass(CastingTable.class).andGenerate("Table")); | ||
} | ||
|
||
@Override | ||
@GroovyBlacklist | ||
public void onReload() { | ||
removeScripted().forEach(TinkerRegistryAccessor.getTableCastRegistry()::remove); | ||
restoreFromBackup().forEach(TinkerRegistryAccessor.getTableCastRegistry()::add); | ||
} | ||
|
||
public void add(ICastingRecipe recipe) { | ||
if (recipe == null) return; | ||
addScripted(recipe); | ||
TinkerRegistryAccessor.getTableCastRegistry().add(recipe); | ||
} | ||
|
||
public boolean remove(ICastingRecipe recipe) { | ||
if (recipe == null) return false; | ||
addBackup(recipe); | ||
TinkerRegistryAccessor.getTableCastRegistry().remove(recipe); | ||
return true; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:gold_ingot')")) | ||
public boolean removeByOutput(ItemStack output) { | ||
if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { | ||
boolean found = recipe.getResult(ItemStack.EMPTY, FluidRegistry.WATER).isItemEqual(output); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") | ||
.add("could not find recipe with output {}", output) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("fluid('iron')")) | ||
public boolean removeByInput(FluidStack input) { | ||
if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { | ||
boolean found = recipe.getFluid(ItemStack.EMPTY, input.getFluid()).isFluidEqual(input); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") | ||
.add("could not find recipe with input {}", input) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(example = @Example("item('minecraft:bucket')")) | ||
public boolean removeByCast(IIngredient cast) { | ||
if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { | ||
boolean found = recipe.matches(cast.getMatchingStacks()[0], recipe.getFluid(cast.getMatchingStacks()[0], FluidRegistry.WATER).getFluid()); | ||
if (found) addBackup(recipe); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") | ||
.add("could not find recipe with cast {}", cast) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
TinkerRegistryAccessor.getTableCastRegistry().forEach(this::addBackup); | ||
TinkerRegistryAccessor.getTableCastRegistry().clear(); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<ICastingRecipe> streamRecipes() { | ||
return new SimpleObjectStream<>(TinkerRegistryAccessor.getTableCastRegistry()).setRemover(this::remove); | ||
} | ||
|
||
@Property(property = "fluidInput", valid = @Comp("1")) | ||
@Property(property = "output", valid = @Comp("1")) | ||
public class RecipeBuilder extends AbstractRecipeBuilder<ICastingRecipe> { | ||
|
||
@Property | ||
private IIngredient cast; | ||
@Property(defaultValue = "200", valid = @Comp(value = "1", type = Comp.Type.GTE)) | ||
private int time = 200; | ||
@Property | ||
private boolean consumesCast = false; | ||
|
||
@RecipeBuilderMethodDescription(field = "time") | ||
public RecipeBuilder coolingTime(int time) { | ||
this.time = Math.max(time, 1); | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder consumesCast(boolean consumesCast) { | ||
this.consumesCast = consumesCast; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder consumesCast() { | ||
return consumesCast(!consumesCast); | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder cast(IIngredient ingredient) { | ||
this.cast = ingredient; | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getErrorMsg() { | ||
return "Error adding Tinkers Construct Casting Table recipe"; | ||
} | ||
|
||
@Override | ||
public void validate(GroovyLog.Msg msg) { | ||
validateFluids(msg, 1, 1, 0, 0); | ||
validateItems(msg, 0, 0, 1, 1); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable ICastingRecipe register() { | ||
if (!validate()) return null; | ||
CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient(cast) | ||
: null, fluidInput.get(0), time, consumesCast, false); | ||
add(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/EntityMelting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; | ||
|
||
import com.cleanroommc.groovyscript.api.GroovyBlacklist; | ||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
import com.cleanroommc.groovyscript.api.documentation.annotations.*; | ||
import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.EntityMeltingRecipe; | ||
import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; | ||
import com.cleanroommc.groovyscript.helper.SimpleObjectStream; | ||
import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; | ||
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; | ||
import net.minecraft.entity.EntityList; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fml.common.registry.EntityEntry; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@RegistryDescription | ||
public class EntityMelting extends VirtualizedRegistry<EntityMeltingRecipe> { | ||
|
||
@RecipeBuilderDescription(example = @Example(".fluidOutput(fluid('iron') * 500).input(resource('minecraft:pig'))")) | ||
public RecipeBuilder recipeBuilder() { | ||
return new RecipeBuilder(); | ||
} | ||
|
||
@Override | ||
@GroovyBlacklist | ||
public void onReload() { | ||
removeScripted().forEach(recipe -> TinkerRegistryAccessor.getEntityMeltingRegistry().remove(recipe.name, recipe.result)); | ||
restoreFromBackup().forEach(recipe -> TinkerRegistryAccessor.getEntityMeltingRegistry().put(recipe.name, recipe.result)); | ||
} | ||
|
||
@MethodDescription(type = MethodDescription.Type.QUERY) | ||
protected List<EntityMeltingRecipe> getAllRecipes() { | ||
return TinkerRegistryAccessor.getEntityMeltingRegistry().entrySet().stream().map(EntityMeltingRecipe::fromMapEntry).collect(Collectors.toList()); | ||
} | ||
|
||
public EntityMeltingRecipe add(EntityEntry entity, FluidStack output) { | ||
EntityMeltingRecipe recipe = new EntityMeltingRecipe(entity, output); | ||
add(recipe); | ||
return recipe; | ||
} | ||
|
||
public void add(EntityMeltingRecipe recipe) { | ||
if (recipe == null || recipe.name == null) return; | ||
addScripted(recipe); | ||
TinkerRegistryAccessor.getEntityMeltingRegistry().put(recipe.name, recipe.result); | ||
} | ||
|
||
public boolean remove(EntityMeltingRecipe recipe) { | ||
if (recipe == null || recipe.name == null) return false; | ||
addBackup(recipe); | ||
TinkerRegistryAccessor.getEntityMeltingRegistry().remove(recipe.name, recipe.result); | ||
return true; | ||
} | ||
|
||
@MethodDescription | ||
public boolean removeByInput(EntityEntry entity) { | ||
ResourceLocation name = entity.getRegistryName(); | ||
if (TinkerRegistryAccessor.getEntityMeltingRegistry().entrySet().removeIf(entry -> { | ||
boolean found = entry.getKey().equals(name); | ||
if (found) addBackup(new EntityMeltingRecipe(entry.getKey(), entry.getValue())); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe") | ||
.add("could not find recipe with input {}", name) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription | ||
public boolean removeByOutput(FluidStack output) { | ||
if (TinkerRegistryAccessor.getEntityMeltingRegistry().entrySet().removeIf(entry -> { | ||
boolean found = entry.getValue().isFluidEqual(output); | ||
if (found) addBackup(new EntityMeltingRecipe(entry.getKey(), entry.getValue())); | ||
return found; | ||
})) return true; | ||
|
||
GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe") | ||
.add("could not find recipe with output {}", output) | ||
.error() | ||
.post(); | ||
return false; | ||
} | ||
|
||
@MethodDescription(priority = 2000, example = @Example(commented = true)) | ||
public void removeAll() { | ||
TinkerRegistryAccessor.getEntityMeltingRegistry().forEach((name, result) -> addBackup(new EntityMeltingRecipe(name, result))); | ||
TinkerRegistryAccessor.getEntityMeltingRegistry().clear(); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY) | ||
public SimpleObjectStream<EntityMeltingRecipe> streamRecipes() { | ||
return new SimpleObjectStream<>(getAllRecipes()).setRemover(this::remove); | ||
} | ||
|
||
public class RecipeBuilder implements IRecipeBuilder<EntityMeltingRecipe> { | ||
|
||
@Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) | ||
private FluidStack output; | ||
@Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) | ||
private ResourceLocation input; | ||
|
||
@RecipeBuilderMethodDescription(field = "output") | ||
public RecipeBuilder fluidOutput(FluidStack stack) { | ||
this.output = stack; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder input(ResourceLocation name) { | ||
this.input = name; | ||
return this; | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder input(String name) { | ||
return input(new ResourceLocation(name)); | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder input(String modid, String name) { | ||
return input(new ResourceLocation(modid, name)); | ||
} | ||
|
||
@RecipeBuilderMethodDescription | ||
public RecipeBuilder input(EntityEntry entity) { | ||
return input(entity.getRegistryName()); | ||
} | ||
|
||
private String getErrorMsg() { | ||
return "Error adding Tinkers Construct Entity Melting recipe"; | ||
} | ||
|
||
private void validate(GroovyLog.Msg msg) { | ||
msg.add(input == null || EntityList.getClass(input) == null, "Expected valid entity name, got " + input); | ||
msg.add(output == null || output.amount < 1, "Expected 1 output fluid but found none!"); | ||
} | ||
|
||
@Override | ||
public boolean validate() { | ||
GroovyLog.Msg msg = GroovyLog.msg(this.getErrorMsg()).error(); | ||
this.validate(msg); | ||
return !msg.postIfNotEmpty(); | ||
} | ||
|
||
@Override | ||
@RecipeBuilderRegistrationMethod | ||
public @Nullable EntityMeltingRecipe register() { | ||
if (!validate()) return null; | ||
EntityMeltingRecipe recipe = new EntityMeltingRecipe(input, output); | ||
add(recipe); | ||
return recipe; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters