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.
- Loading branch information
Showing
6 changed files
with
149 additions
and
26 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
98 changes: 98 additions & 0 deletions
98
...java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/ExplosionRecipeCategory.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,98 @@ | ||
package com.cleanroommc.groovyscript.compat.inworldcrafting.jei; | ||
|
||
import com.cleanroommc.groovyscript.GroovyScript; | ||
import com.cleanroommc.groovyscript.compat.inworldcrafting.Explosion; | ||
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.Blocks; | ||
import net.minecraft.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class ExplosionRecipeCategory extends BaseCategory<ExplosionRecipeCategory.RecipeWrapper> { | ||
|
||
public static final String UID = GroovyScript.ID + ":explosion"; | ||
|
||
private final IDrawable icon; | ||
|
||
public ExplosionRecipeCategory(IGuiHelper guiHelper) { | ||
super(guiHelper, UID, 176, 56); | ||
this.icon = guiHelper.createDrawableIngredient(new ItemStack(Blocks.TNT)); | ||
} | ||
|
||
@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.explosion"), 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 Explosion.Recipe recipe; | ||
|
||
public RecipeWrapper(Explosion.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) { | ||
float chance = this.recipe.getChance(); | ||
if (chance < 1) { | ||
String chanceS = FluidRecipeCategory.numberFormat.format(chance); | ||
int w = minecraft.fontRenderer.getStringWidth(chanceS); | ||
int x = 88 - w / 2, y = 44; | ||
minecraft.fontRenderer.drawString(chanceS, x, y, 0x404040); | ||
} | ||
} | ||
|
||
@Override | ||
public @NotNull List<String> getTooltipStrings(int mouseX, int mouseY) { | ||
if (this.recipe.getChance() < 1 && mouseX >= 74 && mouseX <= 72 + 28 && mouseY >= 25 && mouseY <= 54) { | ||
return Collections.singletonList(I18n.format("groovyscript.recipe.chance_produce", FluidRecipeCategory.numberFormat.format(this.recipe.getChance()))); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
} | ||
} |
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