Merge pull request #10 from xinyihl/pattern-encode-priorities
样板编码优先使用JEI书签物品、流体
This commit is contained in:
commit
76d7a7eee7
|
|
@ -16,7 +16,7 @@ glodium_version=5006780
|
||||||
ae2_version=15.4.2
|
ae2_version=15.4.2
|
||||||
guideme_version=20.1.7
|
guideme_version=20.1.7
|
||||||
wireless_terminals_version=5162352
|
wireless_terminals_version=5162352
|
||||||
jei_version=15.0.0.12
|
jei_version=15.19.5.99
|
||||||
applied_flux_version=5329825
|
applied_flux_version=5329825
|
||||||
mega_cells_version=5320730
|
mega_cells_version=5320730
|
||||||
jade_version=4768593
|
jade_version=4768593
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
package com.extendedae_plus.integration.jei;
|
package com.extendedae_plus.integration.jei;
|
||||||
|
|
||||||
|
import com.extendedae_plus.mixin.jei.accessor.BookmarkOverlayAccessor;
|
||||||
import mezz.jei.api.constants.VanillaTypes;
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
import mezz.jei.api.ingredients.ITypedIngredient;
|
import mezz.jei.api.ingredients.ITypedIngredient;
|
||||||
import mezz.jei.api.runtime.IBookmarkOverlay;
|
import mezz.jei.api.runtime.IBookmarkOverlay;
|
||||||
import mezz.jei.api.runtime.IIngredientListOverlay;
|
import mezz.jei.api.runtime.IIngredientListOverlay;
|
||||||
import mezz.jei.api.runtime.IJeiRuntime;
|
import mezz.jei.api.runtime.IJeiRuntime;
|
||||||
|
import mezz.jei.gui.bookmarks.BookmarkList;
|
||||||
|
import mezz.jei.gui.overlay.elements.IElement;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -113,4 +118,18 @@ public final class JeiRuntimeProxy {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取JEI书签列表
|
||||||
|
*/
|
||||||
|
public static List<? extends ITypedIngredient<?>> getBookmarkList() {
|
||||||
|
IJeiRuntime rt = RUNTIME;
|
||||||
|
if (rt == null) return Collections.emptyList();
|
||||||
|
IBookmarkOverlay bookmarkOverlay = rt.getBookmarkOverlay();
|
||||||
|
if (bookmarkOverlay instanceof BookmarkOverlayAccessor accessor) {
|
||||||
|
BookmarkList bookmarkList = accessor.eap$getBookmarkList();
|
||||||
|
return bookmarkList.getElements().stream().map(IElement::getTypedIngredient).toList();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.extendedae_plus.mixin.jei;
|
package com.extendedae_plus.mixin.ae2;
|
||||||
|
|
||||||
import appeng.integration.modules.jei.transfer.EncodePatternTransferHandler;
|
import appeng.integration.modules.jei.transfer.EncodePatternTransferHandler;
|
||||||
import appeng.integration.modules.jeirei.EncodingHelper;
|
import appeng.integration.modules.jeirei.EncodingHelper;
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.extendedae_plus.mixin.ae2;
|
||||||
|
|
||||||
|
import appeng.api.stacks.AEFluidKey;
|
||||||
|
import appeng.api.stacks.AEItemKey;
|
||||||
|
import appeng.api.stacks.AEKey;
|
||||||
|
import appeng.integration.modules.jeirei.EncodingHelper;
|
||||||
|
import appeng.menu.me.common.GridInventoryEntry;
|
||||||
|
import appeng.menu.me.common.MEStorageMenu;
|
||||||
|
import com.extendedae_plus.integration.jei.JeiRuntimeProxy;
|
||||||
|
import mezz.jei.api.constants.VanillaTypes;
|
||||||
|
import mezz.jei.api.forge.ForgeTypes;
|
||||||
|
import mezz.jei.api.ingredients.ITypedIngredient;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@Mixin(EncodingHelper.class)
|
||||||
|
public class EncodingHelperMixin {
|
||||||
|
// 客户端:注入优先使用JEI书签的物品,流体
|
||||||
|
@Inject(method = "getIngredientPriorities", at = @At("TAIL"), cancellable = true, remap = false)
|
||||||
|
private static void epp$addJeiIngredientPriorities(MEStorageMenu menu, Comparator<GridInventoryEntry> comparator, CallbackInfoReturnable<Map<AEKey, Integer>> cir){
|
||||||
|
Map<AEKey, Integer> result = cir.getReturnValue();
|
||||||
|
AtomicInteger index = new AtomicInteger(Integer.MAX_VALUE);
|
||||||
|
List<? extends ITypedIngredient<?>> list = JeiRuntimeProxy.getBookmarkList();
|
||||||
|
for (ITypedIngredient<?> ingredient : list) {
|
||||||
|
ingredient.getIngredient(VanillaTypes.ITEM_STACK).ifPresent(itemStack -> result.put(AEItemKey.of(itemStack), index.getAndDecrement()));
|
||||||
|
ingredient.getIngredient(ForgeTypes.FLUID_STACK).ifPresent(fluidStack -> result.put(AEFluidKey.of(fluidStack), index.getAndDecrement()));
|
||||||
|
}
|
||||||
|
cir.setReturnValue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.extendedae_plus.mixin.jei.accessor;
|
||||||
|
|
||||||
|
import mezz.jei.gui.bookmarks.BookmarkList;
|
||||||
|
import mezz.jei.gui.overlay.bookmarks.BookmarkOverlay;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
@Mixin(BookmarkOverlay.class)
|
||||||
|
public interface BookmarkOverlayAccessor {
|
||||||
|
@Accessor("bookmarkList")
|
||||||
|
BookmarkList eap$getBookmarkList();
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,9 @@
|
||||||
"extendedae.HighlightButtonMixin",
|
"extendedae.HighlightButtonMixin",
|
||||||
"extendedae.accessor.GuiExPatternTerminalAccessor",
|
"extendedae.accessor.GuiExPatternTerminalAccessor",
|
||||||
"extendedae.accessor.GuiExPatternTerminalSlotsRowAccessor",
|
"extendedae.accessor.GuiExPatternTerminalSlotsRowAccessor",
|
||||||
|
"ae2.EncodePatternTransferHandlerMixin",
|
||||||
|
"ae2.EncodingHelperMixin",
|
||||||
|
"jei.accessor.BookmarkOverlayAccessor",
|
||||||
"hooks.ModelBakeryMixin",
|
"hooks.ModelBakeryMixin",
|
||||||
"jei.EncodePatternTransferHandlerMixin"
|
"jei.EncodePatternTransferHandlerMixin"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user