Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1846ab8
mixins & api for using forge registries
gustovafing Jul 20, 2026
04c6eae
a
gustovafing Aug 5, 2026
13fa1f7
pattern errors and placeholders
gustovafing Jul 20, 2026
fc10abf
medical conditions, dimension markers & sounds
gustovafing Jul 20, 2026
81013ad
machines
gustovafing Jul 20, 2026
ffc60ed
world gen layers & covers
gustovafing Jul 20, 2026
5f3df39
recipe stuff
gustovafing Jul 20, 2026
657cf9b
elements, tag prefixes and material icons
gustovafing Jul 20, 2026
cec42d6
material registries
gustovafing Jul 20, 2026
9c13e70
tests pass
gustovafing Jul 20, 2026
293e2a5
a
gustovafing Aug 5, 2026
ade8442
fix sounds
gustovafing Jul 20, 2026
ff0b065
fix kjs machine registration
gustovafing Jul 21, 2026
0b2f13c
update kjs material builder
gustovafing Jul 21, 2026
5c5fc6e
remove unnecessary machine builders
gustovafing Jul 21, 2026
e731096
fix registry type wrapper
gustovafing Jul 21, 2026
ed83fa3
fix event
gustovafing Jul 21, 2026
9764cb6
some fixes
gustovafing Jul 21, 2026
76cb4bb
dimension marker builder
gustovafing Jul 21, 2026
f32b0fe
more fixes
gustovafing Jul 21, 2026
cfe6e28
spotless
gustovafing Jul 21, 2026
bd08c04
resource location and sloppa fixes
gustovafing Jul 21, 2026
fdd91a6
spotless
gustovafing Jul 21, 2026
0834be5
add registry access to sync context
gustovafing Jul 22, 2026
3cfa70a
warn if resource location is corrected
gustovafing Jul 22, 2026
747d06b
spotless
gustovafing Jul 22, 2026
b01e7c7
change placeholder registry uses to reg lookup
gustovafing Jul 23, 2026
9b94751
update cmd error lang
gustovafing Jul 23, 2026
0022ceb
spotless
gustovafing Jul 23, 2026
739c1e5
spotless
gustovafing Jul 27, 2026
84e97aa
fix build error
gustovafing Jul 30, 2026
e0b10b6
fix placeholder list
gustovafing Aug 1, 2026
086b7b5
update deprecations
gustovafing Aug 3, 2026
6f36752
fix uppercase ids being used in reslocs
gustovafing Aug 3, 2026
2ee78d4
spotless
gustovafing Aug 4, 2026
616aff9
a
gustovafing Aug 4, 2026
940d96c
Update src/main/java/com/gregtechceu/gtceu/api/sync_system/managed/Ma…
gustovafing Aug 4, 2026
28ad214
Apply suggestions from code review
gustovafing Aug 4, 2026
bbba1f0
fix recipe type registration
gustovafing Aug 4, 2026
cfc353e
fix build errors
gustovafing Aug 4, 2026
d888f88
Update GregTechKubeJSPlugin.java
gustovafing Aug 4, 2026
6ad0ad1
fix some kjs stuff
gustovafing Aug 5, 2026
83ec66d
remove menu types
gustovafing Aug 5, 2026
551dc1b
oops
gustovafing Aug 5, 2026
427c469
actually fix it
gustovafing Aug 5, 2026
329165f
fix load order
gustovafing Aug 5, 2026
527d798
fix accidental id change
gustovafing Aug 5, 2026
b0db49b
tests actually pass now
gustovafing Aug 5, 2026
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
12 changes: 12 additions & 0 deletions src/main/java/com/gregtechceu/gtceu/GTCEu.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.server.ServerLifecycleHooks;

import com.mojang.serialization.Codec;
import dev.emi.emi.config.EmiConfig;
import me.shedaniel.rei.api.client.REIRuntime;
import org.apache.logging.log4j.LogManager;
Expand All @@ -29,6 +30,10 @@ public class GTCEu {

public static final String MOD_ID = "gtceu";
private static final ResourceLocation TEMPLATE_LOCATION = new ResourceLocation(MOD_ID, "");
public static final Codec<ResourceLocation> GTCEU_ID = Codec.STRING.comapFlatMap(
str -> ResourceLocation.read(appendIdString(str)),
s -> s.getNamespace().equals(MOD_ID) ? s.getPath() : s.toString());
Comment thread
gustovafing marked this conversation as resolved.

public static final String NAME = "GregTechCEu";
public static final Logger LOGGER = LogManager.getLogger(NAME);

Expand Down Expand Up @@ -57,6 +62,9 @@ public static ResourceLocation id(String path) {
}
// only convert it to camel_case if it has any uppercase to begin with
if (FormattingUtil.hasUpperCase(path)) {
GTCEu.LOGGER.warn(
"Resource location {} has uppercase characters, which are not allowed. Renaming resource location to {}",
path, FormattingUtil.toLowerCaseUnderscore(path));
path = FormattingUtil.toLowerCaseUnderscore(path);
}
return TEMPLATE_LOCATION.withPath(path);
Expand Down Expand Up @@ -156,6 +164,10 @@ public static Path getGameDir() {

public static class Mods {

public static boolean isJadeLoaded() {
return isModLoaded(GTValues.MODID_JADE);
}

public static boolean isJEILoaded() {
return !(isModLoaded(GTValues.MODID_EMI) || isModLoaded(GTValues.MODID_REI)) &&
isModLoaded(GTValues.MODID_JEI);
Expand Down
40 changes: 23 additions & 17 deletions src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@
import com.gregtechceu.gtceu.api.block.ICoilType;
import com.gregtechceu.gtceu.api.block.IFilterType;
import com.gregtechceu.gtceu.api.machine.multiblock.IBatteryData;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.api.registry.GTRegistry;
import com.gregtechceu.gtceu.common.block.BatteryBlock;
import com.gregtechceu.gtceu.common.block.CoilBlock;
import com.gregtechceu.gtceu.config.ConfigHolder;

import net.minecraft.core.MappedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.eventbus.api.GenericEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.IModBusEvent;

import lombok.Getter;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -51,31 +56,32 @@ public static void initializeHighTier() {
else GTCEu.LOGGER.info("High-Tier is Disabled.");
}

/**
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@SuppressWarnings("unused")
@Deprecated(forRemoval = true, since = "8.0.0")
public static class RegisterEvent<K, V> extends GenericEvent<V> implements IModBusEvent {
Comment thread
gustovafing marked this conversation as resolved.

private final GTRegistry<K, V> registry;
private final @Nullable GTRegistry<ResourceLocation, V> registry;
private final @Nullable Registry<V> mcRegistry;

public RegisterEvent(GTRegistry<K, V> registry, Class<V> clazz) {
public RegisterEvent(MappedRegistry<V> registry, Class<V> clazz) {
super(clazz);
this.registry = registry;
}

public void register(K key, V value) {
if (registry != null) registry.register(key, value);
this.registry = null;
this.mcRegistry = registry;
}

public static class RL<V> extends RegisterEvent<ResourceLocation, V> {

public RL(GTRegistry<ResourceLocation, V> registry, Class<V> clazz) {
super(registry, clazz);
}
public RegisterEvent(GTRegistry<ResourceLocation, V> registry, Class<V> clazz) {
super(clazz);
this.registry = registry;
this.mcRegistry = null;
}

public static class String<V> extends RegisterEvent<java.lang.String, V> {

public String(GTRegistry<java.lang.String, V> registry, Class<V> clazz) {
super(registry, clazz);
}
public void register(ResourceLocation key, V value) {
if (registry != null) registry.register(key, value);
if (mcRegistry != null) GTRegistries.register(mcRegistry, key, value);
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public static int[] tiersBetween(int minInclusive, int maxInclusive) {
.toArray();
}

public static final String MODID_JEI = "jei",
public static final String MODID_JADE = "jade",
MODID_JEI = "jei",
MODID_REI = "roughlyenoughitems",
MODID_EMI = "emi",
MODID_APPENG = "ae2",
Expand Down
34 changes: 13 additions & 21 deletions src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.eventbus.api.IEventBus;

import java.util.function.Consumer;

Expand All @@ -33,52 +34,43 @@ public interface IGTAddon {
String addonModId();

/**
* Call init on your custom TagPrefix class(es) here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, TagPrefix>} register event instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerTagPrefixes() {}

/**
* Call init on your custom Element class(es) here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, Element>} register event instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerElements() {}

/**
* Call init on your custom Sound class(es) here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, SoundEntry>} register event instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerSounds() {}

/**
* Call init on your custom Cover class(es) here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, CoverDefinition>} register event
* instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerCovers() {}

/**
* Call init on your custom Recipe Capabilities here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, RecipeCapability>} register event
* instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerRecipeCapabilities() {}

/**
* Call init on your custom IWorldGenLayer class(es) here
*
* @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent<ResourceLocation, IWorldGenLayer>} register event
* instead
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
default void registerWorldgenLayers() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public abstract class RecipeCapability<T> {

public static final Codec<RecipeCapability<?>> DIRECT_CODEC = GTRegistries.RECIPE_CAPABILITIES.codec();
public static final Codec<RecipeCapability<?>> DIRECT_CODEC = GTRegistries.RECIPE_CAPABILITIES.byNameCodec();
public static final Codec<Map<RecipeCapability<?>, List<Content>>> CODEC = new DispatchedMapCodec<>(
RecipeCapability.DIRECT_CODEC,
RecipeCapability::contentCodec);
Expand Down
31 changes: 13 additions & 18 deletions src/main/java/com/gregtechceu/gtceu/api/data/DimensionMarker.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.gregtechceu.gtceu.api.data;

import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase;
import com.gregtechceu.gtceu.integration.kjs.Validator;
import com.gregtechceu.gtceu.utils.memoization.GTMemoizer;
import com.gregtechceu.gtceu.utils.memoization.MemoizedSupplier;

Expand All @@ -14,12 +12,13 @@
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.registries.ForgeRegistries;

import dev.latvian.mods.rhino.util.HideFromJS;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;
import java.util.function.Supplier;

public class DimensionMarker {
Expand Down Expand Up @@ -58,7 +57,7 @@ public void register(ResourceLocation dimKey) {
if (tier < 0 || tier >= MAX_TIER) {
throw new IllegalArgumentException("Tier must be between 0 and " + (MAX_TIER - 1));
}
GTRegistries.DIMENSION_MARKERS.register(dimKey, this);
GTRegistries.register(GTRegistries.DIMENSION_MARKERS, dimKey, this);
}

private ItemStack getStack(Item item) {
Expand All @@ -69,37 +68,33 @@ private ItemStack getStack(Item item) {
return stack;
}

@Setter
@Accessors(fluent = true, chain = true)
public static class Builder extends BuilderBase<DimensionMarker> {
Comment thread
gustovafing marked this conversation as resolved.
public static class Builder {

private final ResourceLocation id;
@Setter
private Supplier<Item> iconSupplier;
@Setter
private int tier = 0;
@Nullable
@Setter
private String overrideName;

public Builder(ResourceLocation dimKey) {
super(dimKey);
id = dimKey;
}

public Builder(ResourceLocation dimKey, Object... args) {
this(dimKey);
}

@HideFromJS
public DimensionMarker buildAndRegister() {
Validator.validate(
id,
Validator.errorIfNull(iconSupplier, "icon"),
Validator.errorIfOutOfRange(tier, "tier", 0, MAX_TIER - 1));
Objects.requireNonNull(id);
Objects.requireNonNull(iconSupplier, "iconSupplier cannot be null;");
Preconditions.checkArgument(tier > 0 && tier < MAX_TIER, "Tier must be between 0 and " + MAX_TIER);
DimensionMarker marker = new DimensionMarker(tier, iconSupplier, overrideName);
marker.register(id);
return marker;
}

@Override
public DimensionMarker register() {
return value = buildAndRegister();
return buildAndRegister();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys;
import com.gregtechceu.gtceu.api.item.tool.MaterialToolTier;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.common.data.GTMedicalConditions;
import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper;
Expand All @@ -34,7 +33,6 @@

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import dev.latvian.mods.rhino.util.HideFromJS;
import dev.latvian.mods.rhino.util.RemapPrefixForJS;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
Expand Down Expand Up @@ -150,7 +148,7 @@ protected Material(ResourceLocation resourceLocation) {
}

protected void registerMaterial() {
GTRegistries.MATERIALS.register(getResourceLocation(), this);
GTRegistries.register(GTRegistries.MATERIALS, getResourceLocation(), this);
}

public String getName() {
Expand Down Expand Up @@ -574,8 +572,9 @@ public boolean isNull() {

@RemapPrefixForJS("kjs$")
@SuppressWarnings("unused") // API, need to treat all of these as used
public static class Builder extends BuilderBase<Material> {
public static class Builder {

public final ResourceLocation id;
private final MaterialInfo materialInfo;
private final MaterialProperties properties;
private final MaterialFlags flags;
Expand Down Expand Up @@ -609,7 +608,7 @@ public static class Builder extends BuilderBase<Material> {
* @since GTCEu 2.0.0
*/
public Builder(ResourceLocation resourceLocation) {
super(resourceLocation);
id = resourceLocation;
String name = resourceLocation.getPath();
if (name.charAt(name.length() - 1) == '_')
throw new IllegalArgumentException("Material name cannot end with a '_'!");
Expand Down Expand Up @@ -1851,8 +1850,14 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) {
*
* @return The finalized Material.
*/
@HideFromJS
public Material buildAndRegister() {
var mat = createEntry();
mat.registerMaterial();
return mat;
}

@ApiStatus.Internal
public Material createEntry() {
materialInfo.componentList = composition.isEmpty() && this.compositionSupplier != null ?
ImmutableList.copyOf(compositionSupplier.stream().map(MaterialStackWrapper::toMatStack)
.toArray(MaterialStack[]::new)) :
Expand All @@ -1879,17 +1884,14 @@ public Material buildAndRegister() {
mat.setFormula(formula, formatFormula);
}
materialInfo.verifyInfo(properties, averageRGB);
mat.registerMaterial();
if (ignoredTagPrefixes != null) {
ignoredTagPrefixes.forEach(p -> p.setIgnored(mat));
}
return mat;
}

@Override
@HideFromJS
public @NotNull Material register() {
Comment thread
gustovafing marked this conversation as resolved.
return value = buildAndRegister();
return buildAndRegister();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.gregtechceu.gtceu.api.data.chemical.material.event;

import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.IModBusEvent;

/**
* Event to register and modify materials in
* <br>
* Material events are fired on the MOD bus as the forge bus isn't active until all mods have loaded.
* @deprecated Your mod content classes should be loaded on startup instead, in your mod's main init files (e.g.
* {@link com.gregtechceu.gtceu.common.CommonProxy#init(IEventBus)}
*/
@Deprecated(forRemoval = true, since = "8.0.0")
public class MaterialEvent extends Event implements IModBusEvent {

public MaterialEvent() {
Expand Down
Loading
Loading