Skip to content

Commit 7efbb42

Browse files
committedMay 21, 2016
Store whether tag was written for server or client, so we know how to load it, since the client may feed use either now...
Fixed triggering of some sounds. Also constantify all the tag names .-.

File tree

77 files changed

+1021
-653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1021
-653
lines changed
 

Diff for: ‎src/main/java/li/cil/oc/api/prefab/ManagedEnvironment.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* unused methods don't clutter the implementing class.
1010
*/
1111
public abstract class ManagedEnvironment implements li.cil.oc.api.network.ManagedEnvironment {
12+
public static final String NODE_TAG = "node";
13+
1214
// Should be initialized using setNode(api.Network.newNode()). See TileEntityEnvironment.
1315
private Node _node;
1416

@@ -45,7 +47,7 @@ public void onMessage(final Message message) {
4547
@Override
4648
public void load(final NBTTagCompound nbt) {
4749
if (node() != null) {
48-
node().load(nbt.getCompoundTag("node"));
50+
node().load(nbt.getCompoundTag(NODE_TAG));
4951
}
5052
}
5153

@@ -61,13 +63,13 @@ public void save(final NBTTagCompound nbt) {
6163

6264
final NBTTagCompound nodeTag = new NBTTagCompound();
6365
node().save(nodeTag);
64-
nbt.setTag("node", nodeTag);
66+
nbt.setTag(NODE_TAG, nodeTag);
6567

6668
node().remove();
6769
} else {
6870
final NBTTagCompound nodeTag = new NBTTagCompound();
6971
node().save(nodeTag);
70-
nbt.setTag("node", nodeTag);
72+
nbt.setTag(NODE_TAG, nodeTag);
7173
}
7274
}
7375
}

Diff for: ‎src/main/scala/li/cil/oc/common/component/TerminalServer.scala

+10-6
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,25 @@ class TerminalServer(val rack: api.internal.Rack, val slot: Int) extends Environ
147147
// ----------------------------------------------------------------------- //
148148
// Persistable
149149

150+
private final val BufferTag = Settings.namespace + "buffer"
151+
private final val KeyboardTag = Settings.namespace + "keyboard"
152+
private final val KeysTag = Settings.namespace + "keys"
153+
150154
override def load(nbt: NBTTagCompound): Unit = {
151155
if (!rack.world.isRemote) {
152156
node.load(nbt)
153157
}
154-
buffer.load(nbt.getCompoundTag(Settings.namespace + "buffer"))
155-
keyboard.load(nbt.getCompoundTag(Settings.namespace + "keyboard"))
158+
buffer.load(nbt.getCompoundTag(BufferTag))
159+
keyboard.load(nbt.getCompoundTag(KeyboardTag))
156160
keys.clear()
157-
nbt.getTagList(Settings.namespace + "keys", NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.getString)
161+
nbt.getTagList(KeysTag, NBT.TAG_STRING).foreach((tag: NBTTagString) => keys += tag.getString)
158162
}
159163

160164
override def save(nbt: NBTTagCompound): Unit = {
161165
node.save(nbt)
162-
nbt.setNewCompoundTag(Settings.namespace + "buffer", buffer.save)
163-
nbt.setNewCompoundTag(Settings.namespace + "keyboard", keyboard.save)
164-
nbt.setNewTagList(Settings.namespace + "keys", keys)
166+
nbt.setNewCompoundTag(BufferTag, buffer.save)
167+
nbt.setNewCompoundTag(KeyboardTag, keyboard.save)
168+
nbt.setNewTagList(KeysTag, keys)
165169
}
166170

167171
// ----------------------------------------------------------------------- //

0 commit comments

Comments
 (0)
Please sign in to comment.