-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger crafting jobs from JEI by Ctrl-clicking recipes
- Loading branch information
1 parent
554563f
commit d4680d7
Showing
5 changed files
with
147 additions
and
13 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
78 changes: 78 additions & 0 deletions
78
.../java/org/cyclops/integratedterminalscompat/modcompat/jei/RecipeTransferErrorColored.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,78 @@ | ||
package org.cyclops.integratedterminalscompat.modcompat.jei; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotView; | ||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView; | ||
import mezz.jei.api.recipe.transfer.IRecipeTransferError; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.network.chat.Component; | ||
import org.cyclops.cyclopscore.helper.Helpers; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* A transfer error object that changes appearance based on presence of storage and craftable items. | ||
* @author rubensworks | ||
*/ | ||
public class RecipeTransferErrorColored implements IRecipeTransferError { | ||
|
||
public static final int SLOT_COLOR_MISSING = Helpers.RGBAToInt(255, 0, 0, 100); | ||
public static final int SLOT_COLOR_CRAFTABLE = Helpers.RGBAToInt(0, 0, 255, 100); | ||
|
||
public static final int HIGHLIGHT_COLOR_FAIL = Helpers.RGBAToInt(255, 0, 0, 100); | ||
public static final int HIGHLIGHT_COLOR_CRAFTABLE = Helpers.RGBAToInt(0, 0, 255, 100); | ||
public static final int HIGHLIGHT_COLOR_CRAFTABLE_PARTIAL = Helpers.RGBAToInt(255, 125, 0, 100); | ||
|
||
private final List<Component> message = new ArrayList<>(); | ||
private final Collection<IRecipeSlotView> slotsMissing; | ||
private final Collection<IRecipeSlotView> slotsCraftable; | ||
private final int color; | ||
|
||
public RecipeTransferErrorColored(Collection<IRecipeSlotView> slotsMissing, Collection<IRecipeSlotView> slotsCraftable) { | ||
this.message.add(Component.translatable("jei.tooltip.transfer")); | ||
this.slotsMissing = slotsMissing; | ||
this.slotsCraftable = slotsCraftable; | ||
if (slotsMissing.isEmpty()) { | ||
// Missing items, but they are all craftable | ||
this.message.add(Component.translatable("gui.integratedterminalscompat.terminal_storage.jei.transfer.craftable").withStyle(ChatFormatting.RED)); | ||
this.message.add(Component.translatable("gui.integratedterminalscompat.terminal_storage.jei.transfer.craft.info").withStyle(ChatFormatting.ITALIC)); | ||
this.color = HIGHLIGHT_COLOR_CRAFTABLE; | ||
} else if (!slotsCraftable.isEmpty()) { | ||
// Missing items, but only some of them are craftable | ||
this.message.add(Component.translatable("gui.integratedterminalscompat.terminal_storage.jei.transfer.craftable_partial").withStyle(ChatFormatting.RED)); | ||
this.message.add(Component.translatable("gui.integratedterminalscompat.terminal_storage.jei.transfer.craft.info").withStyle(ChatFormatting.ITALIC)); | ||
this.color = HIGHLIGHT_COLOR_CRAFTABLE_PARTIAL; | ||
} else { | ||
// Missing items, and none are craftable | ||
this.message.add(Component.translatable("gui.integratedterminalscompat.terminal_storage.jei.transfer.missing").withStyle(ChatFormatting.ITALIC)); | ||
this.color = HIGHLIGHT_COLOR_FAIL; | ||
} | ||
} | ||
|
||
@Override | ||
public Type getType() { | ||
return this.slotsCraftable.isEmpty() ? Type.USER_FACING : Type.COSMETIC; | ||
} | ||
|
||
@Override | ||
public int getButtonHighlightColor() { | ||
return this.color; | ||
} | ||
|
||
@Override | ||
public void showError(PoseStack poseStack, int mouseX, int mouseY, IRecipeSlotsView recipeSlotsView, int recipeX, int recipeY) { | ||
Minecraft.getInstance().screen.renderComponentTooltip(poseStack, this.message, mouseX, mouseY); | ||
poseStack.pushPose(); | ||
poseStack.translate(recipeX, recipeY, 0.0); | ||
for (IRecipeSlotView slot : this.slotsMissing) { | ||
slot.drawHighlight(poseStack, SLOT_COLOR_MISSING); | ||
} | ||
for (IRecipeSlotView slot : this.slotsCraftable) { | ||
slot.drawHighlight(poseStack, SLOT_COLOR_CRAFTABLE); | ||
} | ||
poseStack.popPose(); | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
src/main/resources/assets/integratedterminalscompat/lang/en_us.json
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"_comment": "Gui", | ||
"gui.integratedterminalscompat.terminal_storage.craftinggrid.jeisync": "JEI Search Sync", | ||
"gui.integratedterminalscompat.terminal_storage.craftinggrid.jeisync.info": "Synchronize search box with JEI." | ||
"gui.integratedterminalscompat.terminal_storage.craftinggrid.jeisync.info": "Synchronize search box with JEI.", | ||
"gui.integratedterminalscompat.terminal_storage.jei.transfer.craftable": "Auto-craftable items", | ||
"gui.integratedterminalscompat.terminal_storage.jei.transfer.craftable_partial": "Partially auto-craftable items", | ||
"gui.integratedterminalscompat.terminal_storage.jei.transfer.missing": "Missing items", | ||
"gui.integratedterminalscompat.terminal_storage.jei.transfer.craft.info": "Ctrl+click to trigger auto-crafting" | ||
} |