public abstract class NetworkedObjectCache<T>
extends java.lang.Object
This class is NOT thread safe -- the client view may ONLY be used on the client thread, and the server view may ONLY be used the server thread.
Note that all custom instances should be added to BuildCraftObjectCaches.registerCache(NetworkedObjectCache)
,
in order to work properly
Modifier and Type | Class and Description |
---|---|
class |
NetworkedObjectCache.ClientView
The client view of the cache.
|
class |
NetworkedObjectCache.Link
Defines a link to a cached object (on the client - don't use this on the server).
|
class |
NetworkedObjectCache.ServerView
The server view of the cache.
|
Modifier and Type | Field and Description |
---|---|
protected T |
defaultObject
The default object -- used at the client in case the object hasn't been sent to the client yet.
|
Constructor and Description |
---|
NetworkedObjectCache(T defaultObject) |
Modifier and Type | Method and Description |
---|---|
NetworkedObjectCache.ClientView |
client() |
protected java.lang.String |
getCacheName() |
protected abstract T |
getCanonical(T obj)
Takes a specific object and turns it into its most basic form.
|
protected abstract T |
readObject(PacketBufferBC buffer)
Reads the specified object from the buffer.
|
NetworkedObjectCache.ServerView |
server() |
protected abstract void |
writeObject(T obj,
PacketBufferBC buffer)
Writes the specified object out to the buffer.
|
protected final T defaultObject
public NetworkedObjectCache(T defaultObject)
public NetworkedObjectCache.ServerView server()
public NetworkedObjectCache.ClientView client()
protected abstract T getCanonical(T obj)
ItemStack
's this will
should set the stack size to 1, and remove all non-rendered NBT tag components.obj
- The object to canonicalized.protected abstract void writeObject(T obj, PacketBufferBC buffer)
obj
- The object to write. It will have already been passed through getCanonical(Object)
buffer
- The buffer to write into.protected abstract T readObject(PacketBufferBC buffer) throws java.io.IOException
getCanonical(Object)
(so value.equals(getCanonical(value))
should return true.)buffer
- The buffer to read fromjava.io.IOException
protected java.lang.String getCacheName()