public class Syncer
extends java.lang.Object
Syncable
annotation on their classes with a value matching a registered ISyncHandler.Sync annotation.sync(Object, String...) with the Sync values for those fields.| Modifier and Type | Method and Description |
|---|---|
static void |
autoSync(java.lang.Object caller) |
void |
discover(net.minecraftforge.fml.common.discovery.ASMDataTable asmDataTable)
|
static Syncer |
get()
Gets the
Syncer instance. |
<T> ISyncHandler<? super T,? extends ISyncableData> |
getHandler(T caller)
Gets the
ISyncHandler for the specified object. |
ISyncHandler<?,? extends ISyncableData> |
getHandlerFromId(int id)
Gets a
ISyncHandler from it's ID |
int |
getHandlerId(java.lang.Class<?> clazz)
Gets the handler id for the specified
ISyncHandler. |
static void |
registerHandlerFactory(java.lang.String name,
com.google.common.base.Supplier<ISyncHandler<?,? extends ISyncableData>> supplier)
Registers a
ISyncHandler to the Syncer. |
static void |
sync(java.lang.Object caller,
java.lang.String... syncNames)
Synchronizes the specified fields names and sends the corresponding packet.
|
<T> void |
updateValues(T receiver,
ISyncHandler<T,? extends ISyncableData> handler,
java.util.Map<java.lang.String,java.lang.Object> values)
Update the fields values for the receiver object.
|
public int getHandlerId(java.lang.Class<?> clazz)
ISyncHandler.clazz - the clazzpublic ISyncHandler<?,? extends ISyncableData> getHandlerFromId(int id)
ISyncHandler from it's IDid - the idpublic <T> ISyncHandler<? super T,? extends ISyncableData> getHandler(T caller)
ISyncHandler for the specified object.T - the generic typecaller - the callerpublic void discover(net.minecraftforge.fml.common.discovery.ASMDataTable asmDataTable)
Syncable annotation and fields with Sync annotation.ISyncHandler.asmDataTable - the asm data tablepublic <T> void updateValues(T receiver,
ISyncHandler<T,? extends ISyncableData> handler,
java.util.Map<java.lang.String,java.lang.Object> values)
receiver - the callerhandler - the handlervalues - the valuespublic static void registerHandlerFactory(java.lang.String name,
com.google.common.base.Supplier<ISyncHandler<?,? extends ISyncableData>> supplier)
ISyncHandler to the Syncer.name - the namesupplier - the supplierpublic static void sync(java.lang.Object caller,
java.lang.String... syncNames)
caller - the callersyncNames - the sync namespublic static void autoSync(java.lang.Object caller)