Skip to content

Commit

Permalink
fix 0 iq moments
Browse files Browse the repository at this point in the history
  • Loading branch information
yor42 committed Nov 18, 2024
1 parent ddf997c commit 47c2915
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 80 deletions.
4 changes: 4 additions & 0 deletions src/main/java/cn/academy/crafting/MetalFormerRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public boolean accepts(ItemStack stack, Mode mode2) {
input.getCount() <= stack.getCount() &&
input.getItemDamage() == stack.getItemDamage();
}

public void setId(int id) {
this.id = id;
}
}

final List<RecipeObject> objects = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public Collection<ImagFusorRecipes.IFRecipe> getRecipes() {
return ImagFusorRecipes.INSTANCE.getAllRecipe();
}

@MethodDescription(description = "groovyscript.wiki.academy.imag_fusor.add", type = MethodDescription.Type.ADDITION)
@MethodDescription(description = "groovyscript.wiki.academy.imag_fusor.add", example = @Example("item('academy:crystal_normal'), item('academy:crystal_low'), 3000"), type = MethodDescription.Type.ADDITION)
public void addRecipe(ItemStack output, IIngredient input, int liquidAmount){
for(ItemStack stack:input.getMatchingStacks()) {
this.addRecipe(new ImagFusorRecipes.IFRecipe(stack, liquidAmount, output));
this.add(new ImagFusorRecipes.IFRecipe(stack, liquidAmount, output));
}
}

Expand All @@ -37,8 +37,4 @@ public void removeByInput(ItemStack input) {
}
}

public void addRecipe(ImagFusorRecipes.IFRecipe recipe){
ImagFusorRecipes.INSTANCE.addRecipe(recipe);
this.addScripted(recipe);
}
}
110 changes: 40 additions & 70 deletions src/main/java/cn/academy/support/groovyscript/modules/MetalFormer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.academy.crafting.MetalFormerRecipes;
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
Expand All @@ -21,123 +22,92 @@
@RegistryDescription(linkGenerator = Main.MODID)
public class MetalFormer extends StandardListRegistry<MetalFormerRecipes.RecipeObject> {

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.etch", type = MethodDescription.Type.ADDITION)
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.etch", example = @Example("item('minecraft:stonebrick'), item('minecraft:stonebrick', 3)"), type = MethodDescription.Type.ADDITION)
public void addEtchRecipe(IIngredient input, ItemStack output){
for(ItemStack stack:input.getMatchingStacks()) {
this.addRecipe(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.ETCH));
this.add(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.ETCH));
}
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.incise", type = MethodDescription.Type.ADDITION)
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.incise", example = @Example("block('minecraft:cobblestone'), item('minecraft:stone_slab', 3)"), type = MethodDescription.Type.ADDITION)
public void addInciseRecipe(IIngredient input, ItemStack output){
for(ItemStack stack:input.getMatchingStacks()) {
this.addRecipe(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.INCISE));
this.add(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.INCISE));
}
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.plate", type = MethodDescription.Type.ADDITION)
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.plate", example = @Example("ore('ingotIron'), item('academy:reinforced_iron_plate')"), type = MethodDescription.Type.ADDITION)
public void addPlateRecipe(IIngredient input, ItemStack output){
for(ItemStack stack:input.getMatchingStacks()) {
this.addRecipe(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.PLATE));
this.add(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.PLATE));
}
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.refine", type = MethodDescription.Type.ADDITION)
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.add.refine", example = @Example("ore('oreDiamond'), item('minecraft:diamond') * 64"), type = MethodDescription.Type.ADDITION)
public void addRefineRecipe(IIngredient input, ItemStack output){
for(ItemStack stack:input.getMatchingStacks()) {
this.addRecipe(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.REFINE));
this.add(new MetalFormerRecipes.RecipeObject(stack, output, TileMetalFormer.Mode.REFINE));
}
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.etch", type = MethodDescription.Type.REMOVAL)
public void removeEtchbyInput(ItemStack input){
this.removeByInputandMode(input, TileMetalFormer.Mode.ETCH);
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.etch", example = @Example("ore('oreDiamond')"), type = MethodDescription.Type.REMOVAL)
public void removeEtchByInput(ItemStack input){
this.removeByInputAndMode(input, TileMetalFormer.Mode.ETCH);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.plate", type = MethodDescription.Type.REMOVAL)
public void removePlatebyInput(ItemStack input){
this.removeByInputandMode(input, TileMetalFormer.Mode.PLATE);
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.plate", example = @Example("ore('oreDiamond')"), type = MethodDescription.Type.REMOVAL)
public void removePlateByInput(ItemStack input){
this.removeByInputAndMode(input, TileMetalFormer.Mode.PLATE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.incise", type = MethodDescription.Type.REMOVAL)
public void removeIncisebyInput(ItemStack input){
this.removeByInputandMode(input, TileMetalFormer.Mode.INCISE);
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.incise", example = @Example("ore('oreDiamond')"), type = MethodDescription.Type.REMOVAL)
public void removeInciseByInput(ItemStack input){
this.removeByInputAndMode(input, TileMetalFormer.Mode.INCISE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.refine", type = MethodDescription.Type.REMOVAL)
public void removeRefinebyInput(ItemStack input){
this.removeByInputandMode(input, TileMetalFormer.Mode.REFINE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.clear.all", type = MethodDescription.Type.REMOVAL)
public void clearRecipe(){
Iterator<MetalFormerRecipes.RecipeObject> iterator = MetalFormerRecipes.INSTANCE.getAllRecipes().iterator();
while (iterator.hasNext()) {
MetalFormerRecipes.RecipeObject recipe = iterator.next();
iterator.remove();
this.addBackup(recipe);
}
@MethodDescription(description = "groovyscript.wiki.academy.metal_former.remove.refine", example = @Example("ore('oreDiamond')"), type = MethodDescription.Type.REMOVAL)
public void removeRefineByInput(ItemStack input){
this.removeByInputAndMode(input, TileMetalFormer.Mode.REFINE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.clear.etch", type = MethodDescription.Type.REMOVAL)
public void clearEtch(){
Iterator<MetalFormerRecipes.RecipeObject> iterator = MetalFormerRecipes.INSTANCE.getAllRecipes().iterator();
while (iterator.hasNext()) {
MetalFormerRecipes.RecipeObject recipe = iterator.next();
if(recipe.mode == TileMetalFormer.Mode.ETCH) {
iterator.remove();
this.addBackup(recipe);
}
}
removeByMode(TileMetalFormer.Mode.ETCH);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.clear.incise", type = MethodDescription.Type.REMOVAL)
public void clearIncise(){
Iterator<MetalFormerRecipes.RecipeObject> iterator = MetalFormerRecipes.INSTANCE.getAllRecipes().iterator();
while (iterator.hasNext()) {
MetalFormerRecipes.RecipeObject recipe = iterator.next();
if(recipe.mode == TileMetalFormer.Mode.INCISE) {
iterator.remove();
this.addBackup(recipe);
}
}
removeByMode(TileMetalFormer.Mode.INCISE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.clear.plate", type = MethodDescription.Type.REMOVAL)
public void clearPlate(){
Iterator<MetalFormerRecipes.RecipeObject> iterator = MetalFormerRecipes.INSTANCE.getAllRecipes().iterator();
while (iterator.hasNext()) {
MetalFormerRecipes.RecipeObject recipe = iterator.next();
if(recipe.mode == TileMetalFormer.Mode.PLATE) {
iterator.remove();
this.addBackup(recipe);
}
}
removeByMode(TileMetalFormer.Mode.PLATE);
}

@MethodDescription(description = "groovyscript.wiki.academy.metal_former.clear.refine", type = MethodDescription.Type.REMOVAL)
public void clearRefine(){
Iterator<MetalFormerRecipes.RecipeObject> iterator = MetalFormerRecipes.INSTANCE.getAllRecipes().iterator();
while (iterator.hasNext()) {
MetalFormerRecipes.RecipeObject recipe = iterator.next();
if(recipe.mode == TileMetalFormer.Mode.REFINE) {
iterator.remove();
this.addBackup(recipe);
removeByMode(TileMetalFormer.Mode.REFINE);
}

@GroovyBlacklist
public void removeByMode(TileMetalFormer.Mode mode){
for (MetalFormerRecipes.RecipeObject recipe : MetalFormerRecipes.INSTANCE.getAllRecipes()) {
if (recipe.mode == mode) {
this.remove(recipe);
}
}
}

public void removeByInputandMode(ItemStack input, TileMetalFormer.Mode mode) {
MetalFormerRecipes.RecipeObject recipe;
recipe = MetalFormerRecipes.INSTANCE.removebyInput(input, mode);

if (recipe != null) {
this.addBackup(recipe);
}
@Override
public boolean add(MetalFormerRecipes.RecipeObject recipe) {
recipe.setId(this.getRecipes().size());
return super.add(recipe);
}
public void addRecipe(MetalFormerRecipes.RecipeObject recipe){
MetalFormerRecipes.INSTANCE.add(recipe);
this.addScripted(recipe);

@GroovyBlacklist
public void removeByInputAndMode(ItemStack input, TileMetalFormer.Mode mode) {
this.remove(MetalFormerRecipes.INSTANCE.getRecipe(input, mode));
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/assets/academy/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ groovyscript.wiki.academy.imag_fusor.title=Imag Fusor
groovyscript.wiki.academy.imag_fusor.description=Converts one item and defined amount of Imag Phase Liquid into one item.
groovyscript.wiki.academy.imag_fusor.add=Adds recipes in the format `output`, `input`, `amount of Imag Phase Liquid`
groovyscript.wiki.academy.imag_fusor.remove=Removes an entry matching the given `ItemStack`
groovyscript.wiki.academy.imag_fusor.clear=Removes all entry of Imag Fusor

groovyscript.wiki.academy.metal_former.title=Metal Former
groovyscript.wiki.academy.metal_former.description=Converts an item into another item, according to the mode of the machine.
Expand All @@ -518,7 +517,6 @@ groovyscript.wiki.academy.metal_former.remove.etch=Removes an entry matching the
groovyscript.wiki.academy.metal_former.remove.incise=Removes an entry matching the given `ItemStack` from incise recipes
groovyscript.wiki.academy.metal_former.remove.plate=Removes an entry matching the given `ItemStack` from plate recipes
groovyscript.wiki.academy.metal_former.remove.refine=Removes an entry matching the given `ItemStack` from refine recipes
groovyscript.wiki.academy.metal_former.clear.all=Removes all entry of metal former
groovyscript.wiki.academy.metal_former.clear.etch=Removes all etching entry of metal former
groovyscript.wiki.academy.metal_former.clear.incise=Removes all etching entry of metal former
groovyscript.wiki.academy.metal_former.clear.plate=Removes all etching entry of metal former
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/assets/academy/lang/ko_kr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ groovyscript.wiki.academy.imag_fusor.title=상상 융합기
groovyscript.wiki.academy.imag_fusor.description=한 아이템과 정해진 양의 상상 위상 액체를 다른 아이템으로 변경합니다
groovyscript.wiki.academy.imag_fusor.add=`출력`, `입력`, `상상 위상 액체 소모량`의 형식으로 상상 융합기의 조합법을 추가합니다
groovyscript.wiki.academy.imag_fusor.remove=`아이템스택`과 입력이 일치하는 상상 융합기의 조합법을 삭제합니다.
groovyscript.wiki.academy.imag_fusor.clear=상상 융합기의 모든 조합법을 삭제합니다

groovyscript.wiki.academy.metal_former.title=금속 변형기
groovyscript.wiki.academy.metal_former.description=한 아이템을 동작 모드에 따라 다른 아이템으로 변형합니다.
Expand All @@ -517,7 +516,6 @@ groovyscript.wiki.academy.metal_former.remove.etch=`아이템스택`과 입력
groovyscript.wiki.academy.metal_former.remove.incise=`아이템스택`과 입력이 일치하는 금속 변형기의 절삭 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.remove.plate=`아이템스택`과 입력이 일치하는 금속 변형기의 압연 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.remove.refine=`아이템스택`과 입력이 일치하는 금속 변형기의 정제 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.clear.all=금속 변형기의 모든 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.clear.etch=금속 변형기의 모든 에칭 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.clear.incise=금속 변형기의 모든 절삭 조합법을 삭제합니다.
groovyscript.wiki.academy.metal_former.clear.plate=금속 변형기의 모든 압연 조합법을 삭제합니다.
Expand Down

0 comments on commit 47c2915

Please sign in to comment.