Skip to content

Commit

Permalink
Only expose the IItemHandler capability for block EMC interface
Browse files Browse the repository at this point in the history
Prevents showing unnecessary fluid containers in tooltip mods such as Jade and TOP
  • Loading branch information
62832 committed Apr 29, 2024
1 parent e3beaaa commit 9e6976e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dependencies {

runtimeOnly(fg.deobf(libs.projectex.get()))
runtimeOnly(fg.deobf(libs.teampe.get()))
runtimeOnly(fg.deobf(libs.jade.get()))
}

tasks {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencyResolutionManagement {

library("projectex", "curse.maven", "project-expansion-579177").version("5232445")
library("teampe", "curse.maven", "team-projecte-689273").version("4882959")
library("jade", "curse.maven", "jade-324717").version("5072729")
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/gripe/_90/appliede/iface/EMCInterfaceLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;

import appeng.api.behaviors.GenericInternalInventory;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.GridFlags;
Expand All @@ -31,6 +32,7 @@
import appeng.api.stacks.GenericStack;
import appeng.api.storage.MEStorage;
import appeng.capabilities.Capabilities;
import appeng.helpers.externalstorage.GenericStackItemStorage;
import appeng.me.storage.DelegatingMEInventory;
import appeng.util.ConfigInventory;
import appeng.util.Platform;
Expand All @@ -55,7 +57,7 @@ public class EMCInterfaceLogic implements IActionHost, IGridTickable {
private final GenericStack[] plannedWork;
private int priority = 0;

private final LazyOptional<GenericInternalInventory> storageHolder;
private final LazyOptional<IItemHandler> storageHolder;
private final LazyOptional<MEStorage> localInvHolder;

public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host) {
Expand All @@ -73,7 +75,7 @@ public EMCInterfaceLogic(IManagedGridNode node, EMCInterfaceLogicHost host, int
config.useRegisteredCapacities();
storage.useRegisteredCapacities();

storageHolder = LazyOptional.of(() -> storage);
storageHolder = LazyOptional.of(() -> storage).lazyMap(GenericStackItemStorage::new);
localInvHolder = LazyOptional.of(this::getInventory);
}

Expand Down Expand Up @@ -331,7 +333,7 @@ public void addDrops(List<ItemStack> drops) {
}

public <T> LazyOptional<T> getCapability(Capability<T> cap) {
if (cap == Capabilities.GENERIC_INTERNAL_INV) {
if (cap == ForgeCapabilities.ITEM_HANDLER) {
return storageHolder.cast();
} else if (cap == Capabilities.STORAGE) {
return localInvHolder.cast();
Expand Down

0 comments on commit 9e6976e

Please sign in to comment.