mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Tests do not run yet. Things of note: Removed the idea of substitutions, just register multiple items with the same name they will override each other like a normal map. Decoupled Forge registries from vanilla classes. They now use bouncer classes. MODDERS SHOULD NEVER USE THESE Introduced more stringent registry locking. As it sits things are only allowed to be registered during the RegistryEvent.Registry phases! This is to force modders to split up their registrations, and pave the way for calling these functions multiple times during a single MC lifecycle. ObjectHolder, Missing Mappings, etc... *should* now work for all registry types, nothing should be special cased to Blocks/Items anymore. Added optional generic dummy factory to registries, to allow registry creators the ability to dummy more then just Blocks. Re-worked the ItemStack transformer and applied it to ItemBlock and ItemBlockSpecial. Allowing us to cleanup reflective hacks in Block callbacks. Registry onAdd callback is now only fired on the ACTIVE registry, fixing any issues of temp registries overriding active objects.
49 lines
1.1 KiB
Java
49 lines
1.1 KiB
Java
package net.minecraftforge.registries;
|
|
|
|
import com.google.common.base.Objects;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
/*
|
|
* This is the internal implementation class of the delegate.
|
|
*/
|
|
final class RegistryDelegate<T> implements IRegistryDelegate<T>
|
|
{
|
|
private T referent;
|
|
private ResourceLocation name;
|
|
private final Class<T> type;
|
|
|
|
public RegistryDelegate(T referent, Class<T> type)
|
|
{
|
|
this.referent = referent;
|
|
this.type = type;
|
|
}
|
|
|
|
@Override
|
|
public T get() { return referent; }
|
|
@Override
|
|
public ResourceLocation name() { return name; }
|
|
@Override
|
|
public Class<T> type() { return this.type; }
|
|
|
|
void changeReference(T newTarget){ this.referent = newTarget; }
|
|
public void setName(ResourceLocation name) { this.name = name; }
|
|
|
|
@Override
|
|
public boolean equals(Object obj)
|
|
{
|
|
if (obj instanceof RegistryDelegate)
|
|
{
|
|
RegistryDelegate<?> other = (RegistryDelegate<?>) obj;
|
|
return Objects.equal(other.name, name);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode()
|
|
{
|
|
return Objects.hashCode(name);
|
|
}
|
|
}
|