mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
better fix for InventorySorter compat
This commit is contained in:
parent
50798ab86b
commit
cda89da9ca
6 changed files with 41 additions and 12 deletions
|
@ -247,6 +247,7 @@ dependencies {
|
||||||
// modRuntimeOnly("curse.maven:blueprint-382216:4749000")
|
// modRuntimeOnly("curse.maven:blueprint-382216:4749000")
|
||||||
// modRuntimeOnly("curse.maven:windsweptmod-636321:4817132")
|
// modRuntimeOnly("curse.maven:windsweptmod-636321:4817132")
|
||||||
// modRuntimeOnly("curse.maven:good-ending-690161:4363719")
|
// modRuntimeOnly("curse.maven:good-ending-690161:4363719")
|
||||||
|
// modRuntimeOnly("curse.maven:inventory-sorter-240633:5979609")
|
||||||
|
|
||||||
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
|
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
|
||||||
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
|
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.simibubi.create;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.simibubi.create.compat.inventorySorter.InventorySorterCompat;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
@ -156,6 +158,7 @@ public class Create {
|
||||||
|
|
||||||
// FIXME: this is not thread-safe
|
// FIXME: this is not thread-safe
|
||||||
Mods.CURIOS.executeIfInstalled(() -> () -> Curios.init(modEventBus, forgeEventBus));
|
Mods.CURIOS.executeIfInstalled(() -> () -> Curios.init(modEventBus, forgeEventBus));
|
||||||
|
Mods.INVENTORYSORTER.executeIfInstalled(() -> () -> InventorySorterCompat.init(modEventBus));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final FMLCommonSetupEvent event) {
|
public static void init(final FMLCommonSetupEvent event) {
|
||||||
|
|
|
@ -34,7 +34,8 @@ public enum Mods {
|
||||||
MODERNUI,
|
MODERNUI,
|
||||||
FTBCHUNKS,
|
FTBCHUNKS,
|
||||||
JOURNEYMAP,
|
JOURNEYMAP,
|
||||||
FTBLIBRARY;
|
FTBLIBRARY,
|
||||||
|
INVENTORYSORTER;
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.simibubi.create.compat.inventorySorter;
|
||||||
|
|
||||||
|
import com.simibubi.create.compat.Mods;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.logistics.redstoneRequester.RedstoneRequesterMenu.SorterProofSlot;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.fml.InterModComms;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compatibility with cpw's InventorySorter.
|
||||||
|
* We need to stop it from interfering with scrolling in the Redstone Requester's screen.
|
||||||
|
*/
|
||||||
|
public class InventorySorterCompat {
|
||||||
|
public static final String SLOT_BLACKLIST = "slotblacklist";
|
||||||
|
|
||||||
|
public static void init(IEventBus bus) {
|
||||||
|
bus.addListener(InventorySorterCompat::sendImc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendImc(InterModEnqueueEvent event) {
|
||||||
|
InterModComms.sendTo(Mods.INVENTORYSORTER.id(), SLOT_BLACKLIST, SorterProofSlot.class::getName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class RedstoneRequesterMenu extends GhostItemMenu<RedstoneRequesterBlockE
|
||||||
|
|
||||||
addPlayerSlots(playerX, playerY);
|
addPlayerSlots(playerX, playerY);
|
||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
addSlot(new SlotItemHandler(ghostInventory, i, slotX + 20 * i, slotY));
|
addSlot(new SorterProofSlot(ghostInventory, i, slotX + 20 * i, slotY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,4 +80,11 @@ public class RedstoneRequesterMenu extends GhostItemMenu<RedstoneRequesterBlockE
|
||||||
contentHolder.sendData();
|
contentHolder.sendData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is used to prevent InventorySorter from interfering with scrolling on the slots.
|
||||||
|
// we just need a class to use as a marker, see InventorySorterCompat
|
||||||
|
public static class SorterProofSlot extends SlotItemHandler {
|
||||||
|
public SorterProofSlot(IItemHandler itemHandler, int index, int xPosition, int yPosition) {
|
||||||
|
super(itemHandler, index, xPosition, yPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,15 +197,6 @@ public class RedstoneRequesterScreen extends AbstractSimiContainerScreen<Redston
|
||||||
return super.mouseScrolled(mouseX, mouseY, pDelta);
|
return super.mouseScrolled(mouseX, mouseY, pDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Fixes InventorySorter nabbing the scroll event. This screen needs it for
|
|
||||||
* amount control
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public @Nullable Slot getSlotUnderMouse() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTooltipFromContainerItem(ItemStack pStack) {
|
protected List<Component> getTooltipFromContainerItem(ItemStack pStack) {
|
||||||
List<Component> tooltip = super.getTooltipFromContainerItem(pStack);
|
List<Component> tooltip = super.getTooltipFromContainerItem(pStack);
|
||||||
|
|
Loading…
Add table
Reference in a new issue