Skip to content

Commit

Permalink
fix: fix Primordial Cradle consuming Tetra tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Sep 8, 2023
1 parent 67383e4 commit 9ee49e4
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ dependencies {
implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}")

// runtimeOnly fg.deobf("curse.maven:farmers_delight-398521:4525646") //1.2.1
// runtimeOnly fg.deobf("curse.maven:cultural_delights-574622:4000179")
// runtimeOnly fg.deobf("curse.maven:cultural_delights-574622:4000179")

runtimeOnly fg.deobf("curse.maven:alexs_mobs-426558:4159154") //1.21.1
runtimeOnly fg.deobf("curse.maven:citadel-331936:4132623")
Expand All @@ -227,6 +227,9 @@ dependencies {
compileOnly fg.deobf("maven.modrinth:pehkui:3.6.2+1.19.2-forge") // 3.6.2+1.19.2-forge
//needs to be compileOnly for datagen to work -> temporarily change to implementation for gameplay testing

// implementation fg.deobf("se.mickelus.mutil:mutil:1.19.2-5.1.0")
compileOnly fg.deobf("curse.maven:tetra-289712:4738567") // 1.19.2-5.5.0

//TODO: Morph Mod Integration?
// implementation fg.deobf("curse.maven:identity-391390:3807264") // https://www.curseforge.com/minecraft/mc-mods/identity
// runtimeOnly fg.deobf("curse.maven:architectury-419699:4040966")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.elenterius.biomancy.init.ModItems;
import com.github.elenterius.biomancy.init.ModSoundEvents;
import com.github.elenterius.biomancy.init.ModTriggers;
import com.github.elenterius.biomancy.integration.ModsCompatHandler;
import com.github.elenterius.biomancy.util.SoundUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class PrimordialCradleBlock extends HorizontalDirectionalBlock implements
if (item instanceof BlockItem blockItem && (blockItem.getBlock() instanceof ShulkerBoxBlock || blockItem.getBlock() instanceof FleshkinChestBlock))
return true;

//TODO: handle Tetra Tools & add Dragon Sinew to Tributes
if (ModsCompatHandler.getTetraHelper().isToolOrModularItem(item)) return true;

return item instanceof TieredItem || item instanceof Vanishable || stack.isEnchanted();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.github.elenterius.biomancy.integration.modonomicon.ModonomiconIntegration;
import com.github.elenterius.biomancy.integration.pehkui.IPehkuiHelper;
import com.github.elenterius.biomancy.integration.pehkui.PehkuiCompat;
import com.github.elenterius.biomancy.integration.tetra.TetraCompat;
import com.github.elenterius.biomancy.integration.tetra.TetraHelper;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand All @@ -20,6 +22,7 @@ public final class ModsCompatHandler {
static final Marker LOG_MARKER = MarkerManager.getMarker(ModsCompatHandler.class.getSimpleName());
static IPehkuiHelper PEHKUI_HELPER = IPehkuiHelper.EMPTY;
static IModonomiconHelper MODONOMICON_HELPER = IModonomiconHelper.EMPTY;
static TetraHelper TETRA_HELPER = TetraHelper.EMPTY;

private ModsCompatHandler() {}

Expand All @@ -33,6 +36,11 @@ public static void onBiomancyInit(final IEventBus eventBus) {
BiomancyMod.LOGGER.info(LOG_MARKER, "Initialize Modonomicon integration...");
ModonomiconIntegration.init(helper -> MODONOMICON_HELPER = helper);
}

if (ModList.get().isLoaded("tetra")) {
BiomancyMod.LOGGER.info(LOG_MARKER, "Initialize Modonomicon integration...");
TetraCompat.init(helper -> TETRA_HELPER = helper);
}
}

public static void onBiomancyCommonSetup(final FMLCommonSetupEvent event) {
Expand All @@ -55,6 +63,11 @@ public static void onBiomancyCommonSetup(final FMLCommonSetupEvent event) {
BiomancyMod.LOGGER.warn(LOG_MARKER, "Found outdated version of Create (< 0.5.1). Skipping compatibility setup for Create!");
}
}

if (ModList.get().isLoaded("tetra")) {
BiomancyMod.LOGGER.info(LOG_MARKER, "Setup Tetra compat...");
TetraCompat.onPostSetup();
}
});
}

Expand All @@ -69,10 +82,10 @@ private static int parseVersionNumber(String s) {

public static void onBiomancyClientSetup(final FMLClientSetupEvent event) {
// event.enqueueWork(() -> {
// if (ModList.get().isLoaded("jeresources")) {
// BiomancyMod.LOGGER.info(LOG_MARKER, "setup JER plugin...");
// BiomancyJerPlugin.onClientPostSetup();
// }
// if (ModList.get().isLoaded("jeresources")) {
// BiomancyMod.LOGGER.info(LOG_MARKER, "setup JER plugin...");
// BiomancyJerPlugin.onClientPostSetup();
// }
// });
}

Expand All @@ -84,4 +97,8 @@ public static IModonomiconHelper getModonomiconHelper() {
return MODONOMICON_HELPER;
}

public static TetraHelper getTetraHelper() {
return TETRA_HELPER;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.elenterius.biomancy.integration.tetra;

import net.minecraft.world.item.Item;
import se.mickelus.tetra.items.modular.IModularItem;
import se.mickelus.tetra.properties.IToolProvider;

import java.util.function.Consumer;

public final class TetraCompat {
private TetraCompat() {}

public static void init(Consumer<TetraHelper> helperSetter) {
helperSetter.accept(new TetraCompat.TetraHelperImpl());
}

public static void onPostSetup() {
//TODO: register Dragon Sinew as Primordial Cradle tribute
}

static final class TetraHelperImpl implements TetraHelper {
@Override
public boolean isToolOrModularItem(Item item) {
return item instanceof IModularItem || item instanceof IToolProvider;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.elenterius.biomancy.integration.tetra;

import net.minecraft.world.item.Item;

public sealed interface TetraHelper permits TetraCompat.TetraHelperImpl, TetraHelper.EmptyTetraHelper {

TetraHelper EMPTY = new TetraHelper.EmptyTetraHelper();

boolean isToolOrModularItem(Item item);

final class EmptyTetraHelper implements TetraHelper {
@Override
public boolean isToolOrModularItem(Item item) {
return false;
}
}

}

0 comments on commit 9ee49e4

Please sign in to comment.