Skip to content

Commit 8953ab2

Browse files
committed
Revert propagating redstone signal.
1 parent 77f5fb8 commit 8953ab2

File tree

2 files changed

+2
-87
lines changed

2 files changed

+2
-87
lines changed

src/main/java/dev/technici4n/moderndynamics/extender/MachineExtenderBlock.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import net.minecraft.core.Direction;
2424
import net.minecraft.server.level.ServerLevel;
2525
import net.minecraft.util.RandomSource;
26-
import net.minecraft.world.Containers;
2726
import net.minecraft.world.item.context.BlockPlaceContext;
2827
import net.minecraft.world.level.Level;
2928
import net.minecraft.world.level.LevelReader;
@@ -83,7 +82,7 @@ protected void neighborChanged(BlockState state, Level level, BlockPos pos, Bloc
8382
sideExtender.inNeighborUpdate = true;
8483

8584
try {
86-
sideExtender.getLevel().updateNeighborsAtExceptFromFacing(pos, this, Direction.DOWN, orientation);
85+
level.updateNeighborsAtExceptFromFacing(pos, this, Direction.DOWN, orientation);
8786
} finally {
8887
sideExtender.inNeighborUpdate = false;
8988
}
@@ -94,38 +93,8 @@ protected void neighborChanged(BlockState state, Level level, BlockPos pos, Bloc
9493

9594
@Override
9695
public void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockPos neighbor) {
97-
if (pos.below().equals(neighbor) && level instanceof Level actualLevel) {
96+
if (pos.below().equals(neighbor) && level instanceof ServerLevel actualLevel) {
9897
actualLevel.updateNeighborsAtExceptFromFacing(pos, this, Direction.DOWN, null);
9998
}
10099
}
101-
102-
@Override
103-
protected boolean hasAnalogOutputSignal(BlockState state) {
104-
return true;
105-
}
106-
107-
@Override
108-
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos, Direction direction) {
109-
if (direction == Direction.DOWN || SIGNAL_FORWARDING.isBound()) {
110-
return 0;
111-
}
112-
113-
// Seek to the first non-extender below
114-
var below = pos.below();
115-
while (below.getY() > 0 && level.getBlockState(below).is(this)) {
116-
below = below.below();
117-
}
118-
119-
// Ensure we don't get recursively called
120-
var source = below;
121-
return ScopedValue.where(SIGNAL_FORWARDING, null).call(() -> {
122-
return level.getBlockState(source).getAnalogOutputSignal(level, source, Direction.UP);
123-
});
124-
}
125-
126-
@Override
127-
protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) {
128-
// This mirrors what ChestBlock does
129-
Containers.updateNeighboursAfterDestroy(state, level, pos);
130-
}
131100
}

src/main/java/dev/technici4n/moderndynamics/test/MachineExtenderTest.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@
2020

2121
import dev.technici4n.moderndynamics.init.MdBlocks;
2222
import dev.technici4n.moderndynamics.test.framework.MdGameTestHelper;
23-
import java.util.List;
2423
import net.minecraft.core.BlockPos;
2524
import net.minecraft.core.Direction;
2625
import net.minecraft.network.chat.Component;
27-
import net.minecraft.world.item.Items;
2826
import net.minecraft.world.level.block.Blocks;
29-
import net.minecraft.world.level.block.RedstoneLampBlock;
3027
import net.neoforged.neoforge.capabilities.Capabilities;
31-
import net.neoforged.neoforge.transfer.item.ItemResource;
32-
import net.neoforged.neoforge.transfer.transaction.Transaction;
3328

3429
public class MachineExtenderTest {
3530
@MdGameTest
@@ -58,53 +53,4 @@ public void machineExtenderNotForwardingFromBelow(MdGameTestHelper helper) {
5853
})
5954
.thenSucceed();
6055
}
61-
62-
@MdGameTest
63-
public void machineExtenderForwardWeakSignal(MdGameTestHelper helper) {
64-
var l0 = new BlockPos(4, 1, 4);
65-
var l1 = l0.above();
66-
var l2 = l1.above();
67-
68-
helper.setBlock(l0, Blocks.HOPPER);
69-
helper.setBlock(l0.north().below(), Blocks.STONE, Direction.SOUTH);
70-
helper.setBlock(l0.north(), Blocks.COMPARATOR, Direction.SOUTH);
71-
helper.setBlock(l0.north().north(), Blocks.REDSTONE_LAMP);
72-
73-
helper.setBlock(l1, MdBlocks.MACHINE_EXTENDER.get());
74-
helper.setBlock(l1.east().below(), Blocks.STONE);
75-
helper.setBlock(l1.east(), Blocks.COMPARATOR, Direction.WEST);
76-
helper.setBlock(l1.east().east(), Blocks.REDSTONE_LAMP);
77-
78-
helper.setBlock(l2, MdBlocks.MACHINE_EXTENDER.get());
79-
helper.setBlock(l2.west().below(), Blocks.STONE);
80-
helper.setBlock(l2.west(), Blocks.COMPARATOR, Direction.EAST);
81-
helper.setBlock(l2.west().west(), Blocks.REDSTONE_LAMP);
82-
83-
var lamps = List.of(l0.north().north(), l1.east().east(), l2.west().west());
84-
var lampOff = Blocks.REDSTONE_LAMP.defaultBlockState();
85-
var lampOn = lampOff.setValue(RedstoneLampBlock.LIT, true);
86-
87-
helper.startSequence()
88-
.thenExecute(() -> {
89-
for (var lamp : lamps) {
90-
helper.assertBlockState(lamp, lampOff);
91-
}
92-
})
93-
.thenExecuteAfter(1, () -> {
94-
// Fill the hopper
95-
try (var tx = Transaction.openRoot()) {
96-
var items = helper.getLevel().getCapability(Capabilities.Item.BLOCK, helper.absolutePos(l0), Direction.UP);
97-
for (int i = 0; i < items.size(); i++) {
98-
items.insert(ItemResource.of(Items.STICK), 64, tx);
99-
}
100-
tx.commit();
101-
}
102-
})
103-
.thenExecuteAfter(5, () -> {
104-
for (var lamp : lamps) {
105-
helper.assertBlockState(lamp, lampOn);
106-
}
107-
})
108-
.thenSucceed();
109-
}
11056
}

0 commit comments

Comments
 (0)