now using NBT to pass blueprint over the network

This commit is contained in:
SpaceToad 2014-03-04 21:17:43 +01:00
parent 8a7b612402
commit 83bc69303a
3 changed files with 19 additions and 30 deletions

View file

@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import buildcraft.core.network.NetworkData;
import buildcraft.core.utils.Utils;
/**
@ -57,10 +56,7 @@ import buildcraft.core.utils.Utils;
*/
public class BptBlock {
@NetworkData
public Block block = null;
@NetworkData
public int x, y, z, meta = 0;
/**
@ -68,7 +64,6 @@ public class BptBlock {
* blueprint. Modders can either rely on this list or compute their own int
* BptBlock.
*/
@NetworkData
public ArrayList<ItemStack> storedRequirements = new ArrayList<ItemStack>();
/**
@ -77,7 +72,6 @@ public class BptBlock {
* the standard readNBT function of the corresponding tile (if any) and will
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
*/
@NetworkData
public NBTTagCompound cpt = new NBTTagCompound();
public enum Mode {

View file

@ -216,7 +216,9 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
BlueprintBase bpt = ItemBlueprint.getBlueprint(stack [1]);
if (bpt != null && uploadingPlayer != null) {
RPCHandler.rpcPlayer(this, "downloadBlueprintToClient", uploadingPlayer, bpt);
NBTTagCompound nbt = new NBTTagCompound();
bpt.writeToNBT(nbt);
RPCHandler.rpcPlayer(this, "downloadBlueprintToClient", uploadingPlayer, bpt.id, nbt);
uploadingPlayer = null;
}
}
@ -236,17 +238,21 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
@RPC (RPCSide.CLIENT)
public void requestSelectedBlueprint () {
if (selected > -1 && selected < currentPage.size()) {
RPCHandler.rpcServer(this, "uploadBlueprintToServer",
BuildCraftBuilders.clientDB
.get(currentPage.get(selected)));
BlueprintBase bpt = BuildCraftBuilders.clientDB.get(currentPage.get(selected));
NBTTagCompound nbt = new NBTTagCompound();
bpt.writeToNBT(nbt);
RPCHandler.rpcServer(this, "uploadBlueprintToServer", bpt.id, nbt);
} else {
RPCHandler.rpcServer(this, "uploadBlueprintToServer", (Object) null);
RPCHandler.rpcServer(this, "uploadBlueprintToServer", null, null);
}
}
@RPC (RPCSide.SERVER)
public void uploadBlueprintToServer (BlueprintBase bpt) {
if (bpt != null) {
public void uploadBlueprintToServer (BlueprintId id, NBTTagCompound data) {
if (data != null) {
BlueprintBase bpt = BlueprintBase.loadBluePrint(data);
bpt.id = id;
BuildCraftBuilders.serverDB.add(bpt);
setInventorySlotContents(3, ItemBlueprint.getBlueprintItem(bpt));
} else {
@ -259,7 +265,10 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
}
@RPC (RPCSide.CLIENT)
public void downloadBlueprintToClient (BlueprintBase bpt) {
public void downloadBlueprintToClient (BlueprintId id, NBTTagCompound data) {
BlueprintBase bpt = BlueprintBase.loadBluePrint(data);
bpt.id = id;
BuildCraftBuilders.clientDB.add(bpt);
setCurrentPage(BuildCraftBuilders.clientDB.getPage (pageId));
}

View file

@ -17,31 +17,17 @@ import buildcraft.api.blueprints.MappingRegistry;
import buildcraft.builders.blueprints.BlueprintId;
import buildcraft.core.Box;
import buildcraft.core.Version;
import buildcraft.core.network.NetworkData;
import buildcraft.core.utils.BCLog;
public abstract class BlueprintBase {
@NetworkData
public BptBlock contents[][][];
@NetworkData
public int anchorX, anchorY, anchorZ;
@NetworkData
public int sizeX, sizeY, sizeZ;
@NetworkData
public BlueprintId id = new BlueprintId();
@NetworkData
public String author;
@NetworkData
public String version = "";
@NetworkData
public MappingRegistry mapping = new MappingRegistry();
private String version = "";
protected MappingRegistry mapping = new MappingRegistry();
public BlueprintBase() {
}