Skip to content

Commit 644e2c0

Browse files
committed
started work on reactor chamber
1 parent fd5ebc2 commit 644e2c0

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.gtreimagined.gt4r.reactor.tile;
2+
3+
import muramasa.antimatter.blockentity.BlockEntityFakeBlock;
4+
import muramasa.antimatter.blockentity.BlockEntityMachine;
5+
import muramasa.antimatter.machine.types.Machine;
6+
import muramasa.antimatter.tool.AntimatterToolType;
7+
import net.minecraft.core.BlockPos;
8+
import net.minecraft.core.Direction;
9+
import net.minecraft.server.level.ServerPlayer;
10+
import net.minecraft.world.InteractionHand;
11+
import net.minecraft.world.InteractionResult;
12+
import net.minecraft.world.entity.player.Player;
13+
import net.minecraft.world.level.Level;
14+
import net.minecraft.world.level.block.state.BlockState;
15+
import net.minecraft.world.phys.BlockHitResult;
16+
import net.minecraftforge.common.capabilities.Capability;
17+
import net.minecraftforge.common.util.LazyOptional;
18+
import net.minecraftforge.network.NetworkHooks;
19+
import org.jetbrains.annotations.NotNull;
20+
import org.jetbrains.annotations.Nullable;
21+
22+
public class BlockEntityReactorChamber extends BlockEntityMachine<BlockEntityReactorChamber> {
23+
BlockEntityReactorCore reactor;
24+
25+
public BlockEntityReactorChamber(Machine<?> type, BlockPos pos, BlockState state) {
26+
super(type, pos, state);
27+
}
28+
29+
@Override
30+
public @NotNull <U> LazyOptional<U> getCapability(@NotNull Capability<U> cap, @Nullable Direction side) {
31+
if (reactor != null) {
32+
return reactor.getCapability(cap, side);
33+
}
34+
return super.getCapability(cap, side);
35+
}
36+
37+
@Override
38+
public InteractionResult onInteractServer(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit, @Nullable AntimatterToolType type) {
39+
if (reactor != null && type == null) {
40+
if (!world.isClientSide){
41+
NetworkHooks.openGui((ServerPlayer) player, reactor, extra -> {
42+
extra.writeBlockPos(reactor.getBlockPos());
43+
});
44+
}
45+
return InteractionResult.SUCCESS;
46+
}
47+
return super.onInteractServer(state, world, pos, player, hand, hit, type);
48+
}
49+
50+
public void setReactor(BlockEntityReactorCore reactor) {
51+
this.reactor = reactor;
52+
}
53+
}

0 commit comments

Comments
 (0)