Skip to content

Commit

Permalink
Properly proxy computer capabilities to secondary ports on the digita…
Browse files Browse the repository at this point in the history
…l miner (#8215)
  • Loading branch information
pupnewfster committed Aug 26, 2024
1 parent 425e1af commit 2911cfe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ dependencies {
compileOnly("com.blamejared.recipestages:RecipeStages:${recipe_stages_version}")
compileOnly("curse.maven:opencomputers2-437654:${oc2_id}")
compileOnly("cc.tweaked:cc-tweaked-${previous_minor_minecraft_version}-forge-api:${cc_tweaked_version}")
//localRuntime("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_tweaked_version}")
//localRuntime("cc.tweaked:cc-tweaked-${previous_minor_minecraft_version}-forge:${cc_tweaked_version}")
compileOnly("curse.maven:female-gender-forge-481655:${wildfire_gender_mod_id}")
compileOnly("curse.maven:framedblocks-441647:${framedblocks_mod_id}")

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mekanism/common/capabilities/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import mekanism.api.security.IEntitySecurityUtils;
import mekanism.common.Mekanism;
import mekanism.common.entity.EntityRobit;
import mekanism.common.integration.computer.ComputerCapabilityHelper;
import mekanism.common.integration.energy.EnergyCompatUtils;
import mekanism.common.lib.radiation.capability.RadiationEntity;
import mekanism.common.registries.MekanismEntityTypes;
Expand Down Expand Up @@ -98,6 +99,7 @@ public static void registerCapabilities(RegisterCapabilitiesEvent event) {
TileEntityBoundingBlock.alwaysProxyCapability(event, IBlockSecurityUtils.INSTANCE.ownerCapability());
TileEntityBoundingBlock.alwaysProxyCapability(event, IBlockSecurityUtils.INSTANCE.securityCapability());
//Capabilities we need to proxy because some sub implementations use them
ComputerCapabilityHelper.addBoundingComputerCapabilities(event);
TileEntityBoundingBlock.proxyCapability(event, ITEM.block());
for (BlockCapability<?, @Nullable Direction> capability : EnergyCompatUtils.getLoadedEnergyCapabilities()) {
TileEntityBoundingBlock.proxyCapability(event, capability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mekanism.common.integration.computer.opencomputers2.OC2CapabilityHelper;
import mekanism.common.registration.impl.TileEntityTypeDeferredRegister.BlockEntityTypeBuilder;
import mekanism.common.tile.base.CapabilityTileEntity;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;

public class ComputerCapabilityHelper {

Expand All @@ -19,4 +20,15 @@ public static <TILE extends CapabilityTileEntity & IComputerTile> void addComput
OC2CapabilityHelper.addCapability(builder, supportsComputer);
}
}

public static void addBoundingComputerCapabilities(RegisterCapabilitiesEvent event) {
if (Mekanism.hooks.CCLoaded) {
//If ComputerCraft is loaded add the capability for it
CCCapabilityHelper.addBoundingComputerCapabilities(event);
}
if (Mekanism.hooks.OC2Loaded) {
//If OpenComputers2 is loaded add the capability for it
OC2CapabilityHelper.addBoundingComputerCapabilities(event);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import mekanism.common.integration.computer.ComputerFilterHelper;
import mekanism.common.integration.computer.IComputerTile;
import mekanism.common.registration.impl.TileEntityTypeDeferredRegister.BlockEntityTypeBuilder;
import mekanism.common.tile.TileEntityBoundingBlock;
import mekanism.common.tile.base.CapabilityTileEntity;
import net.minecraft.core.Direction;
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import org.jetbrains.annotations.Nullable;

public class CCCapabilityHelper {
Expand All @@ -32,6 +34,10 @@ public static <TILE extends CapabilityTileEntity & IComputerTile> void addCapabi
builder.with(PeripheralCapability.get(), (ICapabilityProvider<? super TILE, @Nullable Direction, IPeripheral>) PROVIDER, supportsComputer);
}

public static void addBoundingComputerCapabilities(RegisterCapabilitiesEvent event) {
TileEntityBoundingBlock.proxyCapability(event, PeripheralCapability.get());
}

public static void registerApis() {
ComputerCraftAPI.registerAPIFactory(CCApiObject.create(ComputerEnergyHelper.class, "mekanismEnergyHelper"));
ComputerCraftAPI.registerAPIFactory(CCApiObject.create(ComputerFilterHelper.class, "mekanismFilterHelper"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import mekanism.common.integration.computer.IComputerTile;
import mekanism.common.registration.impl.TileEntityTypeDeferredRegister.BlockEntityTypeBuilder;
import mekanism.common.tile.base.CapabilityTileEntity;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;

public class OC2CapabilityHelper {

Expand All @@ -24,4 +25,8 @@ public static <TILE extends CapabilityTileEntity & IComputerTile> void addCapabi
//TODO - 1.20.2: Reimplement when OC2 updates
//builder.with(CAPABILITY, (ICapabilityProvider<? super TILE, @Nullable Direction, Device>) PROVIDER, supportsComputer);
}

public static void addBoundingComputerCapabilities(RegisterCapabilitiesEvent event) {
//TileEntityBoundingBlock.proxyCapability(event, CAPABILITY);
}
}

0 comments on commit 2911cfe

Please sign in to comment.