diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-01-25 21:29:01 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-01-25 21:29:01 +0800 |
| commit | e8353e0d95d00266e9b188a816b73ce7a4dc090b (patch) | |
| tree | ba8d37e326186fea7b8d479bee9ad40dd75c34fe /src/main/java/me/shedaniel | |
| parent | 179890a17ef52f0bcf3cd75c77f047c4a03e49ec (diff) | |
| download | RoughlyEnoughItems-2.1.0.45.tar.gz RoughlyEnoughItems-2.1.0.45.tar.bz2 RoughlyEnoughItems-2.1.0.45.zip | |
Stonecutter Recipesv2.1.0.45
Diffstat (limited to 'src/main/java/me/shedaniel')
4 files changed, 135 insertions, 14 deletions
diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultCampfireCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultCampfireCategory.java index 9041b12ae..c559c6bb3 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultCampfireCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultCampfireCategory.java @@ -55,7 +55,7 @@ public class DefaultCampfireCategory implements IRecipeCategory<DefaultCampfireD drawTexturedRect(startPoint.x + 24, startPoint.y + 19, 82, 92, width, 17); String text = I18n.translate("category.rei.campfire.time", MathHelper.floor(recipeDisplay.getCookTime() / 20d)); int length = MinecraftClient.getInstance().fontRenderer.getStringWidth(text); - MinecraftClient.getInstance().fontRenderer.drawWithShadow(text, bounds.x + bounds.width - length - 4, startPoint.y + 54 - 8, -1); + MinecraftClient.getInstance().fontRenderer.draw(text, bounds.x + bounds.width - length - 5, startPoint.y + 54 - 8, -1); } })); widgets.add(new ItemSlotWidget(startPoint.x + 1, startPoint.y + 11, recipeDisplay.getInput().get(0), true, true, containerGui, true)); diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index 3cabab0ec..1ac5a609b 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.container.FurnaceGui; import net.minecraft.client.gui.container.SmokerGui; import net.minecraft.client.gui.ingame.PlayerInventoryGui; import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.StonecuttingRecipe; import net.minecraft.recipe.cooking.BlastingRecipe; import net.minecraft.recipe.cooking.CampfireCookingRecipe; import net.minecraft.recipe.cooking.SmeltingRecipe; @@ -30,6 +31,7 @@ public class DefaultPlugin implements IRecipePlugin { public static final Identifier SMOKING = new Identifier("roughlyenoughitems", "plugins/smoking"); public static final Identifier BLASTING = new Identifier("roughlyenoughitems", "plugins/blasting"); public static final Identifier CAMPFIRE = new Identifier("roughlyenoughitems", "plugins/campfire"); + public static final Identifier STONE_CUTTING = new Identifier("roughlyenoughitems", "plugins/stone_cutting"); public static final Identifier BREWING = new Identifier("roughlyenoughitems", "plugins/brewing"); private static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList(); @@ -45,30 +47,34 @@ public class DefaultPlugin implements IRecipePlugin { RecipeHelper.registerCategory(new DefaultSmokingCategory()); RecipeHelper.registerCategory(new DefaultBlastingCategory()); RecipeHelper.registerCategory(new DefaultCampfireCategory()); + RecipeHelper.registerCategory(new DefaultStoneCuttingCategory()); RecipeHelper.registerCategory(new DefaultBrewingCategory()); } @Override public void registerRecipes() { - for(Recipe value : RecipeHelper.getRecipeManager().values()) - if (value instanceof ShapelessRecipe) - RecipeHelper.registerRecipe(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) value)); - else if (value instanceof ShapedRecipe) - RecipeHelper.registerRecipe(CRAFTING, new DefaultShapedDisplay((ShapedRecipe) value)); - else if (value instanceof SmeltingRecipe) - RecipeHelper.registerRecipe(SMELTING, new DefaultSmeltingDisplay((SmeltingRecipe) value)); - else if (value instanceof SmokingRecipe) - RecipeHelper.registerRecipe(SMOKING, new DefaultSmokingDisplay((SmokingRecipe) value)); - else if (value instanceof BlastingRecipe) - RecipeHelper.registerRecipe(BLASTING, new DefaultBlastingDisplay((BlastingRecipe) value)); - else if (value instanceof CampfireCookingRecipe) - RecipeHelper.registerRecipe(CAMPFIRE, new DefaultCampfireDisplay((CampfireCookingRecipe) value)); + for(Recipe recipe : RecipeHelper.getRecipeManager().values()) + if (recipe instanceof ShapelessRecipe) + RecipeHelper.registerRecipe(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) recipe)); + else if (recipe instanceof ShapedRecipe) + RecipeHelper.registerRecipe(CRAFTING, new DefaultShapedDisplay((ShapedRecipe) recipe)); + else if (recipe instanceof SmeltingRecipe) + RecipeHelper.registerRecipe(SMELTING, new DefaultSmeltingDisplay((SmeltingRecipe) recipe)); + else if (recipe instanceof SmokingRecipe) + RecipeHelper.registerRecipe(SMOKING, new DefaultSmokingDisplay((SmokingRecipe) recipe)); + else if (recipe instanceof BlastingRecipe) + RecipeHelper.registerRecipe(BLASTING, new DefaultBlastingDisplay((BlastingRecipe) recipe)); + else if (recipe instanceof CampfireCookingRecipe) + RecipeHelper.registerRecipe(CAMPFIRE, new DefaultCampfireDisplay((CampfireCookingRecipe) recipe)); + else if (recipe instanceof StonecuttingRecipe) + RecipeHelper.registerRecipe(STONE_CUTTING, new DefaultStoneCuttingDisplay((StonecuttingRecipe) recipe)); BREWING_DISPLAYS.forEach(display -> RecipeHelper.registerRecipe(BREWING, display)); } @Override public void registerSpeedCraft() { RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.CAMPFIRE, null); + RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.STONE_CUTTING, null); RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.BREWING, null); RecipeHelper.registerSpeedCraftFunctional(DefaultPlugin.CRAFTING, new SpeedCraftFunctional<DefaultCraftingDisplay>() { @Override diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingCategory.java new file mode 100644 index 000000000..d6584abf3 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingCategory.java @@ -0,0 +1,59 @@ +package me.shedaniel.rei.plugin; + +import com.mojang.blaze3d.platform.GlStateManager; +import me.shedaniel.rei.api.IRecipeCategory; +import me.shedaniel.rei.gui.widget.IWidget; +import me.shedaniel.rei.gui.widget.ItemSlotWidget; +import me.shedaniel.rei.gui.widget.RecipeBaseWidget; +import me.shedaniel.rei.listeners.IMixinContainerGui; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.GuiLighting; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.MathHelper; + +import java.awt.*; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class DefaultStoneCuttingCategory implements IRecipeCategory<DefaultStoneCuttingDisplay> { + + private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png"); + + @Override + public Identifier getIdentifier() { + return DefaultPlugin.STONE_CUTTING; + } + + @Override + public ItemStack getCategoryIcon() { + return new ItemStack(Blocks.STONECUTTER); + } + + @Override + public String getCategoryName() { + return I18n.translate("category.rei.stone_cutting"); + } + + @Override + public List<IWidget> setupDisplay(IMixinContainerGui containerGui, DefaultStoneCuttingDisplay recipeDisplay, Rectangle bounds) { + Point startPoint = new Point((int) bounds.getCenterX() - 41, (int) bounds.getCenterY() - 13); + List<IWidget> widgets = new LinkedList<>(Arrays.asList(new RecipeBaseWidget(bounds) { + @Override + public void draw(int mouseX, int mouseY, float partialTicks) { + super.draw(mouseX, mouseY, partialTicks); + GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiLighting.disable(); + MinecraftClient.getInstance().getTextureManager().bindTexture(DISPLAY_TEXTURE); + drawTexturedRect(startPoint.x, startPoint.y, 0, 221, 82, 26); + } + })); + widgets.add(new ItemSlotWidget(startPoint.x + 4, startPoint.y + 5, recipeDisplay.getInput().get(0), true, true, containerGui, true)); + widgets.add(new ItemSlotWidget(startPoint.x + 61, startPoint.y + 5, recipeDisplay.getOutput(), false, true, containerGui, true)); + return widgets; + } + +} diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingDisplay.java new file mode 100644 index 000000000..c4a149150 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultStoneCuttingDisplay.java @@ -0,0 +1,56 @@ +package me.shedaniel.rei.plugin; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.IRecipeDisplay; +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.StonecuttingRecipe; +import net.minecraft.recipe.cooking.CampfireCookingRecipe; +import net.minecraft.util.DefaultedList; +import net.minecraft.util.Identifier; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class DefaultStoneCuttingDisplay implements IRecipeDisplay { + + private List<ItemStack> inputs, output; + + public DefaultStoneCuttingDisplay(StonecuttingRecipe recipe) { + this(recipe.getPreviewInputs(), recipe.getOutput()); + } + + public DefaultStoneCuttingDisplay(DefaultedList<Ingredient> ingredients, ItemStack output) { + this.inputs = Lists.newArrayList(); + ingredients.stream().map(ingredient -> ingredient.getStackArray()).forEach(itemStacks -> Collections.addAll(inputs, itemStacks)); + this.output = Arrays.asList(output); + } + + @Override + public Recipe getRecipe() { + return null; + } + + @Override + public List<List<ItemStack>> getInput() { + return Arrays.asList(inputs); + } + + @Override + public List<ItemStack> getOutput() { + return this.output; + } + + @Override + public Identifier getRecipeCategory() { + return DefaultPlugin.STONE_CUTTING; + } + + @Override + public List<List<ItemStack>> getRequiredItems() { + return getInput(); + } + +} |
