|
1 | 1 | package org.gtreimagined.gt4r.reactor.tile;
|
2 | 2 |
|
3 | 3 | import lombok.Getter;
|
| 4 | +import muramasa.antimatter.Ref; |
4 | 5 | import muramasa.antimatter.blockentity.BlockEntityFakeBlock;
|
5 | 6 | import muramasa.antimatter.blockentity.BlockEntityMachine;
|
6 | 7 | import muramasa.antimatter.machine.Tier;
|
7 | 8 | import muramasa.antimatter.machine.types.Machine;
|
8 | 9 | import muramasa.antimatter.tool.AntimatterToolType;
|
| 10 | +import muramasa.antimatter.util.Utils; |
9 | 11 | import net.minecraft.core.BlockPos;
|
10 | 12 | import net.minecraft.core.Direction;
|
11 | 13 | import net.minecraft.nbt.CompoundTag;
|
|
23 | 25 | import org.gtreimagined.gt4r.data.Machines;
|
24 | 26 | import org.jetbrains.annotations.NotNull;
|
25 | 27 | import org.jetbrains.annotations.Nullable;
|
| 28 | +import tesseract.TesseractCapUtils; |
| 29 | +import tesseract.api.gt.IEnergyHandler; |
| 30 | + |
| 31 | +import java.util.Optional; |
26 | 32 |
|
27 | 33 | public class BlockEntityReactorChamber extends BlockEntityMachine<BlockEntityReactorChamber> {
|
28 | 34 | @Getter
|
@@ -63,6 +69,23 @@ public void onFirstTickClient(Level level, BlockPos pos, BlockState state) {
|
63 | 69 | }
|
64 | 70 | }
|
65 | 71 |
|
| 72 | + @Override |
| 73 | + public void serverTick(Level level, BlockPos pos, BlockState state) { |
| 74 | + super.serverTick(level, pos, state); |
| 75 | + if (reactor != null && !reactor.isFluid()) { |
| 76 | + for (Direction dir : Ref.DIRS) { |
| 77 | + if (dir != reactorSide) { |
| 78 | + BlockEntity tile = this.getCachedBlockEntity(dir); |
| 79 | + if (tile == null) continue; |
| 80 | + Optional<IEnergyHandler> handle = TesseractCapUtils.INSTANCE.getEnergyHandler(tile, dir.getOpposite()); |
| 81 | + if (handle.map(h -> !h.canInput(dir.getOpposite())).orElse(true)) continue; |
| 82 | + handle.ifPresent(eh -> reactor.energyHandler.ifPresent(h -> Utils.transferEnergy(h, eh))); |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + } |
| 88 | + |
66 | 89 | @Override
|
67 | 90 | public @NotNull <U> LazyOptional<U> getCapability(@NotNull Capability<U> cap, @Nullable Direction side) {
|
68 | 91 | if (reactor != null) {
|
|
0 commit comments