forked from VazkiiMods/Botania
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix redstone still breaking when placed on exchanged blocks after Vaz…
…kiiMods#4316 (VazkiiMods#4330) This reverts back to the original implementation I had for preventing blocks attached to replaced blocks from breaking. After further testing I found that the current solution only works for simple things like torches, but not more complex things like redstone dust.
- Loading branch information
Showing
6 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
Xplat/src/main/java/vazkii/botania/common/CollectingNeighborUpdaterAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package vazkii.botania.common; | ||
|
||
public interface CollectingNeighborUpdaterAccess { | ||
void botania$pauseUpdates(); | ||
|
||
void botania$resumeUpdates(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Xplat/src/main/java/vazkii/botania/mixin/CollectingNeighborUpdaterMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package vazkii.botania.mixin; | ||
|
||
import net.minecraft.world.level.redstone.CollectingNeighborUpdater; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import vazkii.botania.common.CollectingNeighborUpdaterAccess; | ||
|
||
@Mixin(CollectingNeighborUpdater.class) | ||
abstract class CollectingNeighborUpdaterMixin implements CollectingNeighborUpdaterAccess { | ||
@Shadow | ||
private int count; | ||
@Shadow | ||
@Final | ||
private int maxChainedNeighborUpdates; | ||
|
||
@Shadow | ||
protected abstract void runUpdates(); | ||
|
||
@Unique | ||
private boolean delayUpdates = false; | ||
|
||
@Inject(method = "runUpdates", at = @At("HEAD"), cancellable = true) | ||
void skipUpdatesWhenDelayed(final CallbackInfo ci) { | ||
if (this.delayUpdates | ||
// It's possible to just temporarily change the max chained updates, but I don't think | ||
// we will normally get to that amount anyway as we pause/resume updates for each single block | ||
// we exchange, and the limit is 1000000 by default | ||
&& this.count < this.maxChainedNeighborUpdates) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Override | ||
public void botania$pauseUpdates() { | ||
this.delayUpdates = true; | ||
} | ||
|
||
@Override | ||
public void botania$resumeUpdates() { | ||
this.delayUpdates = false; | ||
this.runUpdates(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Xplat/src/main/java/vazkii/botania/mixin/LevelAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package vazkii.botania.mixin; | ||
|
||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.redstone.NeighborUpdater; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(Level.class) | ||
public interface LevelAccessor { | ||
@Accessor("neighborUpdater") | ||
NeighborUpdater getNeighborUpdater(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters