mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 09:33:42 +01:00
Heated Mixing JEI support
This commit is contained in:
parent
d4f0743522
commit
9fe29193de
3 changed files with 91 additions and 24 deletions
|
@ -10,6 +10,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
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.compat.jei.category.animations.AnimatedMixer;
|
||||||
import com.simibubi.create.content.contraptions.components.mixer.MixingRecipe;
|
import com.simibubi.create.content.contraptions.components.mixer.MixingRecipe;
|
||||||
import com.simibubi.create.content.contraptions.processing.ProcessingIngredient;
|
import com.simibubi.create.content.contraptions.processing.ProcessingIngredient;
|
||||||
|
@ -27,10 +28,11 @@ import net.minecraft.util.NonNullList;
|
||||||
public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
||||||
|
|
||||||
private AnimatedMixer mixer = new AnimatedMixer();
|
private AnimatedMixer mixer = new AnimatedMixer();
|
||||||
|
private AnimatedBlazeHeater heater = new AnimatedBlazeHeater();
|
||||||
|
|
||||||
public MixingCategory() {
|
public MixingCategory() {
|
||||||
super("mixing", doubleItemIcon(AllBlocks.MECHANICAL_MIXER.get(), AllBlocks.BASIN.get()),
|
super("mixing", doubleItemIcon(AllBlocks.MECHANICAL_MIXER.get(), AllBlocks.BASIN.get()),
|
||||||
emptyBackground(177, 70));
|
emptyBackground(177, 110));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,8 +56,9 @@ public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
||||||
Map<Integer, Float> catalystIndices = new HashMap<>(9);
|
Map<Integer, Float> catalystIndices = new HashMap<>(9);
|
||||||
for (int i = 0; i < actualIngredients.size(); i++) {
|
for (int i = 0; i < actualIngredients.size(); i++) {
|
||||||
for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) {
|
for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) {
|
||||||
if (processingIngredient.isCatalyst() && ItemHelper
|
if (processingIngredient.isCatalyst()
|
||||||
.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i).getKey())) {
|
&& ItemHelper.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i)
|
||||||
|
.getKey())) {
|
||||||
catalystIndices.put(i, processingIngredient.getOutputChance());
|
catalystIndices.put(i, processingIngredient.getOutputChance());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -65,20 +68,26 @@ public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
||||||
int size = actualIngredients.size();
|
int size = actualIngredients.size();
|
||||||
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int yOffset = recipe.getHeatLevelRequired() > 0 ? 30 : 10;
|
||||||
while (i < size) {
|
while (i < size) {
|
||||||
Pair<Ingredient, MutableInt> ingredient = actualIngredients.get(i);
|
Pair<Ingredient, MutableInt> ingredient = actualIngredients.get(i);
|
||||||
itemStacks.init(i, true, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19);
|
itemStacks.init(i, true, 16 + xOffset + (i % 3) * 19, 50 - (i / 3) * 19 + yOffset);
|
||||||
List<ItemStack> asList = Arrays.asList(ingredient.getKey().getMatchingStacks());
|
List<ItemStack> asList = Arrays.asList(ingredient.getKey()
|
||||||
itemStacks.set(i, asList.stream().map(stack -> {
|
.getMatchingStacks());
|
||||||
stack = stack.copy();
|
itemStacks.set(i, asList.stream()
|
||||||
stack.setCount(ingredient.getRight().getValue());
|
.map(stack -> {
|
||||||
return stack;
|
stack = stack.copy();
|
||||||
}).collect(Collectors.toList()));
|
stack.setCount(ingredient.getRight()
|
||||||
|
.getValue());
|
||||||
|
return stack;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemStacks.init(i, false, 141, 50);
|
itemStacks.init(i, false, 141, 50 + yOffset);
|
||||||
itemStacks.set(i, recipe.getRecipeOutput().getStack());
|
itemStacks.set(i, recipe.getRecipeOutput()
|
||||||
|
.getStack());
|
||||||
|
|
||||||
addCatalystTooltip(itemStacks, catalystIndices);
|
addCatalystTooltip(itemStacks, catalystIndices);
|
||||||
}
|
}
|
||||||
|
@ -89,21 +98,25 @@ public class MixingCategory extends CreateRecipeCategory<MixingRecipe> {
|
||||||
|
|
||||||
int size = actualIngredients.size();
|
int size = actualIngredients.size();
|
||||||
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
int xOffset = size < 3 ? (3 - size) * 19 / 2 : 0;
|
||||||
|
int yOffset = recipe.getHeatLevelRequired() > 0 ? 30 : 10;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT;
|
AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT;
|
||||||
for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) {
|
for (ProcessingIngredient processingIngredient : recipe.getRollableIngredients()) {
|
||||||
if (processingIngredient.isCatalyst() && ItemHelper
|
if (processingIngredient.isCatalyst()
|
||||||
.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i).getKey())) {
|
&& ItemHelper.matchIngredients(processingIngredient.getIngredient(), actualIngredients.get(i)
|
||||||
|
.getKey())) {
|
||||||
jeiSlot = AllGuiTextures.JEI_CATALYST_SLOT;
|
jeiSlot = AllGuiTextures.JEI_CATALYST_SLOT;
|
||||||
break;
|
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_SLOT.draw(141, 50 + yOffset);
|
||||||
AllGuiTextures.JEI_DOWN_ARROW.draw(136, 32);
|
AllGuiTextures.JEI_DOWN_ARROW.draw(136, 32 + yOffset);
|
||||||
AllGuiTextures.JEI_SHADOW.draw(81, 57);
|
AllGuiTextures.JEI_SHADOW.draw(81, 57 + yOffset);
|
||||||
mixer.draw(getBackground().getWidth() / 2 + 3, 25);
|
if (recipe.getHeatLevelRequired() > 0)
|
||||||
|
heater.drawWithHeatLevel(getBackground().getWidth() / 2 + 3, 55, recipe.getHeatLevelRequired());
|
||||||
|
mixer.draw(getBackground().getWidth() / 2 + 3, 34);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<Integer, AllBlockPartials> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tag": "forge:ingots/zinc"
|
"tag": "forge:ingots/zinc"
|
||||||
},
|
}
|
||||||
{
|
|
||||||
"item": "minecraft:blaze_powder"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"results": [
|
"results": [
|
||||||
{
|
{
|
||||||
|
@ -17,5 +14,5 @@
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"requiredHeat": 1
|
"requiredHeat": 3
|
||||||
}
|
}
|
Loading…
Reference in a new issue