-
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.
Remove Schematicannon Mixin & add Serene Seasons one
- Loading branch information
1 parent
ef59672
commit 55b43d2
Showing
5 changed files
with
68 additions
and
30 deletions.
There are no files selected for viewing
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
28 changes: 0 additions & 28 deletions
28
.../java/dev/ithundxr/railwaystweaks/mixin/compat/create/SchematicannonBlockEntityMixin.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...java/dev/ithundxr/railwaystweaks/mixin/compat/sereneseasons/RandomUpdateHandlerMixin.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,22 @@ | ||
package dev.ithundxr.railwaystweaks.mixin.compat.sereneseasons; | ||
|
||
import dev.ithundxr.railwaystweaks.utils.TickCounter; | ||
import glitchcore.event.TickEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
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 sereneseasons.season.RandomUpdateHandler; | ||
|
||
@Mixin(RandomUpdateHandler.class) | ||
public class RandomUpdateHandlerMixin { | ||
|
||
@Unique private static TickCounter railwaystweaks$tickCounter = new TickCounter(100); | ||
|
||
@Inject(method = "onWorldTick", at = @At("HEAD"), cancellable = true, remap = false) | ||
private static void railwaystweaks$reduceRandomTicks(TickEvent.Level event, CallbackInfo ci) { | ||
railwaystweaks$tickCounter.increment(); | ||
if (!railwaystweaks$tickCounter.test()) ci.cancel(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/dev/ithundxr/railwaystweaks/utils/TickCounter.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,39 @@ | ||
package dev.ithundxr.railwaystweaks.utils; | ||
|
||
public class TickCounter { | ||
|
||
private final int tickThreshold; | ||
private final int maxValue; | ||
|
||
private int counter = 0; | ||
|
||
public TickCounter(int tickThreshold) { | ||
this(tickThreshold, Integer.MAX_VALUE); | ||
} | ||
|
||
public TickCounter(int tickThreshold, int maxValue) { | ||
this.tickThreshold = tickThreshold; | ||
this.maxValue = maxValue; | ||
} | ||
|
||
public boolean test() { | ||
if(counter >= tickThreshold) { | ||
reset(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void increment() { | ||
if(counter >= maxValue || counter < 0) reset(); | ||
else counter++; | ||
} | ||
|
||
public void reset() { | ||
counter = 0; | ||
} | ||
|
||
public int value() { return this.counter; } | ||
|
||
public int getTickThreshold() { return this.tickThreshold; } | ||
} |
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