Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Desoroxxx committed Sep 19, 2023
1 parent c983307 commit 5c5d998
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.redstudio.redcore.ticking;

import lombok.NoArgsConstructor;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -18,28 +19,25 @@ public class RedClientTickEvent extends Event {
* <p>
* In a client that is not lagging, it would be fired 10 times a second.
*/
@NoArgsConstructor
public static class BiTickEvent extends RedClientTickEvent {
public BiTickEvent() {
}
}

/**
* This event is fired each 5 ticks.
* <p>
* In a client that is not lagging, it would be fired 4 times a second.
*/
@NoArgsConstructor
public static class PentaTickEvent extends RedClientTickEvent {
public PentaTickEvent() {
}
}

/**
* This event is fired each 10 ticks.
* <p>
* In a client that is not lagging, it would be fired 2 times a second.
*/
@NoArgsConstructor
public static class DecaTickEvent extends RedClientTickEvent {
public DecaTickEvent() {
}
}
}
42 changes: 20 additions & 22 deletions src/main/java/dev/redstudio/redcore/ticking/RedClientTicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@
@SideOnly(Side.CLIENT)
public class RedClientTicker {

private static boolean clientTickerStarted = false;

private static int biTickCount, pentaTickCount, decaTickCount;

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onClientTickEvent(TickEvent.ClientTickEvent clientTickEvent) {
if (clientTickEvent.phase == TickEvent.Phase.START) {

biTickCount++;
if (biTickCount == 2) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.BiTickEvent());
biTickCount = 0;
}

pentaTickCount++;
if (pentaTickCount == 5) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.PentaTickEvent());
pentaTickCount = 0;
}

decaTickCount++;
if (decaTickCount == 10) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.DecaTickEvent());
decaTickCount = 0;
}
public static void onClientTickEvent(final TickEvent.ClientTickEvent clientTickEvent) {
if (clientTickEvent.phase != TickEvent.Phase.START)
return;

biTickCount++;
if (biTickCount == 2) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.BiTickEvent());
biTickCount = 0;
}

pentaTickCount++;
if (pentaTickCount == 5) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.PentaTickEvent());
pentaTickCount = 0;
}

decaTickCount++;
if (decaTickCount == 10) {
MinecraftForge.EVENT_BUS.post(new RedClientTickEvent.DecaTickEvent());
decaTickCount = 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/redstudio/redcore/utils/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Desoroxxx
* @since 0.2
*/
public class MathUtil {
public final class MathUtil {

/**
* Clamps a value within a specified range [min, max], checking for the minimum value first.
Expand Down

0 comments on commit 5c5d998

Please sign in to comment.