Skip to content

Commit 75c682e

Browse files
committed
Fixed that the ME Bridge would not work as an AE node anymore
1 parent e141cec commit 75c682e

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/MeBridgeEntity.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import appeng.api.networking.crafting.ICraftingSimulationRequester;
99
import appeng.api.networking.security.IActionHost;
1010
import appeng.api.networking.security.IActionSource;
11+
import appeng.api.orientation.BlockOrientation;
1112
import appeng.api.util.AECableType;
13+
import appeng.me.helpers.IGridConnectedBlockEntity;
1214
import de.srendi.advancedperipherals.common.addons.appliedenergistics.CraftJob;
1315
import de.srendi.advancedperipherals.common.addons.appliedenergistics.MeBridgeEntityListener;
1416
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MeBridgePeripheral;
@@ -29,16 +31,18 @@
2931

3032
import java.util.List;
3133
import java.util.Optional;
34+
import java.util.Set;
3235
import java.util.concurrent.CopyOnWriteArrayList;
3336

34-
public class MeBridgeEntity extends PeripheralBlockEntity<MeBridgePeripheral> implements IActionSource, IActionHost, IInWorldGridNodeHost, ICraftingSimulationRequester {
37+
public class MeBridgeEntity extends PeripheralBlockEntity<MeBridgePeripheral> implements IActionSource, IActionHost, IInWorldGridNodeHost, IGridConnectedBlockEntity, ICraftingSimulationRequester {
3538

3639
private final List<CraftJob> jobs = new CopyOnWriteArrayList<>();
3740
private boolean initialized = false;
3841
private final IManagedGridNode mainNode = GridHelper.createManagedNode(this, MeBridgeEntityListener.INSTANCE);
3942

4043
public MeBridgeEntity(BlockPos pos, BlockState state) {
4144
super(BlockEntityTypes.ME_BRIDGE.get(), pos, state);
45+
getMainNode().setExposedOnSides(getGridConnectableSides(null));
4246
}
4347

4448
@NotNull
@@ -51,14 +55,12 @@ protected MeBridgePeripheral createPeripheral() {
5155
public <T extends BlockEntity> void handleTick(Level level, BlockState state, BlockEntityType<T> type) {
5256
if (!this.level.isClientSide) {
5357
if (!initialized) {
54-
5558
mainNode.setFlags(GridFlags.REQUIRE_CHANNEL);
5659
mainNode.setIdlePowerUsage(APConfig.PERIPHERALS_CONFIG.meConsumption.get());
5760
mainNode.setVisualRepresentation(new ItemStack(Blocks.ME_BRIDGE.get()));
5861
mainNode.setInWorldNode(true);
5962
mainNode.create(level, getBlockPos());
60-
61-
//peripheral can be null if `getCapability` was not called before
63+
//peripheral can be null if `createPeripheralCap` was not called before
6264
if (peripheral == null)
6365
peripheral = createPeripheral();
6466
peripheral.setNode(mainNode);
@@ -109,12 +111,33 @@ public void onChunkUnloaded() {
109111
mainNode.destroy();
110112
}
111113

114+
@Override
115+
public IManagedGridNode getMainNode() {
116+
return mainNode;
117+
}
118+
119+
@Override
120+
public Set<Direction> getGridConnectableSides(BlockOrientation orientation) {
121+
return IGridConnectedBlockEntity.super.getGridConnectableSides(orientation);
122+
}
123+
124+
@Nullable
125+
@Override
126+
public IGridNode getGridNode() {
127+
return IGridConnectedBlockEntity.super.getGridNode();
128+
}
129+
112130
@Nullable
113131
@Override
114132
public IGridNode getGridNode(@NotNull Direction dir) {
115133
return getActionableNode();
116134
}
117135

136+
@Override
137+
public void saveChanges() {
138+
139+
}
140+
118141
@NotNull
119142
@Override
120143
public AECableType getCableConnectionType(@NotNull Direction dir) {

src/main/java/de/srendi/advancedperipherals/common/util/inventory/InventoryUtil.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ private InventoryUtil() {
2626
}
2727

2828
public static IItemHandler extractHandler(@Nullable Object object) {
29-
/*if (object instanceof ICapabilityProvider capabilityProvider) {
30-
LazyOptional<IItemHandler> cap = capabilityProvider.getCapability(ForgeCapabilities.ITEM_HANDLER);
31-
if (cap.isPresent())
32-
return cap.orElseThrow(NullPointerException::new);
33-
}*/
3429
if (object instanceof IItemHandler itemHandler)
3530
return itemHandler;
3631
if (object instanceof Container container)

0 commit comments

Comments
 (0)