Skip to content

Commit

Permalink
Add CompatibilityUtils
Browse files Browse the repository at this point in the history
Change VanillaCauldronBehaviors
  • Loading branch information
FirstMegaGame4 committed Sep 22, 2023
1 parent fc74520 commit 1a6b53b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/
public class VanillaCauldronBehaviors {

public static final VanillaCauldronBehaviorMap EMPTY_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final VanillaCauldronBehaviorMap WATER_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final VanillaCauldronBehaviorMap LAVA_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final VanillaCauldronBehaviorMap SNOW_POWDER_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final CauldronBehaviorMap EMPTY_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final CauldronBehaviorMap WATER_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final CauldronBehaviorMap LAVA_BEHAVIOR = new VanillaCauldronBehaviorMap();
public static final CauldronBehaviorMap SNOW_POWDER_BEHAVIOR = new VanillaCauldronBehaviorMap();

public static class VanillaCauldronBehaviorMap extends CauldronBehaviorMap {
private static class VanillaCauldronBehaviorMap extends CauldronBehaviorMap {

@Override
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mmodding.mmodding_lib.library.utils;

import org.quiltmc.loader.api.QuiltLoader;

import java.util.function.Supplier;

public class CompatibilityUtils {

public static <T> T getIfModLoadedOrElse(String modId, Supplier<T> ifLoaded, Supplier<T> orElse) {
return QuiltLoader.isModLoaded(modId) ? ifLoaded.get() : orElse.get();
}

public static void executeIfModLoaded(String modId, Runnable run) {
if (QuiltLoader.isModLoaded(modId)) {
run.run();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public interface TickOperations {

void setTickValue(int tickValue);

default void checkTickForOperation(int tick, Runnable runnable) {
default void checkTickForOperation(int tick, Runnable run) {
if (this.getTickValue() >= tick) {
runnable.run();
run.run();
this.setTickValue(0);
} else {
this.setTickValue(this.getTickValue() + 1);
Expand Down

0 comments on commit 1a6b53b

Please sign in to comment.