diff --git a/build.gradle b/build.gradle index a58ca00db..57b866acb 100644 --- a/build.gradle +++ b/build.gradle @@ -74,6 +74,9 @@ repositories { maven { url = 'https://mvnrepository.com/artifact/org.apache.groovy/groovy' } + maven { + url 'https://dvs1.progwml6.com/files/maven/' + } maven { url 'http://maven.tterrag.com/' allowInsecureProtocol = true diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java index 8e7e6bb94..1cbb2dff4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.BurningRecipeCategory; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; @@ -11,12 +12,14 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Optional; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class Burning extends VirtualizedRegistry { @@ -24,6 +27,12 @@ public class Burning extends VirtualizedRegistry { private final List recipes = new ArrayList<>(); + @Optional.Method(modid = "jei") + @GroovyBlacklist + public List getRecipeWrappers() { + return this.recipes.stream().map(BurningRecipeCategory.RecipeWrapper::new).collect(Collectors.toList()); + } + @Override public void onReload() { this.recipes.addAll(getBackupRecipes()); @@ -67,13 +76,21 @@ public Recipe(IIngredient input, ItemStack output, int ticks, Closure b this.beforeRecipe = beforeRecipe; } - public boolean isValidInput(EntityItem entityItem, ItemStack itemStack) { - return this.input.test(itemStack) && (this.beforeRecipe == null || ClosureHelper.call(true, this.beforeRecipe, entityItem)); + public IIngredient getInput() { + return input; + } + + public ItemStack getOutput() { + return output; } public int getTicks() { return ticks; } + + public boolean isValidInput(EntityItem entityItem, ItemStack itemStack) { + return this.input.test(itemStack) && (this.beforeRecipe == null || ClosureHelper.call(true, this.beforeRecipe, entityItem)); + } } public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java new file mode 100644 index 000000000..8ac56d474 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java @@ -0,0 +1,87 @@ +package com.cleanroommc.groovyscript.compat.inworldcrafting.jei; + +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.compat.inworldcrafting.Burning; +import com.cleanroommc.groovyscript.compat.mods.jei.BaseCategory; +import mezz.jei.api.IGuiHelper; +import mezz.jei.api.gui.IDrawable; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.ingredients.VanillaTypes; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.Collections; + +public class BurningRecipeCategory extends BaseCategory { + + public static final String UID = GroovyScript.ID + ":burning"; + + private final IDrawable icon; + + public BurningRecipeCategory(IGuiHelper guiHelper) { + super(guiHelper, UID, 176, 56); + this.icon = guiHelper.createDrawableIngredient(new ItemStack(Items.BLAZE_POWDER)); + } + + @Override + public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, @NotNull IIngredients ingredients) { + addItemSlot(recipeLayout, 0, true, 53, 25); + addItemSlot(recipeLayout, 1, false, 105, 25); + + recipeLayout.getItemStacks().set(ingredients); + setBackgrounds(recipeLayout.getItemStacks(), slot); + } + + @Override + public void drawExtras(@NotNull Minecraft minecraft) { + minecraft.fontRenderer.drawSplitString(I18n.format("groovyscript.recipe.burning"), 4, 4, 168, 0x404040); + GlStateManager.color(1f, 1f, 1f, 1f); + rightArrow.draw(minecraft, 76, 26); + float tntScale = 0.5f; + GlStateManager.pushMatrix(); + GlStateManager.translate(80, 26, 0); + GlStateManager.translate(8, 8, 0); + GlStateManager.scale(tntScale, tntScale, 1); + GlStateManager.translate(-8, -8, 0); + this.icon.draw(minecraft); + GlStateManager.popMatrix(); + } + + @Nullable + @Override + public IDrawable getIcon() { + return icon; + } + + public static class RecipeWrapper implements IRecipeWrapper { + + private final Burning.Recipe recipe; + + public RecipeWrapper(Burning.Recipe recipe) { + this.recipe = recipe; + } + + @Override + public void getIngredients(IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.recipe.getInput().getMatchingStacks()))); + ingredients.setOutput(VanillaTypes.ITEM, this.recipe.getOutput()); + } + + @Override + public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { + int ticks = this.recipe.getTicks(); + String ticksS = ticks + " ticks"; + int w = minecraft.fontRenderer.getStringWidth(ticksS); + int x = 88 - w / 2, y = 44; + minecraft.fontRenderer.drawString(ticksS, x, y, 0x404040); + } + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java index 2f45a3dad..7226137d6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java @@ -5,6 +5,7 @@ import com.cleanroommc.groovyscript.command.GSCommand; import com.cleanroommc.groovyscript.command.SimpleCommand; import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidRecipe; +import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.BurningRecipeCategory; import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.ExplosionRecipeCategory; import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.FluidRecipeCategory; import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; @@ -67,6 +68,7 @@ public void registerCategories(IRecipeCategoryRegistration registry) { IGuiHelper guiHelper = registry.getJeiHelpers().getGuiHelper(); registry.addRecipeCategories(new FluidRecipeCategory(guiHelper)); registry.addRecipeCategories(new ExplosionRecipeCategory(guiHelper)); + registry.addRecipeCategories(new BurningRecipeCategory(guiHelper)); } @Override @@ -87,6 +89,7 @@ public void register(IModRegistry registry) { }); registry.addRecipes(recipeWrappers, FluidRecipeCategory.UID); registry.addRecipes(VanillaModule.inWorldCrafting.explosion.getRecipeWrappers(), ExplosionRecipeCategory.UID); + registry.addRecipes(VanillaModule.inWorldCrafting.burning.getRecipeWrappers(), BurningRecipeCategory.UID); } @Override diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 90a6eea76..6553b3911 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -7,8 +7,10 @@ key.groovyscript.reload=Reload Scripts groovyscript.jei.category.groovyscript:fluid_recipe.name=In world fluid recipes groovyscript.jei.category.groovyscript:explosion.name=Explosion recipes +groovyscript.jei.category.groovyscript:burning.name=Burning recipes groovyscript.recipe.fluid_recipe=Drop items into fluid to transform fluid groovyscript.recipe.explosion=Explode item with an explosion to transform item +groovyscript.recipe.burning=Burn item with fire to transform item groovyscript.recipe.chance_produce=§2%s§7 chance to produce output groovyscript.recipe.chance_consume=§2%s§7 chance to get consumed