mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-21 12:32:31 +00:00
Now support JEI "+" click!
This commit is contained in:
1 parent
9437fbf03f
commit
70139662d3
4 files changed
+88
-15
No files matched your search
@@ -1,26 +1,19 @@
|
||||
package pers.towdium.tudicraft.event;
|
||||
|
||||
|
||||
import mezz.jei.gui.Focus;
|
||||
import mezz.jei.gui.ItemListOverlay;
|
||||
import mezz.jei.input.InputHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import pers.towdium.tudicraft.Tudicraft;
|
||||
import pers.towdium.tudicraft.gui.calculator.ContainerCalculator;
|
||||
import pers.towdium.tudicraft.gui.calculator.GuiCalculator;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.ContainerRecipeEditor;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.GuiRecipeEditor;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.InventoryRecipeEditor;
|
||||
import pers.towdium.tudicraft.plugin.JEIPlugin;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,6 @@ public class GuiCalculator extends GuiTooltipScreen{
|
||||
int total = 1;
|
||||
EnumMode mode = EnumMode.INPUT;
|
||||
|
||||
|
||||
public enum EnumMode {INPUT, OUTPUT, CATALYST}
|
||||
|
||||
public GuiCalculator(ContainerCalculator containerCalculator){
|
||||
|
||||
@@ -2,8 +2,11 @@ package pers.towdium.tudicraft.plugin;
|
||||
|
||||
import mezz.jei.JeiRuntime;
|
||||
import mezz.jei.api.*;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.transfer.BasicRecipeTransferHandler;
|
||||
import pers.towdium.tudicraft.Tudicraft;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.swing.plaf.TableUI;
|
||||
|
||||
/**
|
||||
@@ -25,17 +28,17 @@ public class JEIPlugin implements IModPlugin{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
public void register(@Nonnull IModRegistry registry) {
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new NormalRecipeTransferHandler(VanillaRecipeCategoryUid.CRAFTING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(@Nonnull IRecipeRegistry recipeRegistry) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
public void onRuntimeAvailable(@Nonnull IJeiRuntime jeiRuntime) {
|
||||
Tudicraft.log.info("载入了!");
|
||||
runtime = jeiRuntime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package pers.towdium.tudicraft.plugin;
|
||||
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||
import mezz.jei.gui.ingredients.IGuiIngredient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import pers.towdium.tudicraft.core.ItemStackWrapper;
|
||||
import pers.towdium.tudicraft.gui.recipeEditor.ContainerRecipeEditor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Towdium
|
||||
*/
|
||||
public class NormalRecipeTransferHandler implements IRecipeTransferHandler {
|
||||
String recipeUID;
|
||||
|
||||
public NormalRecipeTransferHandler(String recipeUID ) {
|
||||
this.recipeUID = recipeUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Container> getContainerClass() {
|
||||
return ContainerRecipeEditor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return recipeUID;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IRecipeTransferError transferRecipe(@Nonnull Container container, @Nonnull IRecipeLayout iRecipeLayout, @Nonnull EntityPlayer entityPlayer, boolean maxTransfer, boolean doTransfer) {
|
||||
if(doTransfer){
|
||||
List<ItemStack> outputStacks = new ArrayList<>();
|
||||
List<ItemStack> inputStacks = new ArrayList<>();
|
||||
LOOP:
|
||||
for(IGuiIngredient<ItemStack> ingredient : iRecipeLayout.getItemStacks().getGuiIngredients().values()){
|
||||
if(ingredient.getAllIngredients().size()==0){
|
||||
continue;
|
||||
}
|
||||
if(ingredient.isInput()){
|
||||
ItemStack itemStack = ingredient.getAllIngredients().get(0);
|
||||
for (ItemStack exist : inputStacks){
|
||||
if(ItemStackWrapper.isTypeEqual(exist, itemStack)){
|
||||
exist.stackSize += itemStack.stackSize;
|
||||
continue LOOP;
|
||||
}
|
||||
}
|
||||
inputStacks.add(itemStack.copy());
|
||||
}else {
|
||||
ItemStack itemStack = ingredient.getAllIngredients().get(0);
|
||||
for (ItemStack exist : outputStacks){
|
||||
if(ItemStackWrapper.isTypeEqual(exist, itemStack)){
|
||||
exist.stackSize += itemStack.stackSize;
|
||||
continue LOOP;
|
||||
}
|
||||
}
|
||||
outputStacks.add(itemStack.copy());
|
||||
}
|
||||
}
|
||||
for(int i=0; i<=outputStacks.size()-1 && i<=3; i++){
|
||||
container.getSlot(i).putStack(outputStacks.get(i));
|
||||
}
|
||||
for(int i=4; i<=4+inputStacks.size()-1 && i<=15; i++){
|
||||
container.getSlot(i).putStack(inputStacks.get(i-4));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user