DimensionManager.registerDimension now returns the DimensionType instance for convienance.
You can still access others in DimensionType.getByName() Fixed ForgeRegistry rappers not forwarding isEmpty.
This commit is contained in:
parent
3003e33074
commit
47e6b34d2b
5 changed files with 23 additions and 2 deletions
|
@ -87,7 +87,7 @@ public class DimensionManager
|
||||||
* @param type Dimension Type.
|
* @param type Dimension Type.
|
||||||
* @param data Configuration data for this dimension, passed into
|
* @param data Configuration data for this dimension, passed into
|
||||||
*/
|
*/
|
||||||
public static void registerDimension(ResourceLocation name, ModDimension type, PacketBuffer data)
|
public static DimensionType registerDimension(ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||||
{
|
{
|
||||||
Validate.notNull(name, "Can not register a dimesnion with null name");
|
Validate.notNull(name, "Can not register a dimesnion with null name");
|
||||||
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
Validate.isTrue(!REGISTRY.func_212607_c(name), "Dimension: " + name + " Already registered");
|
||||||
|
@ -105,6 +105,7 @@ public class DimensionManager
|
||||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||||
REGISTRY.register(id, name, instance);
|
REGISTRY.register(id, name, instance);
|
||||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +171,7 @@ public class DimensionManager
|
||||||
dimensions.remove(id);
|
dimensions.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerDimensionInternal(int id, ResourceLocation name, ModDimension type, PacketBuffer data)
|
public static DimensionType registerDimensionInternal(int id, ResourceLocation name, ModDimension type, PacketBuffer data)
|
||||||
{
|
{
|
||||||
Validate.notNull(name, "Can not register a dimesnion with null name");
|
Validate.notNull(name, "Can not register a dimesnion with null name");
|
||||||
Validate.notNull(type, "Can not register a null dimension type");
|
Validate.notNull(type, "Can not register a null dimension type");
|
||||||
|
@ -180,6 +181,7 @@ public class DimensionManager
|
||||||
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
DimensionType instance = new DimensionType(id, "", name.getNamespace() + "/" + name.getPath(), type.getFactory(), type, data);
|
||||||
REGISTRY.register(id, name, instance);
|
REGISTRY.register(id, name, instance);
|
||||||
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
LOGGER.info(DIMMGR, "Registered dimension {} of type {} and id {}", name.toString(), type.getRegistryName().toString(), id);
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
|
|
@ -190,6 +190,12 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||||
return this.names.containsValue(value);
|
return this.names.containsValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return this.names.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V getValue(ResourceLocation key)
|
public V getValue(ResourceLocation key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
|
||||||
|
|
||||||
boolean containsKey(ResourceLocation key);
|
boolean containsKey(ResourceLocation key);
|
||||||
boolean containsValue(V value);
|
boolean containsValue(V value);
|
||||||
|
boolean isEmpty();
|
||||||
|
|
||||||
@Nullable V getValue(ResourceLocation key);
|
@Nullable V getValue(ResourceLocation key);
|
||||||
@Nullable ResourceLocation getKey(V value);
|
@Nullable ResourceLocation getKey(V value);
|
||||||
|
|
|
@ -133,6 +133,12 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||||
return this.delegate.getDefaultKey();
|
return this.delegate.getDefaultKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return this.delegate.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
//internal
|
//internal
|
||||||
@Override
|
@Override
|
||||||
public void lock(){ this.locked = true; }
|
public void lock(){ this.locked = true; }
|
||||||
|
|
|
@ -121,6 +121,12 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
|
||||||
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
|
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return this.delegate.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
//internal
|
//internal
|
||||||
@Override
|
@Override
|
||||||
public void lock(){ this.locked = true; }
|
public void lock(){ this.locked = true; }
|
||||||
|
|
Loading…
Reference in a new issue