Skip to content

Commit 7c46595

Browse files
committed
Clean up redstone debug code, remove unimplemented r_out tunnel
Will implement redstone_out in a future version; for now, items and redstone_in should both be functional. Keeping it creative-only for now until recipes can be figured out, and beta testers can fiddle with it.
1 parent 84659f9 commit 7c46595

File tree

5 files changed

+14
-70
lines changed

5 files changed

+14
-70
lines changed

src/main/java/com/robotgryphon/compactmachines/api/tunnels/redstone/IRedstoneReaderTunnel.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212
*/
1313
public interface IRedstoneReaderTunnel extends IRedstoneTunnel {
1414

15-
int getStrongPower(ITunnelConnectionInfo connectionInfo);
16-
17-
int getWeakPower(ITunnelConnectionInfo connectionInfo);
15+
/**
16+
* Gets the weak (passive) power level from the outside of the machine.
17+
*
18+
* @param connectionInfo
19+
* @return
20+
*/
21+
default int getPowerLevel(ITunnelConnectionInfo connectionInfo) {
22+
return 0;
23+
}
1824

1925
/**
2026
* Called by the tunnel wall blocks to check if a redstone signal can be pulled
@@ -28,5 +34,5 @@ default boolean canConnectRedstone(ITunnelConnectionInfo connectionInfo) {
2834
return true;
2935
}
3036

31-
void onPowerChanged(ITunnelConnectionInfo connectionInfo, int latestPower);
37+
default void onPowerChanged(ITunnelConnectionInfo connectionInfo, int latestPower) {}
3238
}

src/main/java/com/robotgryphon/compactmachines/block/BlockCompactMachine.java

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ public boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos
9090
return false;
9191
}
9292

93-
@Override
94-
public int getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
95-
return 0;
96-
}
97-
9893
@Override
9994
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
10095
// TODO Tile Entity
@@ -132,16 +127,13 @@ public void neighborChanged(BlockState state, World world, BlockPos pos, Block c
132127
return;
133128
}
134129

135-
CompactMachines.LOGGER.debug(changedBlock);
136-
137130
// Determine whether it's an immediate neighbor; if so, execute ...
138131
Arrays.stream(Direction.values())
139132
.filter(hd -> pos.offset(hd).equals(changedPos))
140133
.findFirst()
141134
.ifPresent(facing -> {
142135
Set<BlockPos> tunnelsForMachineSide = TunnelHelper.getTunnelsForMachineSide(machine.machineId, serverWorld, facing);
143136
for (BlockPos tunnelPos : tunnelsForMachineSide) {
144-
// TODO: Tunnel definition lookup, check for IRedstoneTunnel instances
145137
TunnelWallTile tunnelTile = (TunnelWallTile) compactWorld.getTileEntity(tunnelPos);
146138
if (tunnelTile == null) continue;
147139

@@ -150,10 +142,9 @@ public void neighborChanged(BlockState state, World world, BlockPos pos, Block c
150142
ITunnelConnectionInfo connInfo = TunnelHelper.generateConnectionInfo(tunnelTile);
151143

152144
tunnelTile.getTunnelDefinition().ifPresent(tunnelDefinition -> {
145+
// TODO: world notification interface for tunnels
153146
if (tunnelDefinition instanceof IRedstoneReaderTunnel) {
154147
// Send redstone changes into machine
155-
156-
157148
IRedstoneReaderTunnel rrt = (IRedstoneReaderTunnel) tunnelDefinition;
158149
int latestPower = world.getRedstonePower(changedPos, facing);
159150
rrt.onPowerChanged(connInfo, latestPower);
@@ -163,44 +154,6 @@ public void neighborChanged(BlockState state, World world, BlockPos pos, Block c
163154
});
164155
}
165156

166-
@Override
167-
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
168-
super.onNeighborChange(state, world, pos, neighbor);
169-
170-
if (world.isRemote()) {
171-
return;
172-
}
173-
174-
// TODO Tile Entity
175-
// if(!(world.getTileEntity(pos) instanceof TileEntityMachine)) {
176-
// return;
177-
// }
178-
179-
180-
// TODO Tile Entity and Server Stuff
181-
// // Make sure we don't stack overflow when we get in a notifyBlockChange loop.
182-
// // Just ensure only a single notification happens per tick.
183-
// TileEntityMachine te = (TileEntityMachine) world.getTileEntity(pos);
184-
// if(te.isInsideItself() || te.alreadyNotifiedOnTick) {
185-
// return;
186-
// }
187-
//
188-
// ServerWorld machineWorld = DimensionTools.getServerMachineWorld();
189-
// BlockPos neighborPos = te.getConnectedBlockPosition(facing);
190-
// if(neighborPos != null && machineWorld.getTileEntity(neighborPos) instanceof TileEntityTunnel) {
191-
// machineWorld.notifyNeighborsOfStateChange(neighborPos, Blockss.tunnel, false);
192-
// te.alreadyNotifiedOnTick = true;
193-
// }
194-
//
195-
// RedstoneTunnelData tunnelData = te.getRedstoneTunnelForSide(facing);
196-
// if(tunnelData != null && !tunnelData.isOutput) {
197-
// BlockPos redstoneNeighborPos = tunnelData.pos;
198-
// if(redstoneNeighborPos != null && machineWorld.getTileEntity(redstoneNeighborPos) instanceof TileEntityRedstoneTunnel) {
199-
// machineWorld.notifyNeighborsOfStateChange(redstoneNeighborPos, Blockss.redstoneTunnel, false);
200-
// }
201-
// }
202-
}
203-
204157
@Override
205158
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
206159
Block given = CompactMachineUtil.getMachineBlockBySize(this.size);

src/main/java/com/robotgryphon/compactmachines/block/walls/TunnelWallBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public int getWeakPower(BlockState state, IBlockReader world, BlockPos pos, Dire
8787
TunnelDefinition definition = tunnelInfo.get();
8888
if (definition instanceof IRedstoneReaderTunnel) {
8989
ITunnelConnectionInfo conn = TunnelHelper.generateConnectionInfo(world, pos);
90-
int weak = ((IRedstoneReaderTunnel) definition).getWeakPower(conn);
90+
int weak = ((IRedstoneReaderTunnel) definition).getPowerLevel(conn);
9191
return weak;
9292
}
9393

src/main/java/com/robotgryphon/compactmachines/core/Registration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public class Registration {
171171

172172
public static final RegistryObject<TunnelDefinition> REDSTONE_IN_TUNNEL = TUNNEL_DEFINITIONS.register("redstone_in", RedstoneInTunnelDefinition::new);
173173

174-
public static final RegistryObject<TunnelDefinition> REDSTONE_OUT_TUNNEL = TUNNEL_DEFINITIONS.register("redstone_out", RedstoneOutTunnelDefinition::new);
174+
// public static final RegistryObject<TunnelDefinition> REDSTONE_OUT_TUNNEL = TUNNEL_DEFINITIONS.register("redstone_out", RedstoneOutTunnelDefinition::new);
175175

176176
// ================================================================================================================
177177
// DIMENSION

src/main/java/com/robotgryphon/compactmachines/tunnels/definitions/RedstoneInTunnelDefinition.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,7 @@ public int getTunnelIndicatorColor() {
3434
}
3535

3636
@Override
37-
public boolean canConnectRedstone(ITunnelConnectionInfo connectionInfo) {
38-
return true;
39-
}
40-
41-
@Override
42-
public void onPowerChanged(ITunnelConnectionInfo connectionInfo, int latestPower) {
43-
CompactMachines.LOGGER.debug("Got power change: {}", latestPower);
44-
}
45-
46-
@Override
47-
public int getStrongPower(ITunnelConnectionInfo connectionInfo) {
48-
return 0;
49-
}
50-
51-
@Override
52-
public int getWeakPower(ITunnelConnectionInfo connectionInfo) {
37+
public int getPowerLevel(ITunnelConnectionInfo connectionInfo) {
5338
IWorldReader connectedWorld = connectionInfo.getConnectedWorld(EnumTunnelSide.OUTSIDE).orElse(null);
5439
if (connectedWorld instanceof ServerWorld) {
5540
DimensionalPosition pos = connectionInfo.getConnectedPosition(EnumTunnelSide.OUTSIDE).orElse(null);

0 commit comments

Comments
 (0)