-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
329 additions
and
249 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
@file:JvmName("Logging") | ||
|
||
package juuxel.adorn.util | ||
|
||
import org.slf4j.Logger | ||
|
23 changes: 23 additions & 0 deletions
23
fabric/src/main/java/juuxel/adorn/compat/BiomeMakeoverCompat.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,23 @@ | ||
package juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class BiomeMakeoverCompat implements BlockVariantSet { | ||
private static final String[] WOOD_VARIANTS = { | ||
"ancient_oak", | ||
"blighted_balsa", | ||
"willow", | ||
"swamp_cypress", | ||
}; | ||
|
||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return Arrays.stream(WOOD_VARIANTS) | ||
.<BlockVariant>map(name -> new BlockVariant.Wood("biomemakeover/" + name)) | ||
.toList(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/juuxel/adorn/compat/BlockusCompat.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 juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.List; | ||
|
||
public final class BlockusCompat implements BlockVariantSet { | ||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return List.of(new BlockVariant.Wood("blockus/white_oak")); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
fabric/src/main/java/juuxel/adorn/compat/CinderscapesCompat.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,21 @@ | ||
package juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class CinderscapesCompat implements BlockVariantSet { | ||
private static final String[] WOOD_VARIANTS = { | ||
"scorched", | ||
"umbral", | ||
}; | ||
|
||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return Arrays.stream(WOOD_VARIANTS) | ||
.<BlockVariant>map(name -> new BlockVariant.Wood("cinderscapes/" + name)) | ||
.toList(); | ||
} | ||
} |
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,38 @@ | ||
package juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariantSets; | ||
import juuxel.adorn.config.ConfigManager; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
public final class Compat { | ||
public static void init() { | ||
ifModLoaded("byg", () -> BlockVariantSets.add(new BygCompat())); | ||
ifModLoaded("terrestria", () -> BlockVariantSets.add(new TerrestriaCompat())); | ||
ifModLoaded("towelette", ToweletteCompat::init); | ||
ifModLoaded("traverse", () -> BlockVariantSets.add(new TraverseCompat())); | ||
ifModLoaded("woods_and_mires", () -> BlockVariantSets.add(new WamCompat())); | ||
ifModLoaded("biomemakeover", () -> BlockVariantSets.add(new BiomeMakeoverCompat())); | ||
ifModLoaded("cinderscapes", () -> BlockVariantSets.add(new CinderscapesCompat())); | ||
ifModLoaded("promenade", () -> BlockVariantSets.add(new PromenadeCompat())); | ||
ifModLoaded("techreborn", () -> BlockVariantSets.add(new TechRebornCompat())); | ||
ifModLoaded("blockus", () -> BlockVariantSets.add(new BlockusCompat())); | ||
} | ||
|
||
public static boolean isCompatEnabled(String mod) { | ||
var compatMap = ConfigManager.Companion.config().compat; | ||
|
||
if (!compatMap.containsKey(mod)) { | ||
compatMap.put(mod, true); | ||
ConfigManager.Companion.getINSTANCE().save(); | ||
return true; | ||
} | ||
|
||
return compatMap.get(mod); | ||
} | ||
|
||
private static void ifModLoaded(String mod, Runnable fn) { | ||
if (isCompatEnabled(mod) && FabricLoader.getInstance().isModLoaded(mod)) { | ||
fn.run(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
fabric/src/main/java/juuxel/adorn/compat/PromenadeCompat.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 juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class PromenadeCompat implements BlockVariantSet { | ||
private static final String[] WOOD_VARIANTS = { | ||
"dark_amaranth", | ||
"palm", | ||
"sakura", | ||
}; | ||
|
||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return Arrays.stream(WOOD_VARIANTS) | ||
.<BlockVariant>map(name -> new BlockVariant.Wood("promenade/" + name)) | ||
.toList(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/juuxel/adorn/compat/TechRebornCompat.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 juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.List; | ||
|
||
public final class TechRebornCompat implements BlockVariantSet { | ||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return List.of(new BlockVariant.Wood("techreborn/rubber")); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
fabric/src/main/java/juuxel/adorn/compat/TerrestriaCompat.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,44 @@ | ||
package juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class TerrestriaCompat implements BlockVariantSet { | ||
private static final String[] WOOD_VARIANTS = { | ||
"cypress", | ||
"hemlock", | ||
"japanese_maple", | ||
"rainbow_eucalyptus", | ||
"redwood", | ||
"rubber", | ||
"sakura", | ||
"yucca_palm", | ||
"willow", | ||
}; | ||
|
||
private static final String[] STONE_VARIANTS = { | ||
"basalt", | ||
"basalt_cobblestone", | ||
"smooth_basalt", | ||
"basalt_brick", | ||
"mossy_basalt_cobblestone", | ||
"mossy_basalt_brick", | ||
}; | ||
|
||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return Arrays.stream(WOOD_VARIANTS) | ||
.<BlockVariant>map(name -> new BlockVariant.Wood("terrestria/" + name)) | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public List<BlockVariant> getStoneVariants() { | ||
return Arrays.stream(STONE_VARIANTS) | ||
.<BlockVariant>map(name -> new BlockVariant.Stone("terrestria/" + name)) | ||
.toList(); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
fabric/src/main/java/juuxel/adorn/compat/ToweletteCompat.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,67 @@ | ||
package juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.BenchBlock; | ||
import juuxel.adorn.block.ChairBlock; | ||
import juuxel.adorn.block.ChimneyBlock; | ||
import juuxel.adorn.block.CoffeeTableBlock; | ||
import juuxel.adorn.block.CopperPipeBlock; | ||
import juuxel.adorn.block.PicketFenceBlock; | ||
import juuxel.adorn.block.PlatformBlock; | ||
import juuxel.adorn.block.PostBlock; | ||
import juuxel.adorn.block.PrismarineChimneyBlock; | ||
import juuxel.adorn.block.ShelfBlock; | ||
import juuxel.adorn.block.SofaBlock; | ||
import juuxel.adorn.block.StepBlock; | ||
import juuxel.adorn.block.TableBlock; | ||
import juuxel.adorn.block.TableLampBlock; | ||
import juuxel.adorn.block.TradingStationBlock; | ||
import juuxel.adorn.util.RegistryUtil; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.registry.Registries; | ||
import virtuoel.statement.api.StateRefresher; | ||
import virtuoel.towelette.api.FluidProperties; | ||
import virtuoel.towelette.api.ToweletteConfig; | ||
|
||
public final class ToweletteCompat { | ||
public static void init() { | ||
boolean flowing = isFlowingFluidloggingEnabled(); | ||
|
||
RegistryUtil.visit(Registries.BLOCK, block -> { | ||
if (shouldFluidlog(block)) { | ||
StateRefresher.INSTANCE.addBlockProperty(block, FluidProperties.FLUID, Registries.FLUID.getDefaultId()); | ||
|
||
if (flowing) { | ||
StateRefresher.INSTANCE.addBlockProperty(block, FluidProperties.LEVEL_1_8, 8); | ||
StateRefresher.INSTANCE.addBlockProperty(block, FluidProperties.FALLING, false); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private static boolean isFlowingFluidloggingEnabled() { | ||
var data = ToweletteConfig.DATA.get("flowingFluidlogging"); | ||
if (data != null && data.isJsonPrimitive()) { | ||
return data.getAsBoolean(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private static boolean shouldFluidlog(Block block) { | ||
return block instanceof BenchBlock || | ||
block instanceof ChairBlock || | ||
block instanceof ChimneyBlock || | ||
block instanceof CoffeeTableBlock || | ||
block instanceof CopperPipeBlock || | ||
block instanceof PicketFenceBlock || | ||
block instanceof PlatformBlock || | ||
block instanceof PostBlock || | ||
block instanceof PrismarineChimneyBlock || | ||
block instanceof ShelfBlock || | ||
block instanceof SofaBlock || | ||
block instanceof StepBlock || | ||
block instanceof TableBlock || | ||
block instanceof TableLampBlock || | ||
block instanceof TradingStationBlock; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/juuxel/adorn/compat/TraverseCompat.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 juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.List; | ||
|
||
public final class TraverseCompat implements BlockVariantSet { | ||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return List.of(new BlockVariant.Wood("traverse/fir")); | ||
} | ||
} |
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 juuxel.adorn.compat; | ||
|
||
import juuxel.adorn.block.variant.BlockVariant; | ||
import juuxel.adorn.block.variant.BlockVariantSet; | ||
|
||
import java.util.List; | ||
|
||
public final class WamCompat implements BlockVariantSet { | ||
@Override | ||
public List<BlockVariant> getWoodVariants() { | ||
return List.of(new BlockVariant.Wood("woods_and_mires/pine")); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
fabric/src/main/java/juuxel/adorn/compat/modmenu/AdornModMenuPlugin.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,15 @@ | ||
package juuxel.adorn.compat.modmenu; | ||
|
||
import com.terraformersmc.modmenu.api.ConfigScreenFactory; | ||
import com.terraformersmc.modmenu.api.ModMenuApi; | ||
import juuxel.adorn.client.gui.screen.MainConfigScreen; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public final class AdornModMenuPlugin implements ModMenuApi { | ||
@Override | ||
public ConfigScreenFactory<?> getModConfigScreenFactory() { | ||
return MainConfigScreen::new; | ||
} | ||
} |
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,17 @@ | ||
package juuxel.adorn.util; | ||
|
||
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; | ||
import net.minecraft.registry.Registry; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public final class RegistryUtil { | ||
/** | ||
* Registers a visitor for this registry that will be called for each | ||
* entry currently in the registry, and all future entries. | ||
*/ | ||
public static <A> void visit(Registry<? extends A> registry, Consumer<A> callback) { | ||
registry.forEach(callback); | ||
RegistryEntryAddedCallback.event(registry).register((rawId, id, object) -> callback.accept(object)); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
fabric/src/main/kotlin/juuxel/adorn/compat/BiomeMakeoverCompat.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.