Implemented builder state save for filler and quarry.
Fixed API, and moved out some non-essencial files. Close #1618
This commit is contained in:
parent
f4ec1c6ca4
commit
5bd9aec80a
15 changed files with 169 additions and 91 deletions
|
@ -34,10 +34,6 @@ package buildcraft.api.blueprints;
|
||||||
*/
|
*/
|
||||||
public abstract class SchematicBlockBase extends Schematic {
|
public abstract class SchematicBlockBase extends Schematic {
|
||||||
|
|
||||||
public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the block should not be placed to the world. Requirements
|
* Return true if the block should not be placed to the world. Requirements
|
||||||
* will not be asked on such a block, and building will not be called.
|
* will not be asked on such a block, and building will not be called.
|
||||||
|
|
|
@ -57,20 +57,6 @@ public class SchematicMask extends SchematicBlockBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: To be removed with the "real" list of items
|
|
||||||
@Override
|
|
||||||
public void addRequirements(IBuilderContext context, LinkedList<ItemStack> requirements) {
|
|
||||||
requirements.add(new ItemStack(Blocks.brick_block));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) {
|
|
||||||
if (!isConcrete) {
|
|
||||||
context.world().destroyBlockInWorldPartially(0, x, y, z,
|
|
||||||
(int) (completed * 10.0F) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||||
nbt.setBoolean("isConcrete", isConcrete);
|
nbt.setBoolean("isConcrete", isConcrete);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
import buildcraft.core.BuildCraftConfiguration;
|
import buildcraft.api.core.JavaTools;
|
||||||
|
|
||||||
public class SchematicRegistry {
|
public class SchematicRegistry {
|
||||||
|
|
||||||
|
@ -138,14 +138,14 @@ public class SchematicRegistry {
|
||||||
return !modsForbidden.contains(modid) && !blocksForbidden.contains(name);
|
return !modsForbidden.contains(modid) && !blocksForbidden.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readConfiguration (BuildCraftConfiguration conf) {
|
public static void readConfiguration (Configuration conf) {
|
||||||
Property excludedMods = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedMods", new String [0],
|
Property excludedMods = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedMods", new String [0],
|
||||||
"mods that should be excluded from the builder.");
|
"mods that should be excluded from the builder.");
|
||||||
Property excludedBlocks = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedBlocks", new String [0],
|
Property excludedBlocks = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedBlocks", new String [0],
|
||||||
"blocks that should be excluded from the builder.");
|
"blocks that should be excluded from the builder.");
|
||||||
|
|
||||||
for (String id : excludedMods.getStringList()) {
|
for (String id : excludedMods.getStringList()) {
|
||||||
id = BuildCraftConfiguration.stripSurroundingQuotes (id.trim());
|
id = JavaTools.stripSurroundingQuotes (id.trim());
|
||||||
|
|
||||||
if (id.length() > 0) {
|
if (id.length() > 0) {
|
||||||
modsForbidden.add(id);
|
modsForbidden.add(id);
|
||||||
|
@ -153,7 +153,7 @@ public class SchematicRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String id : excludedBlocks.getStringList()) {
|
for (String id : excludedBlocks.getStringList()) {
|
||||||
id = BuildCraftConfiguration.stripSurroundingQuotes (id.trim());
|
id = JavaTools.stripSurroundingQuotes (id.trim());
|
||||||
|
|
||||||
if (id.length() > 0) {
|
if (id.length() > 0) {
|
||||||
blocksForbidden.add(id);
|
blocksForbidden.add(id);
|
||||||
|
|
|
@ -78,4 +78,12 @@ public class JavaTools {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String surroundWithQuotes(String stringToSurroundWithQuotes){
|
||||||
|
return String.format("\"%s\"", stringToSurroundWithQuotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String stripSurroundingQuotes(String stringToStripQuotes) {
|
||||||
|
return stringToStripQuotes.replaceAll("^\"|\"$", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,6 @@ import net.minecraftforge.common.config.Property;
|
||||||
import buildcraft.api.blueprints.SchematicBlock;
|
import buildcraft.api.blueprints.SchematicBlock;
|
||||||
import buildcraft.api.blueprints.SchematicEntity;
|
import buildcraft.api.blueprints.SchematicEntity;
|
||||||
import buildcraft.api.blueprints.SchematicFactory;
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
import buildcraft.api.blueprints.SchematicFactoryBlock;
|
|
||||||
import buildcraft.api.blueprints.SchematicFactoryEntity;
|
|
||||||
import buildcraft.api.blueprints.SchematicFactoryMask;
|
|
||||||
import buildcraft.api.blueprints.SchematicMask;
|
import buildcraft.api.blueprints.SchematicMask;
|
||||||
import buildcraft.api.blueprints.SchematicRegistry;
|
import buildcraft.api.blueprints.SchematicRegistry;
|
||||||
import buildcraft.api.core.BCLog;
|
import buildcraft.api.core.BCLog;
|
||||||
|
@ -73,6 +70,9 @@ import buildcraft.builders.schematics.SchematicCustomStack;
|
||||||
import buildcraft.builders.schematics.SchematicDirt;
|
import buildcraft.builders.schematics.SchematicDirt;
|
||||||
import buildcraft.builders.schematics.SchematicDoor;
|
import buildcraft.builders.schematics.SchematicDoor;
|
||||||
import buildcraft.builders.schematics.SchematicEnderChest;
|
import buildcraft.builders.schematics.SchematicEnderChest;
|
||||||
|
import buildcraft.builders.schematics.SchematicFactoryBlock;
|
||||||
|
import buildcraft.builders.schematics.SchematicFactoryEntity;
|
||||||
|
import buildcraft.builders.schematics.SchematicFactoryMask;
|
||||||
import buildcraft.builders.schematics.SchematicFarmland;
|
import buildcraft.builders.schematics.SchematicFarmland;
|
||||||
import buildcraft.builders.schematics.SchematicFire;
|
import buildcraft.builders.schematics.SchematicFire;
|
||||||
import buildcraft.builders.schematics.SchematicFluid;
|
import buildcraft.builders.schematics.SchematicFluid;
|
||||||
|
|
|
@ -23,13 +23,13 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.oredict.RecipeSorter;
|
import net.minecraftforge.oredict.RecipeSorter;
|
||||||
import buildcraft.api.blueprints.SchematicRegistry;
|
import buildcraft.api.blueprints.SchematicRegistry;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
|
import buildcraft.api.core.JavaTools;
|
||||||
import buildcraft.api.gates.ActionManager;
|
import buildcraft.api.gates.ActionManager;
|
||||||
import buildcraft.api.gates.GateExpansions;
|
import buildcraft.api.gates.GateExpansions;
|
||||||
import buildcraft.api.recipes.BuildcraftRecipes;
|
import buildcraft.api.recipes.BuildcraftRecipes;
|
||||||
import buildcraft.api.transport.IExtractionHandler;
|
import buildcraft.api.transport.IExtractionHandler;
|
||||||
import buildcraft.api.transport.PipeManager;
|
import buildcraft.api.transport.PipeManager;
|
||||||
import buildcraft.api.transport.PipeWire;
|
import buildcraft.api.transport.PipeWire;
|
||||||
import buildcraft.core.BuildCraftConfiguration;
|
|
||||||
import buildcraft.core.CreativeTabBuildCraft;
|
import buildcraft.core.CreativeTabBuildCraft;
|
||||||
import buildcraft.core.DefaultProps;
|
import buildcraft.core.DefaultProps;
|
||||||
import buildcraft.core.InterModComms;
|
import buildcraft.core.InterModComms;
|
||||||
|
@ -295,16 +295,16 @@ public class BuildCraftTransport extends BuildCraftMod {
|
||||||
Block.blockRegistry.getNameForObject(Blocks.double_stone_slab),
|
Block.blockRegistry.getNameForObject(Blocks.double_stone_slab),
|
||||||
Block.blockRegistry.getNameForObject(Blocks.double_wooden_slab),
|
Block.blockRegistry.getNameForObject(Blocks.double_wooden_slab),
|
||||||
Block.blockRegistry.getNameForObject(Blocks.sponge),
|
Block.blockRegistry.getNameForObject(Blocks.sponge),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.architectBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.architectBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.builderBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.builderBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.fillerBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.fillerBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.libraryBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.libraryBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.autoWorkbenchBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.autoWorkbenchBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.floodGateBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.floodGateBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.miningWellBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.miningWellBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)),
|
||||||
BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)),
|
JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)),
|
||||||
});
|
});
|
||||||
|
|
||||||
facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes.";
|
facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes.";
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
|
|
||||||
private LinkedList <ItemStack> requiredToBuild;
|
private LinkedList <ItemStack> requiredToBuild;
|
||||||
|
|
||||||
NBTTagCompound initNBT = null;
|
private NBTTagCompound initNBT = null;
|
||||||
|
|
||||||
private class PathIterator {
|
private class PathIterator {
|
||||||
|
|
||||||
|
@ -215,7 +215,6 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bluePrintBuilder != null) {
|
if (bluePrintBuilder != null) {
|
||||||
NBTTagCompound builderCpt = new NBTTagCompound();
|
|
||||||
bluePrintBuilder.loadBuildStateToNBT(
|
bluePrintBuilder.loadBuildStateToNBT(
|
||||||
initNBT.getCompoundTag("builderState"), this);
|
initNBT.getCompoundTag("builderState"), this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
|
private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown;
|
||||||
private SimpleInventory inv = new SimpleInventory(27, "Filler", 64);
|
private SimpleInventory inv = new SimpleInventory(27, "Filler", 64);
|
||||||
|
|
||||||
|
private NBTTagCompound initNBT = null;
|
||||||
|
|
||||||
public TileFiller() {
|
public TileFiller() {
|
||||||
inv.addListener(this);
|
inv.addListener(this);
|
||||||
box.kind = Kind.STRIPES;
|
box.kind = Kind.STRIPES;
|
||||||
|
@ -61,19 +63,35 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
if (!worldObj.isRemote) {
|
if (worldObj.isRemote) {
|
||||||
IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, zCoord);
|
return;
|
||||||
|
|
||||||
if (a != null) {
|
|
||||||
box.initialize(a);
|
|
||||||
|
|
||||||
if (a instanceof TileMarker) {
|
|
||||||
((TileMarker) a).removeFromWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
sendNetworkUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord,
|
||||||
|
zCoord);
|
||||||
|
|
||||||
|
if (a != null) {
|
||||||
|
box.initialize(a);
|
||||||
|
|
||||||
|
if (a instanceof TileMarker) {
|
||||||
|
((TileMarker) a).removeFromWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentPattern != null && currentTemplate == null) {
|
||||||
|
currentTemplate = currentPattern
|
||||||
|
.getTemplateBuilder(box, getWorld());
|
||||||
|
context = currentTemplate.getContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initNBT != null && currentTemplate != null) {
|
||||||
|
currentTemplate.loadBuildStateToNBT(
|
||||||
|
initNBT.getCompoundTag("builderState"), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNBT = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +110,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mjStored < POWER_ACTIVATION && !buildTracker.markTimeIfDelay(worldObj)) {
|
if (mjStored < POWER_ACTIVATION || !buildTracker.markTimeIfDelay(worldObj)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +193,9 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
|
|
||||||
done = nbt.getBoolean("done");
|
done = nbt.getBoolean("done");
|
||||||
lastMode = Mode.values()[nbt.getByte("lastMode")];
|
lastMode = Mode.values()[nbt.getByte("lastMode")];
|
||||||
|
|
||||||
|
// The rest of load has to be done upon initialize.
|
||||||
|
initNBT = (NBTTagCompound) nbt.getCompoundTag("bpt").copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -193,6 +214,16 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
||||||
|
|
||||||
nbt.setBoolean("done", done);
|
nbt.setBoolean("done", done);
|
||||||
nbt.setByte("lastMode", (byte) lastMode.ordinal());
|
nbt.setByte("lastMode", (byte) lastMode.ordinal());
|
||||||
|
|
||||||
|
NBTTagCompound bptNBT = new NBTTagCompound();
|
||||||
|
|
||||||
|
if (currentTemplate != null) {
|
||||||
|
NBTTagCompound builderCpt = new NBTTagCompound();
|
||||||
|
currentTemplate.saveBuildStateToNBT(builderCpt, this);
|
||||||
|
bptNBT.setTag("builderState", builderCpt);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setTag("bpt", bptNBT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,8 +6,12 @@
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.blueprints;
|
package buildcraft.builders.schematics;
|
||||||
|
|
||||||
|
import buildcraft.api.blueprints.MappingRegistry;
|
||||||
|
import buildcraft.api.blueprints.SchematicBlock;
|
||||||
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
|
import buildcraft.api.blueprints.SchematicRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
|
@ -6,8 +6,12 @@
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.blueprints;
|
package buildcraft.builders.schematics;
|
||||||
|
|
||||||
|
import buildcraft.api.blueprints.MappingRegistry;
|
||||||
|
import buildcraft.api.blueprints.SchematicEntity;
|
||||||
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
|
import buildcraft.api.blueprints.SchematicRegistry;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class SchematicFactoryEntity extends SchematicFactory <SchematicEntity> {
|
public class SchematicFactoryEntity extends SchematicFactory <SchematicEntity> {
|
|
@ -6,8 +6,11 @@
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||||
*/
|
*/
|
||||||
package buildcraft.api.blueprints;
|
package buildcraft.builders.schematics;
|
||||||
|
|
||||||
|
import buildcraft.api.blueprints.MappingRegistry;
|
||||||
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
|
import buildcraft.api.blueprints.SchematicMask;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class SchematicFactoryMask extends SchematicFactory <SchematicMask> {
|
public class SchematicFactoryMask extends SchematicFactory <SchematicMask> {
|
|
@ -9,6 +9,7 @@
|
||||||
package buildcraft.core;
|
package buildcraft.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
|
|
||||||
|
@ -24,12 +25,4 @@ public class BuildCraftConfiguration extends Configuration {
|
||||||
versionProp.set(Version.VERSION);
|
versionProp.set(Version.VERSION);
|
||||||
super.save();
|
super.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String surroundWithQuotes(String stringToSurroundWithQuotes){
|
|
||||||
return String.format("\"%s\"", stringToSurroundWithQuotes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String stripSurroundingQuotes(String stringToStripQuotes) {
|
|
||||||
return stringToStripQuotes.replaceAll("^\"|\"$", "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.Constants;
|
||||||
import buildcraft.api.blueprints.IBuilderContext;
|
import buildcraft.api.blueprints.IBuilderContext;
|
||||||
import buildcraft.api.blueprints.MappingRegistry;
|
import buildcraft.api.blueprints.MappingRegistry;
|
||||||
import buildcraft.api.blueprints.SchematicBlockBase;
|
import buildcraft.api.blueprints.SchematicBlockBase;
|
||||||
import buildcraft.api.blueprints.SchematicFactory;
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
import buildcraft.api.blueprints.SchematicMask;
|
import buildcraft.api.blueprints.SchematicMask;
|
||||||
import buildcraft.api.core.BuildCraftAPI;
|
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
|
|
||||||
public class BuildingSlotBlock extends BuildingSlot {
|
public class BuildingSlotBlock extends BuildingSlot {
|
||||||
|
@ -93,8 +94,9 @@ public class BuildingSlotBlock extends BuildingSlot {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeCompleted (IBuilderContext context, double complete) {
|
public void writeCompleted (IBuilderContext context, double complete) {
|
||||||
if (BuildCraftAPI.isSoftBlock(context.world(), x, y, z)) {
|
if (mode == Mode.ClearIfInvalid) {
|
||||||
getSchematic().writeCompleted(context, x, y, z, complete);
|
context.world().destroyBlockInWorldPartially(0, x, y, z,
|
||||||
|
(int) (complete * 10.0F) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,10 +112,22 @@ public class BuildingSlotBlock extends BuildingSlot {
|
||||||
nbt.setInteger("y", y);
|
nbt.setInteger("y", y);
|
||||||
nbt.setInteger("z", z);
|
nbt.setInteger("z", z);
|
||||||
|
|
||||||
NBTTagCompound schematicNBT = new NBTTagCompound();
|
if (schematic != null) {
|
||||||
SchematicFactory.getFactory(schematic.getClass())
|
NBTTagCompound schematicNBT = new NBTTagCompound();
|
||||||
.saveSchematicToWorldNBT(schematicNBT, schematic, registry);
|
SchematicFactory.getFactory(schematic.getClass())
|
||||||
nbt.setTag("schematic", schematicNBT);
|
.saveSchematicToWorldNBT(schematicNBT, schematic, registry);
|
||||||
|
nbt.setTag("schematic", schematicNBT);
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagList nbtStacks = new NBTTagList ();
|
||||||
|
|
||||||
|
for (ItemStack stack : stackConsumed) {
|
||||||
|
NBTTagCompound nbtStack = new NBTTagCompound();
|
||||||
|
stack.writeToNBT(nbtStack);
|
||||||
|
nbtStacks.appendTag(nbtStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setTag("stackConsumed", nbtStacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +137,20 @@ public class BuildingSlotBlock extends BuildingSlot {
|
||||||
y = nbt.getInteger("y");
|
y = nbt.getInteger("y");
|
||||||
z = nbt.getInteger("z");
|
z = nbt.getInteger("z");
|
||||||
|
|
||||||
schematic = (SchematicBlockBase) SchematicFactory
|
if (nbt.hasKey("schematic")) {
|
||||||
|
schematic = (SchematicBlockBase) SchematicFactory
|
||||||
.createSchematicFromWorldNBT(nbt.getCompoundTag("schematic"), registry);
|
.createSchematicFromWorldNBT(nbt.getCompoundTag("schematic"), registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
stackConsumed = new LinkedList<ItemStack>();
|
||||||
|
|
||||||
|
NBTTagList nbtStacks = nbt.getTagList("stackConsumed", Constants.NBT.TAG_COMPOUND);
|
||||||
|
|
||||||
|
for (int i = 0; i < nbtStacks.tagCount(); ++i) {
|
||||||
|
stackConsumed.add(ItemStack.loadItemStackFromNBT(nbtStacks
|
||||||
|
.getCompoundTagAt(i)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -87,7 +87,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
private Ticket chunkTicket;
|
private Ticket chunkTicket;
|
||||||
public EntityPlayer placedBy;
|
public EntityPlayer placedBy;
|
||||||
|
|
||||||
boolean frameProducer = true;
|
private boolean frameProducer = true;
|
||||||
|
|
||||||
|
private NBTTagCompound initNBT = null;
|
||||||
|
|
||||||
public TileQuarry () {
|
public TileQuarry () {
|
||||||
box.kind = Kind.STRIPES;
|
box.kind = Kind.STRIPES;
|
||||||
|
@ -167,7 +169,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
|
|
||||||
if (stage == Stage.BUILDING) {
|
if (stage == Stage.BUILDING) {
|
||||||
if (builder != null && !builder.isDone(this)) {
|
if (builder != null && !builder.isDone(this)) {
|
||||||
builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
|
if (buildTracker.markTimeIfDelay(worldObj)) {
|
||||||
|
builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
stage = Stage.IDLE;
|
stage = Stage.IDLE;
|
||||||
}
|
}
|
||||||
|
@ -360,6 +364,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
headPosX = nbttagcompound.getDouble("headPosX");
|
headPosX = nbttagcompound.getDouble("headPosX");
|
||||||
headPosY = nbttagcompound.getDouble("headPosY");
|
headPosY = nbttagcompound.getDouble("headPosY");
|
||||||
headPosZ = nbttagcompound.getDouble("headPosZ");
|
headPosZ = nbttagcompound.getDouble("headPosZ");
|
||||||
|
|
||||||
|
// The rest of load has to be done upon initialize.
|
||||||
|
initNBT = (NBTTagCompound) nbttagcompound.getCompoundTag("bpt").copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -376,6 +383,16 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
NBTTagCompound boxTag = new NBTTagCompound();
|
NBTTagCompound boxTag = new NBTTagCompound();
|
||||||
box.writeToNBT(boxTag);
|
box.writeToNBT(boxTag);
|
||||||
nbttagcompound.setTag("box", boxTag);
|
nbttagcompound.setTag("box", boxTag);
|
||||||
|
|
||||||
|
NBTTagCompound bptNBT = new NBTTagCompound();
|
||||||
|
|
||||||
|
if (builder != null) {
|
||||||
|
NBTTagCompound builderCpt = new NBTTagCompound();
|
||||||
|
builder.saveBuildStateToNBT(builderCpt, this);
|
||||||
|
bptNBT.setTag("builderState", builderCpt);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbttagcompound.setTag("bpt", bptNBT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
@ -627,6 +644,13 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
||||||
|
|
||||||
createUtilsIfNeeded();
|
createUtilsIfNeeded();
|
||||||
|
|
||||||
|
if (initNBT != null && builder != null) {
|
||||||
|
builder.loadBuildStateToNBT(
|
||||||
|
initNBT.getCompoundTag("builderState"), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNBT = null;
|
||||||
|
|
||||||
sendNetworkUpdate();
|
sendNetworkUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,10 @@
|
||||||
*/
|
*/
|
||||||
package buildcraft.transport;
|
package buildcraft.transport;
|
||||||
|
|
||||||
import buildcraft.BuildCraftTransport;
|
import java.util.LinkedList;
|
||||||
import buildcraft.api.core.Position;
|
import java.util.List;
|
||||||
import buildcraft.api.recipes.BuildcraftRecipes;
|
import java.util.Set;
|
||||||
import buildcraft.api.transport.PipeWire;
|
|
||||||
import buildcraft.core.BlockSpring;
|
|
||||||
import buildcraft.core.BuildCraftConfiguration;
|
|
||||||
import buildcraft.core.CreativeTabBuildCraft;
|
|
||||||
import buildcraft.core.ItemBuildCraft;
|
|
||||||
import buildcraft.core.proxy.CoreProxy;
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
@ -34,10 +25,21 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import buildcraft.BuildCraftTransport;
|
||||||
|
import buildcraft.api.core.JavaTools;
|
||||||
|
import buildcraft.api.core.Position;
|
||||||
|
import buildcraft.api.recipes.BuildcraftRecipes;
|
||||||
|
import buildcraft.api.transport.PipeWire;
|
||||||
|
import buildcraft.core.BlockSpring;
|
||||||
|
import buildcraft.core.CreativeTabBuildCraft;
|
||||||
|
import buildcraft.core.ItemBuildCraft;
|
||||||
|
import buildcraft.core.proxy.CoreProxy;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import com.google.common.base.Strings;
|
||||||
import java.util.List;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.Set;
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class ItemFacade extends ItemBuildCraft {
|
public class ItemFacade extends ItemBuildCraft {
|
||||||
|
|
||||||
|
@ -121,14 +123,16 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||||
if (worldObj.isRemote)
|
if (worldObj.isRemote) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side));
|
Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side));
|
||||||
pos.moveForwards(1.0);
|
pos.moveForwards(1.0);
|
||||||
|
|
||||||
TileEntity tile = worldObj.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
|
TileEntity tile = worldObj.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
|
||||||
if (!(tile instanceof TileGenericPipe))
|
if (!(tile instanceof TileGenericPipe)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
TileGenericPipe pipeTile = (TileGenericPipe) tile;
|
||||||
|
|
||||||
if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getType(stack), ItemFacade.getWireType(stack), ItemFacade.getBlocks(stack), ItemFacade.getMetaValues(stack))) {
|
if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getType(stack), ItemFacade.getWireType(stack), ItemFacade.getBlocks(stack), ItemFacade.getMetaValues(stack))) {
|
||||||
|
@ -194,7 +198,7 @@ public class ItemFacade extends ItemBuildCraft {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String blacklistedBlock : BuildCraftTransport.facadeBlacklist) {
|
for (String blacklistedBlock : BuildCraftTransport.facadeBlacklist) {
|
||||||
if(blockName.equals(BuildCraftConfiguration.stripSurroundingQuotes(blacklistedBlock))) {
|
if(blockName.equals(JavaTools.stripSurroundingQuotes(blacklistedBlock))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue