From 9fe29193deb132a2608d48b78bf8b1b1c248cad0 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Tue, 14 Jul 2020 19:50:23 +0200 Subject: [PATCH] Heated Mixing JEI support --- .../compat/jei/category/MixingCategory.java | 51 ++++++++++------- .../animations/AnimatedBlazeHeater.java | 57 +++++++++++++++++++ .../create/recipes/mixing/brass_ingot.json | 7 +-- 3 files changed, 91 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeHeater.java diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MixingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MixingCategory.java index 68f30c47c..fd2ada44b 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MixingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MixingCategory.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.AllBlocks; +import com.simibubi.create.compat.jei.category.animations.AnimatedBlazeHeater; import com.simibubi.create.compat.jei.category.animations.AnimatedMixer; import com.simibubi.create.content.contraptions.components.mixer.MixingRecipe; import com.simibubi.create.content.contraptions.processing.ProcessingIngredient; @@ -27,10 +28,11 @@ import net.minecraft.util.NonNullList; public class MixingCategory extends CreateRecipeCategory { private AnimatedMixer mixer = new AnimatedMixer(); + private AnimatedBlazeHeater heater = new AnimatedBlazeHeater(); public MixingCategory() { super("mixing", doubleItemIcon(AllBlocks.MECHANICAL_MIXER.get(), AllBlocks.BASIN.get()), - emptyBackground(177, 70)); + emptyBackground(177, 110)); } @Override @@ -54,8 +56,9 @@ public class MixingCategory extends CreateRecipeCategory { Map catalystIndices = new HashMap<>(9); for (int i = 0; i < actualIngredients.size(); i++) { for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) { - if (processingIngredient.isCatalyst() && ItemHelper - .matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i).getKey())) { + if (processingIngredient.isCatalyst() + && ItemHelper.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i) + .getKey())) { catalystIndices.put(i, processingIngredient.getOutputChance()); break; } @@ -65,20 +68,26 @@ public class MixingCategory extends CreateRecipeCategory { int size = actualIngredients.size(); int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0; int i = 0; + int yOffset = recipe.getHeatLevelRequired() > 0 ? 30 : 10; while (i < size) { Pair ingredient = actualIngredients.get(i); - itemStacks.init(i, true, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19); - List asList = Arrays.asList(ingredient.getKey().getMatchingStacks()); - itemStacks.set(i, asList.stream().map(stack -> { - stack = stack.copy(); - stack.setCount(ingredient.getRight().getValue()); - return stack; - }).collect(Collectors.toList())); + itemStacks.init(i, true, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset); + List asList = Arrays.asList(ingredient.getKey() + .getMatchingStacks()); + itemStacks.set(i, asList.stream() + .map(stack -> { + stack = stack.copy(); + stack.setCount(ingredient.getRight() + .getValue()); + return stack; + }) + .collect(Collectors.toList())); i++; } - itemStacks.init(i, false, 141, 50); - itemStacks.set(i, recipe.getRecipeOutput().getStack()); + itemStacks.init(i, false, 141, 50 + yOffset); + itemStacks.set(i, recipe.getRecipeOutput() + .getStack()); addCatalystTooltip(itemStacks, catalystIndices); } @@ -89,21 +98,25 @@ public class MixingCategory extends CreateRecipeCategory { int size = actualIngredients.size(); int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0; + int yOffset = recipe.getHeatLevelRequired() > 0 ? 30 : 10; for (int i = 0; i < size; i++) { AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT; for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) { - if (processingIngredient.isCatalyst() && ItemHelper - .matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i).getKey())) { + if (processingIngredient.isCatalyst() + && ItemHelper.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i) + .getKey())) { jeiSlot = AllGuiTextures.JEI_CATALYST_SLOT; break; } } - jeiSlot.draw(16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19); + jeiSlot.draw(16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset); } - AllGuiTextures.JEI_SLOT.draw(141, 50); - AllGuiTextures.JEI_DOWN_ARROW.draw(136, 32); - AllGuiTextures.JEI_SHADOW.draw(81, 57); - mixer.draw(getBackground().getWidth() / 2 + 3, 25); + AllGuiTextures.JEI_SLOT.draw(141, 50 + yOffset); + AllGuiTextures.JEI_DOWN_ARROW.draw(136, 32 + yOffset); + AllGuiTextures.JEI_SHADOW.draw(81, 57 + yOffset); + if (recipe.getHeatLevelRequired() > 0) + heater.drawWithHeatLevel(getBackground().getWidth() / 2 + 3, 55, recipe.getHeatLevelRequired()); + mixer.draw(getBackground().getWidth() / 2 + 3, 34); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeHeater.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeHeater.java new file mode 100644 index 000000000..84483c08a --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeHeater.java @@ -0,0 +1,57 @@ +package com.simibubi.create.compat.jei.category.animations; + +import java.util.HashMap; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.gui.GuiGameElement; + +import mezz.jei.api.gui.drawable.IDrawable; + +public class AnimatedBlazeHeater implements IDrawable { + private static final HashMap blazeModelMap = new HashMap<>(); + + public AnimatedBlazeHeater() { + super(); + blazeModelMap.put(2, AllBlockPartials.BLAZE_HEATER_BLAZE_TWO); + blazeModelMap.put(3, AllBlockPartials.BLAZE_HEATER_BLAZE_THREE); + blazeModelMap.put(4, AllBlockPartials.BLAZE_HEATER_BLAZE_FOUR); + } + + @Override + public void draw(int xOffset, int yOffset) { + drawWithHeatLevel(xOffset, yOffset, 3); + } + + public void drawWithHeatLevel(int xOffset, int yOffset, int heatLevel) { + RenderSystem.pushMatrix(); + RenderSystem.translatef(xOffset, yOffset, 200); + RenderSystem.rotatef(-15.5f, 1, 0, 0); + RenderSystem.rotatef(22.5f, 0, 1, 0); + int scale = 23; + + GuiGameElement.of(AllBlocks.HEATER.getDefaultState()) + .atLocal(0, 1.65, 0) + .scale(scale) + .render(); + + GuiGameElement.of(blazeModelMap.getOrDefault(heatLevel, AllBlockPartials.BLAZE_HEATER_BLAZE_ONE)) + .atLocal(1, 1.65, 1) + .rotate(0, 180, 0) + .scale(scale) + .render(); + + RenderSystem.popMatrix(); + } + + @Override + public int getWidth() { + return 50; + } + + @Override + public int getHeight() { + return 50; + } +} diff --git a/src/main/resources/data/create/recipes/mixing/brass_ingot.json b/src/main/resources/data/create/recipes/mixing/brass_ingot.json index 6b06a9e03..3a2e2f3d1 100644 --- a/src/main/resources/data/create/recipes/mixing/brass_ingot.json +++ b/src/main/resources/data/create/recipes/mixing/brass_ingot.json @@ -6,10 +6,7 @@ }, { "tag": "forge:ingots/zinc" - }, - { - "item": "minecraft:blaze_powder" - } + } ], "results": [ { @@ -17,5 +14,5 @@ "count": 2 } ], - "requiredHeat": 1 + "requiredHeat": 3 } \ No newline at end of file