Package net.minecraftforge.common.loot
Class GlobalLootModifierSerializer<T extends IGlobalLootModifier>
- java.lang.Object
-
- net.minecraftforge.common.loot.GlobalLootModifierSerializer<T>
-
- Type Parameters:
T
- the Type to deserialize
- All Implemented Interfaces:
IForgeRegistryEntry<GlobalLootModifierSerializer<?>>
- Direct Known Subclasses:
GlobalLootModifiersTest.DungeonLootEnhancerModifier.Serializer
,GlobalLootModifiersTest.SilkTouchTestModifier.Serializer
,GlobalLootModifiersTest.SmeltingEnchantmentModifier.Serializer
,GlobalLootModifiersTest.WheatSeedsConverterModifier.Serializer
public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier> extends java.lang.Object implements IForgeRegistryEntry<GlobalLootModifierSerializer<?>>
Abstract base deserializer for LootModifiers. Takes care of Forge registry things.
Modders should extend this class to return their modifier and implement the abstractread
method to deserialize from json.
-
-
Field Summary
Fields Modifier and Type Field Description private ResourceLocation
registryName
-
Constructor Summary
Constructors Constructor Description GlobalLootModifierSerializer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static <G> java.lang.Class<G>
castClass(java.lang.Class<?> cls)
ResourceLocation
getRegistryName()
A unique identifier for this entry, if this entry is registered already it will return it's official registry name.java.lang.Class<GlobalLootModifierSerializer<?>>
getRegistryType()
Used by Forge's registry system.com.google.gson.JsonObject
makeConditions(ILootCondition[] conditions)
Helper to create the json object from the conditions.abstract T
read(ResourceLocation location, com.google.gson.JsonObject object, ILootCondition[] ailootcondition)
Most mods will likely not need more than
return new MyModifier(conditionsIn)
but any additional properties that are needed will need to be deserialized here.GlobalLootModifierSerializer<T>
setRegistryName(java.lang.String name)
GlobalLootModifierSerializer<T>
setRegistryName(java.lang.String modID, java.lang.String name)
GlobalLootModifierSerializer<T>
setRegistryName(ResourceLocation name)
Sets a unique name for this Item.abstract com.google.gson.JsonObject
write(T instance)
Write the serializer to json.
-
-
-
Field Detail
-
registryName
private ResourceLocation registryName
-
-
Method Detail
-
setRegistryName
public final GlobalLootModifierSerializer<T> setRegistryName(java.lang.String name)
-
setRegistryName
public final GlobalLootModifierSerializer<T> setRegistryName(ResourceLocation name)
Description copied from interface:IForgeRegistryEntry
Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. The supplied name will be prefixed with the currently active mod's modId. If the supplied name already has a prefix that is different, it will be used and a warning will be logged. If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. Returns 'this' to allow for chaining.- Specified by:
setRegistryName
in interfaceIForgeRegistryEntry<T extends IGlobalLootModifier>
- Parameters:
name
- Unique registry name- Returns:
- This instance
-
setRegistryName
public final GlobalLootModifierSerializer<T> setRegistryName(java.lang.String modID, java.lang.String name)
-
getRegistryName
public final ResourceLocation getRegistryName()
Description copied from interface:IForgeRegistryEntry
A unique identifier for this entry, if this entry is registered already it will return it's official registry name. Otherwise it will return the name set in setRegistryName(). If neither are valid null is returned.- Specified by:
getRegistryName
in interfaceIForgeRegistryEntry<T extends IGlobalLootModifier>
- Returns:
- Unique identifier or null.
-
read
public abstract T read(ResourceLocation location, com.google.gson.JsonObject object, ILootCondition[] ailootcondition)
Most mods will likely not need more than
return new MyModifier(conditionsIn)
but any additional properties that are needed will need to be deserialized here.- Parameters:
name
- The resource location (if needed)json
- The full json object (including ILootConditions)conditionsIn
- An already deserialized list of ILootConditions
-
write
public abstract com.google.gson.JsonObject write(T instance)
Write the serializer to json. Most serializers won't have to do anything else thanmakeConditions(net.minecraft.loot.conditions.ILootCondition[])
Which simply creates the JsonObject from an array of ILootConditions.
-
makeConditions
public com.google.gson.JsonObject makeConditions(ILootCondition[] conditions)
Helper to create the json object from the conditions. Add any extra properties to the returned json.
-
getRegistryType
public final java.lang.Class<GlobalLootModifierSerializer<?>> getRegistryType()
Used by Forge's registry system.- Specified by:
getRegistryType
in interfaceIForgeRegistryEntry<T extends IGlobalLootModifier>
- Returns:
- Root registry type.
-
castClass
private static <G> java.lang.Class<G> castClass(java.lang.Class<?> cls)
-
-