Skip to content

Commit

Permalink
Refactor other mod id handling (GregTechCEu#2354)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Jan 31, 2024
1 parent 47544f6 commit 826d589
Show file tree
Hide file tree
Showing 68 changed files with 731 additions and 525 deletions.
12 changes: 9 additions & 3 deletions src/main/java/gregtech/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.oredict.OreDictionary;

import org.jetbrains.annotations.ApiStatus;

import java.time.LocalDate;
import java.util.Random;
import java.util.function.Supplier;
Expand Down Expand Up @@ -120,10 +122,14 @@ public class GTValues {
"Overpowered Voltage", "Maximum Voltage" };

/**
* ModID strings, since they are quite common parameters
* GregTech Mod ID
*/
public static final String MODID = "gregtech",
MODID_FR = "forestry",
public static final String MODID = "gregtech";

/** @deprecated Use {@link gregtech.api.util.Mods} instead */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.9")
public static final String MODID_FR = "forestry",
MODID_CT = "crafttweaker",
MODID_TOP = "theoneprobe",
MODID_CTM = "ctm",
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/gregtech/api/block/VariantActiveBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gregtech.api.block;

import gregtech.api.GTValues;
import gregtech.api.util.Mods;
import gregtech.client.model.ActiveVariantBlockBakedModel;
import gregtech.client.utils.BloomEffectUtil;
import gregtech.common.ConfigHolder;
Expand All @@ -22,7 +22,6 @@
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -135,7 +134,7 @@ public IExtendedBlockState getExtendedState(@NotNull IBlockState state, @NotNull
.withProperty(ACTIVE, Minecraft.getMinecraft().world != null &&
isBlockActive(Minecraft.getMinecraft().world.provider.getDimension(), pos));

if (Loader.isModLoaded(GTValues.MODID_CTM)) {
if (Mods.CTM.isModLoaded()) {
// if the Connected Textures Mod is loaded we wrap our IExtendedBlockState with their wrapper,
// so that the CTM renderer can render the block properly.
return new CTMExtendedState(ext, world, pos);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gregtech.api.block.machines;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.api.block.BlockCustomParticle;
import gregtech.api.block.UnlistedIntegerProperty;
Expand All @@ -15,6 +14,7 @@
import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
import gregtech.api.pipenet.IBlockAppearance;
import gregtech.api.util.GTUtility;
import gregtech.api.util.Mods;
import gregtech.client.renderer.handler.MetaTileEntityRenderer;
import gregtech.common.creativetab.GTCreativeTabs;
import gregtech.common.items.MetaItems;
Expand Down Expand Up @@ -56,7 +56,6 @@
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -282,7 +281,7 @@ public void onBlockPlacedBy(World worldIn, @NotNull BlockPos pos, @NotNull IBloc
}
}
}
if (Loader.isModLoaded(GTValues.MODID_APPENG)) {
if (Mods.AppliedEnergistics2.isModLoaded()) {
if (metaTileEntity.getProxy() != null) {
metaTileEntity.getProxy().setOwner((EntityPlayer) placer);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/gregtech/api/fluids/FluidBuilder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gregtech.api.fluids;

import gregtech.api.GTValues;
import gregtech.api.fluids.attribute.AttributedFluid;
import gregtech.api.fluids.attribute.FluidAttribute;
import gregtech.api.fluids.store.FluidStorageKey;
Expand All @@ -12,13 +11,13 @@
import gregtech.api.util.FluidTooltipUtil;
import gregtech.api.util.GTLog;
import gregtech.api.util.GTUtility;
import gregtech.api.util.Mods;

import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Loader;

import com.google.common.base.Preconditions;
import io.github.drmanganese.topaddons.reference.Colors;
Expand Down Expand Up @@ -380,7 +379,7 @@ private static int convertViscosity(double viscosity) {
}

// register cross mod compat for colors
if (Loader.isModLoaded(GTValues.MODID_TOP_ADDONS)) {
if (Mods.TOPAddons.isModLoaded()) {
int displayColor = isColorEnabled || material == null ? color : material.getMaterialRGB();
Colors.FLUID_NAME_COLOR_MAP.put(name, displayColor);
}
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/gregtech/api/gui/widgets/SortingButtonWidget.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package gregtech.api.gui.widgets;

import gregtech.api.util.Mods;

import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.common.Loader;

import java.util.function.Consumer;

public class SortingButtonWidget extends ClickButtonWidget {

private static boolean inventoryTweaksChecked;
private static boolean inventoryTweaksPresent;
private static KeyBinding sortKeyBinding;

public SortingButtonWidget(int xPosition, int yPosition, int width, int height, String displayText,
Expand Down Expand Up @@ -43,13 +42,10 @@ public boolean keyTyped(char charTyped, int keyCode) {
}

private static int getInvTweaksSortCode() {
if (!inventoryTweaksChecked) {
inventoryTweaksChecked = true;
inventoryTweaksPresent = Loader.isModLoaded("inventorytweaks");
}
if (!inventoryTweaksPresent) {
if (!Mods.InventoryTweaks.isModLoaded()) {
return 0;
}

try {
if (sortKeyBinding == null) {
Class<?> proxyClass = Class.forName("invtweaks.forge.ClientProxy");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/items/metaitem/ElectricStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gregtech.api.capability.IElectricItem;
import gregtech.api.capability.impl.ElectricItem;
import gregtech.api.items.metaitem.stats.*;
import gregtech.api.util.Mods;
import gregtech.common.ConfigHolder;
import gregtech.integration.baubles.BaublesModule;

Expand All @@ -25,7 +26,6 @@
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.common.Loader;

import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void onUpdate(ItemStack itemStack, Entity entity) {
IInventory inventoryPlayer = entityPlayer.inventory;
long transferLimit = electricItem.getTransferLimit();

if (Loader.isModLoaded(GTValues.MODID_BAUBLES)) {
if (Mods.Baubles.isModLoaded()) {
inventoryPlayer = BaublesModule.getBaublesWrappedInventory(entityPlayer);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/gregtech/api/items/metaitem/MetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import gregtech.api.unification.stack.ItemMaterialInfo;
import gregtech.api.util.GTUtility;
import gregtech.api.util.LocalizationUtils;
import gregtech.api.util.Mods;
import gregtech.client.utils.ToolChargeBarRenderer;
import gregtech.common.ConfigHolder;
import gregtech.common.creativetab.GTCreativeTabs;
Expand Down Expand Up @@ -110,7 +111,9 @@
* {@code addItem(0, "test_item").addStats(new ElectricStats(10000, 1, false)) } This will add single-use (not
* rechargeable) LV battery with initial capacity 10000 EU
*/
@Optional.Interface(modid = GTValues.MODID_ECORE, iface = "com.enderio.core.common.interfaces.IOverlayRenderAware")
@Optional.Interface(
modid = Mods.Names.ENDER_CORE,
iface = "com.enderio.core.common.interfaces.IOverlayRenderAware")
public abstract class MetaItem<T extends MetaItem<?>.MetaValueItem> extends Item
implements ItemUIFactory, IOverlayRenderAware {

Expand Down
24 changes: 16 additions & 8 deletions src/main/java/gregtech/api/items/toolitem/IGTTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.api.util.GTUtility;
import gregtech.api.util.Mods;
import gregtech.api.util.TextFormattingUtil;
import gregtech.client.utils.ToolChargeBarRenderer;
import gregtech.client.utils.TooltipHelper;
Expand Down Expand Up @@ -89,14 +90,21 @@
* Backing of every variation of a GT Tool
*/
@Optional.InterfaceList({
@Optional.Interface(modid = GTValues.MODID_APPENG, iface = "appeng.api.implementations.items.IAEWrench"),
@Optional.Interface(modid = GTValues.MODID_BC, iface = "buildcraft.api.tools.IToolWrench"),
@Optional.Interface(modid = GTValues.MODID_COFH, iface = "cofh.api.item.IToolHammer"),
@Optional.Interface(modid = GTValues.MODID_EIO, iface = "crazypants.enderio.api.tool.ITool"),
@Optional.Interface(modid = GTValues.MODID_FR, iface = "forestry.api.arboriculture.IToolGrafter"),
@Optional.Interface(modid = GTValues.MODID_PROJRED_CORE, iface = "mrtjp.projectred.api.IScrewdriver"),
@Optional.Interface(modid = GTValues.MODID_RC, iface = "mods.railcraft.api.items.IToolCrowbar"),
@Optional.Interface(modid = GTValues.MODID_ECORE,
@Optional.Interface(modid = Mods.Names.APPLIED_ENERGISTICS2,
iface = "appeng.api.implementations.items.IAEWrench"),
@Optional.Interface(modid = Mods.Names.BUILD_CRAFT_CORE,
iface = "buildcraft.api.tools.IToolWrench"),
@Optional.Interface(modid = Mods.Names.COFH_CORE,
iface = "cofh.api.item.IToolHammer"),
@Optional.Interface(modid = Mods.Names.ENDER_IO,
iface = "crazypants.enderio.api.tool.ITool"),
@Optional.Interface(modid = Mods.Names.FORESTRY,
iface = "forestry.api.arboriculture.IToolGrafter"),
@Optional.Interface(modid = Mods.Names.PROJECT_RED_CORE,
iface = "mrtjp.projectred.api.IScrewdriver"),
@Optional.Interface(modid = Mods.Names.RAILCRAFT,
iface = "mods.railcraft.api.items.IToolCrowbar"),
@Optional.Interface(modid = Mods.Names.ENDER_CORE,
iface = "com.enderio.core.common.interfaces.IOverlayRenderAware") })
public interface IGTTool extends ItemUIFactory, IAEWrench, IToolWrench, IToolHammer, ITool, IToolGrafter,
IOverlayRenderAware, IScrewdriver, IToolCrowbar {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import gregtech.api.util.GTLog;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.GTUtility;
import gregtech.api.util.Mods;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.BloomEffectUtil;
import gregtech.common.ConfigHolder;
Expand Down Expand Up @@ -1547,17 +1548,17 @@ public boolean canVoidRecipeFluidOutputs() {
}

@NotNull
@Method(modid = GTValues.MODID_APPENG)
@Method(modid = Mods.Names.APPLIED_ENERGISTICS2)
public AECableType getCableConnectionType(@NotNull AEPartLocation part) {
return AECableType.NONE;
}

@Nullable
@Method(modid = GTValues.MODID_APPENG)
@Method(modid = Mods.Names.APPLIED_ENERGISTICS2)
public AENetworkProxy getProxy() {
return null;
}

@Method(modid = GTValues.MODID_APPENG)
@Method(modid = Mods.Names.APPLIED_ENERGISTICS2)
public void gridChanged() {}
}
Loading

0 comments on commit 826d589

Please sign in to comment.