commit
a22568790a
2 changed files with 13 additions and 3 deletions
|
@ -489,7 +489,13 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
|
|||
public static Pipe createPipe(int key) {
|
||||
|
||||
try {
|
||||
return pipes.get(key).getConstructor(int.class).newInstance(key);
|
||||
Class<? extends Pipe> pipe = pipes.get(key);
|
||||
if (pipe != null) {
|
||||
return pipe.getConstructor(int.class).newInstance(key);
|
||||
} else {
|
||||
System.err.printf("Detected pipe with unknown key. Did you remove a buildcraft addon?\n");
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -60,6 +60,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
private boolean blockNeighborChange = false;
|
||||
private boolean pipeBound = false;
|
||||
|
||||
//Store the pipe key to prevent losing pipes when a user forgets to include an addon
|
||||
int key;
|
||||
|
||||
@TileNetworkData
|
||||
public int pipeId = -1;
|
||||
|
||||
|
@ -74,7 +77,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
if (pipe != null) {
|
||||
nbttagcompound.setInteger("pipeId", pipe.itemID);
|
||||
pipe.writeToNBT(nbttagcompound);
|
||||
}
|
||||
} else
|
||||
nbttagcompound.setInteger("pipeId", key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +86,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
|
||||
int key = nbttagcompound.getInteger("pipeId");
|
||||
key = nbttagcompound.getInteger("pipeId");
|
||||
pipe = BlockGenericPipe.createPipe(key);
|
||||
|
||||
if (pipe != null) {
|
||||
|
|
Loading…
Reference in a new issue