Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some GT items to ExtraBees alveary mutator #2315

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/java/gregtech/integration/forestry/ForestryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import gregtech.api.items.toolitem.ItemGTTool;
import gregtech.api.modules.GregTechModule;
import gregtech.api.recipes.machines.RecipeMapScanner;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.event.MaterialEvent;
import gregtech.api.unification.material.info.MaterialFlags;
import gregtech.api.unification.material.properties.OreProperty;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.common.items.ToolItems;
import gregtech.integration.IntegrationModule;
import gregtech.integration.IntegrationSubmodule;
Expand All @@ -25,6 +27,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
Expand All @@ -41,6 +44,8 @@
import forestry.core.items.IColoredItem;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -160,6 +165,10 @@ public void init(FMLInitializationEvent event) {
}
}

if (Loader.isModLoaded(GTValues.MODID_EB)) {
registerAlvearyMutators();
}

if (event.getSide() == Side.CLIENT) {
if (ForestryUtil.apicultureEnabled()) {
if (ForestryConfig.enableGTBees) {
Expand Down Expand Up @@ -344,4 +353,31 @@ private static void createOreProperty(Material material, Material... byproducts)
material.setProperty(PropertyKey.ORE, property);
material.addFlags(MaterialFlags.DISABLE_ORE_BLOCK);
}

private static void registerAlvearyMutators() {
try {
Class<?> mutationHandler = Class.forName("binnie.extrabees.utils.AlvearyMutationHandler");
Method method = mutationHandler.getDeclaredMethod("addMutationItem", ItemStack.class, float.class);

registerAlvearyMutator(method, Materials.Uranium238, 2.0f);
registerAlvearyMutator(method, Materials.Uranium235, 4.0f);
registerAlvearyMutator(method, Materials.Plutonium241, 6.0f);
registerAlvearyMutator(method, Materials.Plutonium239, 8.0f);
registerAlvearyMutator(method, Materials.NaquadahEnriched, 10.0f);
registerAlvearyMutator(method, Materials.Naquadria, 15.0f);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
IntegrationModule.logger.error("Could not register GT Alveary mutators!");
}
}

private static void registerAlvearyMutator(Method method, Material material, float chance) {
try {
ItemStack stack = OreDictUnifier.get(OrePrefix.dust, material);
if (stack != ItemStack.EMPTY) {
method.invoke(null, stack, chance);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
IntegrationModule.logger.error("Could not register GT Alveary mutators!");
}
}
}