Skip to content

Commit fd9f312

Browse files
committed
Duct-tape piston resolver, closes #64, #63, #61
1 parent d06fa6f commit fd9f312

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

changelog.txt

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
- Implement `@ModuleInstance` (MehVahdJukaar)
2-
- Complain when mods return null from `IForgeItem#getCraftingRemainingItem` and try to move on instead of crashing b/c I'm sick of fielding issue reports about it lol (quat)
3-
- Pressing Escape backs up only 1 level from config screens instead of kicking you out (quat)
4-
- Try and fix the Quark config being perpetually "incorrect"; had to do with anti-overlap comments (quat)
5-
- Change how config loading works; ensure everything is loaded on the correct threads at the correct times, ignore config change requests that happen too early, lots of verbose logging. (quat)
6-
7-
Changes from older versions (which were mistakenly uploaded as 1.20.0 so you might not have seen them)
8-
9-
- fixed an issue with piston and sticky blocks (MehVahdJukaar)
10-
- Some fixes for the config loading race condition (MehVahdJukaar)
1+
- Try and fix crashes related to ZetaPistonStructureResolver

src/main/java/org/violetmoon/zeta/piston/ZetaPistonStructureResolver.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,23 @@ public boolean resolve() {
115115
} else if (!addBlockLine(blockToMove, moveDirection))
116116
return false;
117117
else {
118-
for (BlockPos blockpos : myToPush) {
119-
if (addBranchingBlocks(world, blockpos, isBlockBranching(world, blockpos)) == MoveResult.PREVENT)
120-
return false;
121-
}
118+
//vanilla does this
119+
//for(int i = 0; i < this.toPush.size(); ++i) {
120+
// BlockPos blockpos = (BlockPos)this.toPush.get(i);
121+
// if (this.level.getBlockState(blockpos).isStickyBlock() && !this.addBranchingBlocks(blockpos)) {
122+
// return false;
123+
// }
124+
//}
125+
//we need to replace the stickiness logic with more complicated branching logic
126+
//i.e. a normal block needs to trigger addBranchingBlocks code if there is a Quark chain next to it.
127+
//an indexed for is fine in vanilla since it never removes blocks from toPush (we do)
128+
129+
//noinspection ForLoopReplaceableByForEach //it isn't, we modify myToPush
130+
for(int i = 0; i < myToPush.size(); i++) {
131+
BlockPos blockpos = myToPush.get(i);
132+
if(addBranchingBlocks(world, blockpos, isBlockBranching(world, blockpos)) == MoveResult.PREVENT)
133+
return false;
134+
}
122135

123136
return true;
124137
}
@@ -222,7 +235,7 @@ else if (res != MoveResult.MOVE) {
222235

223236
if (state.getPistonPushReaction() == PushReaction.DESTROY) {
224237
myToDestroy.add(currentPos);
225-
myToPush.remove(currentPos);
238+
// myToPush.remove(currentPos);
226239
return true;
227240
}
228241

@@ -294,7 +307,6 @@ private MoveResult addBranchingBlocks(Level world, BlockPos fromPos, boolean isS
294307
case BREAK:
295308
if (PistonBaseBlock.isPushable(targetState, world, targetPos, moveDirection, true, moveDirection)) {
296309
myToDestroy.add(targetPos);
297-
myToPush.remove(targetPos);
298310
return MoveResult.BREAK;
299311
}
300312

0 commit comments

Comments
 (0)