Throw an exception if an addon tries to use our deferred registers
Seriously, don't register stuff in our domain. That explains those crash reports I was getting.
@@ -43,9 +43,17 @@ import java.util.function.Function;
import java.util.function.Supplier;
/**
- * Contains base helpers for all Tinker modules
+ * Contains base helpers for all Tinker modules. Should not be extended by other mods, this is only for internal usage.
*/
public abstract class TinkerModule {
+ protected TinkerModule() {
+ // "seal" this class to prevent other mods from using our deferred registers, basically, prevent anyone from outside our package from instantiating an instance. Yes, it happened
+ // if you are a mod dev and need a protected method here, just copy it, they are all trivial
+ if (!this.getClass().getName().startsWith("slimeknights.tconstruct.")) {
+ throw new IllegalStateException("TinkerModule being extended from invalid package " + this.getClass().getName() + ". This is a bug with the mod containing that class, they should create their own deferred registers.");
+ }
+ }
+
// deferred register instances
protected static final BlockDeferredRegisterExtension BLOCKS = new BlockDeferredRegisterExtension(TConstruct.MOD_ID);
protected static final ItemDeferredRegisterExtension ITEMS = new ItemDeferredRegisterExtension(TConstruct.MOD_ID);
