completed first version of builder state save, for #1575
This commit is contained in:
parent
c5dec93711
commit
863977bcd4
5 changed files with 50 additions and 2 deletions
|
@ -50,7 +50,6 @@ public class MappingRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public Item getItemForId(int id) {
|
||||
if (id >= idToItem.size()) {
|
||||
return null;
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.blueprints.BuildingSlot;
|
||||
import buildcraft.core.blueprints.IBuilder;
|
||||
|
@ -222,6 +223,8 @@ public class BuildingItem implements IBuilder {
|
|||
destination.writeToNBT(destinationNBT);
|
||||
nbt.setTag ("destination", destinationNBT);
|
||||
|
||||
nbt.setDouble("lifeTime", lifetime);
|
||||
|
||||
NBTTagList items = new NBTTagList();
|
||||
for (ItemStack s : stacksToBuild) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
@ -229,7 +232,16 @@ public class BuildingItem implements IBuilder {
|
|||
items.appendTag(cpt);
|
||||
}
|
||||
|
||||
// TODO: How to write the schematic??? Or load that from the builder???
|
||||
MappingRegistry registry = new MappingRegistry();
|
||||
|
||||
NBTTagCompound slotNBT = new NBTTagCompound();
|
||||
NBTTagCompound registryNBT = new NBTTagCompound();
|
||||
|
||||
slotToBuild.writeToNBT(slotNBT, registry);
|
||||
registry.write(registryNBT);
|
||||
|
||||
nbt.setTag("registry", registryNBT);
|
||||
nbt.setTag("slotToBuild", slotNBT);
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound nbt) {
|
||||
|
|
|
@ -11,7 +11,9 @@ package buildcraft.core.blueprints;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.blueprints.Schematic;
|
||||
import buildcraft.api.core.Position;
|
||||
|
||||
|
@ -48,4 +50,8 @@ public abstract class BuildingSlot {
|
|||
public abstract boolean isAlreadyBuilt (IBuilderContext context);
|
||||
|
||||
public abstract Schematic getSchematic ();
|
||||
|
||||
public abstract void writeToNBT (NBTTagCompound nbt, MappingRegistry registry);
|
||||
|
||||
public abstract void readFromNBT (NBTTagCompound nbt, MappingRegistry registry);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@ package buildcraft.core.blueprints;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.blueprints.SchematicBlockBase;
|
||||
import buildcraft.api.blueprints.SchematicMask;
|
||||
import buildcraft.api.core.Position;
|
||||
|
@ -124,4 +126,21 @@ public class BuildingSlotBlock extends BuildingSlot implements Comparable<Buildi
|
|||
public boolean isAlreadyBuilt(IBuilderContext context) {
|
||||
return schematic.isAlreadyBuilt(context, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound nbt, MappingRegistry registry) {
|
||||
nbt.setByte("mode", (byte) mode.ordinal());
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
nbt.setInteger("z", z);
|
||||
|
||||
NBTTagCompound schematicNBT = new NBTTagCompound();
|
||||
schematic.writeToNBT(schematicNBT, registry);
|
||||
nbt.setTag("schematic", schematicNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound nbt, MappingRegistry registry) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@ package buildcraft.core.blueprints;
|
|||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.blueprints.SchematicEntity;
|
||||
import buildcraft.api.core.Position;
|
||||
|
||||
|
@ -54,4 +56,14 @@ public class BuildingSlotEntity extends BuildingSlot {
|
|||
public boolean isAlreadyBuilt(IBuilderContext context) {
|
||||
return schematic.isAlreadyBuilt(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound nbt, MappingRegistry registry) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound nbt, MappingRegistry registry) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue