Added provision for blueprints with non existing blocks and entities.
Close #1702
This commit is contained in:
parent
03dfd35b47
commit
fe5e734b64
4 changed files with 38 additions and 17 deletions
|
@ -138,6 +138,7 @@ item.blueprint.author=by
|
|||
item.blueprint.blank=Blank
|
||||
item.blueprint.creative_only=Creative Only
|
||||
item.blueprint.no_build=No Building
|
||||
item.blueprint.incomplete=Incomplete
|
||||
item.PipeItemsWood.name=Wooden Transport Pipe
|
||||
item.PipeItemsCobblestone.name=Cobblestone Transport Pipe
|
||||
item.PipeItemsStone.name=Stone Transport Pipe
|
||||
|
|
|
@ -57,6 +57,14 @@ public abstract class ItemBlueprint extends ItemBuildCraft {
|
|||
list.add(String.format(StringUtils.localize("item.blueprint.no_build")));
|
||||
}
|
||||
}
|
||||
|
||||
if (NBTUtils.getItemData(stack).hasKey("isComplete")) {
|
||||
boolean isComplete = NBTUtils.getItemData(stack).getBoolean("isComplete");
|
||||
|
||||
if (!isComplete) {
|
||||
list.add(String.format(StringUtils.localize("item.blueprint.incomplete")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BlueprintId getId (ItemStack stack) {
|
||||
|
|
|
@ -196,22 +196,27 @@ public class Blueprint extends BlueprintBase {
|
|||
index++;
|
||||
|
||||
if (cpt.hasKey("blockId")) {
|
||||
int blockId = cpt.getInteger("blockId");
|
||||
Block block = mapping.getBlockForId(cpt.getInteger("blockId"));
|
||||
|
||||
contents[x][y][z] = SchematicRegistry.newSchematicBlock(mapping.getBlockForId(blockId));
|
||||
contents[x][y][z].readFromNBT(cpt, mapping);
|
||||
if (block != null) {
|
||||
contents[x][y][z] = SchematicRegistry.newSchematicBlock(block);
|
||||
contents[x][y][z].readFromNBT(cpt, mapping);
|
||||
|
||||
switch (contents[x][y][z].getBuildingPermission()) {
|
||||
case ALL:
|
||||
break;
|
||||
case CREATIVE_ONLY:
|
||||
if (buildingPermission == BuildingPermission.ALL) {
|
||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
switch (contents[x][y][z].getBuildingPermission()) {
|
||||
case ALL:
|
||||
break;
|
||||
case CREATIVE_ONLY:
|
||||
if (buildingPermission == BuildingPermission.ALL) {
|
||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
buildingPermission = BuildingPermission.NONE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NONE:
|
||||
buildingPermission = BuildingPermission.NONE;
|
||||
break;
|
||||
} else {
|
||||
contents[x][y][z] = null;
|
||||
isComplete = false;
|
||||
}
|
||||
} else {
|
||||
contents[x][y][z] = null;
|
||||
|
@ -227,10 +232,15 @@ public class Blueprint extends BlueprintBase {
|
|||
NBTTagCompound cpt = entitiesNBT.getCompoundTagAt(i);
|
||||
|
||||
if (cpt.hasKey("entityId")) {
|
||||
int entityId = cpt.getInteger("entityId");
|
||||
SchematicEntity s = SchematicRegistry.newSchematicEntity(mapping.getEntityForId(entityId));
|
||||
s.readFromNBT(cpt, mapping);
|
||||
entities.add(s);
|
||||
Class<? extends Entity> entity = mapping.getEntityForId(cpt.getInteger("entityId"));
|
||||
|
||||
if (entity != null) {
|
||||
SchematicEntity s = SchematicRegistry.newSchematicEntity(entity);
|
||||
s.readFromNBT(cpt, mapping);
|
||||
entities.add(s);
|
||||
} else {
|
||||
isComplete = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,6 +253,7 @@ public class Blueprint extends BlueprintBase {
|
|||
nbt.setString("author", author);
|
||||
nbt.setString("name", id.name);
|
||||
nbt.setByte ("permission", (byte) buildingPermission.ordinal());
|
||||
nbt.setBoolean("isComplete", isComplete);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public abstract class BlueprintBase {
|
|||
public boolean rotate = true;
|
||||
public boolean excavate = true;
|
||||
public BuildingPermission buildingPermission = BuildingPermission.ALL;
|
||||
public boolean isComplete = true;
|
||||
|
||||
protected MappingRegistry mapping = new MappingRegistry();
|
||||
|
||||
|
|
Loading…
Reference in a new issue