Skip to content

Commit

Permalink
Remove Schematicannon Mixin & add Serene Seasons one
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-evelyn committed Dec 1, 2024
1 parent ef59672 commit 55b43d2
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 30 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ dependencies {
modCompileOnly("tschipp.carryon:carryon-fabric-1.20.1:2.1.2.7") { isTransitive = false }

// OPAC API
modCompileOnly("maven.modrinth:open-parties-and-claims:fabric-1.20.1-0.23.2")
modCompileOnlyApi("maven.modrinth:open-parties-and-claims:fabric-1.20.1-0.23.2")

// Serene Seasons
modCompileOnly("maven.modrinth:serene-seasons:4RgDk9NB")
modCompileOnly("maven.modrinth:glitchcore:25HLOiOl")
}

tasks.processResources {
Expand Down

This file was deleted.

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 src/main/java/dev/ithundxr/railwaystweaks/utils/TickCounter.java
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; }
}
3 changes: 2 additions & 1 deletion src/main/resources/railwaystweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"compat.create.BlockHelperMixin",
"compat.create.Carriage$DimensionalCarriageEntityMixin",
"compat.create.CarriageAccessor",
"compat.create.SchematicannonBlockEntityMixin",
"compat.create.FunnelBlockEntityMixin",
"compat.dcintegration.DiscordEventListenerMixin",
"compat.enchancement.SlideComponentMixin",
"compat.sereneseasons.RandomUpdateHandlerMixin",
"compat.tconstruct.LazyModifierMixin",
"compat.tconstruct.SimpleChannelAccessor"
],
Expand Down

0 comments on commit 55b43d2

Please sign in to comment.