entities can now have building permissions in schematics
This commit is contained in:
parent
229f064e05
commit
1d462b1794
4 changed files with 40 additions and 21 deletions
|
@ -26,7 +26,6 @@ import net.minecraftforge.common.util.Constants;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
|
|
||||||
public class SchematicEntity extends Schematic {
|
public class SchematicEntity extends Schematic {
|
||||||
|
|
||||||
public Class<? extends Entity> entity;
|
public Class<? extends Entity> entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +42,7 @@ public class SchematicEntity extends Schematic {
|
||||||
* Schematic.
|
* Schematic.
|
||||||
*/
|
*/
|
||||||
public ItemStack[] storedRequirements = new ItemStack[0];
|
public ItemStack[] storedRequirements = new ItemStack[0];
|
||||||
|
public BuildingPermission defaultPermission = BuildingPermission.ALL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getRequirementsForPlacement(IBuilderContext context, LinkedList<ItemStack> requirements) {
|
public void getRequirementsForPlacement(IBuilderContext context, LinkedList<ItemStack> requirements) {
|
||||||
|
@ -154,13 +154,11 @@ public class SchematicEntity extends Schematic {
|
||||||
|
|
||||||
rqs.add(ItemStack.loadItemStackFromNBT(sub));
|
rqs.add(ItemStack.loadItemStackFromNBT(sub));
|
||||||
} else {
|
} else {
|
||||||
// TODO: requirement can't be retreived, this blueprint is
|
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||||
// only useable in creative
|
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
// TODO: requirement can't be retreived, this blueprint is
|
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||||
// only useable in creative
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,4 +213,9 @@ public class SchematicEntity extends Schematic {
|
||||||
public int buildTime() {
|
public int buildTime() {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BuildingPermission getBuildingPermission() {
|
||||||
|
return defaultPermission;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Please check the contents of the license, which should be located
|
* Please check the contents of the license, which should be located
|
||||||
* as "LICENSE.API" in the BuildCraft source code distribution.
|
* as "LICENSE.API" in the BuildCraft source code distribution.
|
||||||
*/
|
*/
|
||||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints")
|
@API(apiVersion = "1.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints")
|
||||||
package buildcraft.api.blueprints;
|
package buildcraft.api.blueprints;
|
||||||
import cpw.mods.fml.common.API;
|
import cpw.mods.fml.common.API;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a comparable container for block positions. TODO: should this be merged with position?
|
* This class is a comparable container for integer block positions.
|
||||||
*/
|
*/
|
||||||
public class BlockIndex implements Comparable<BlockIndex> {
|
public class BlockIndex implements Comparable<BlockIndex> {
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ public class Blueprint extends BlueprintBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readEntitiesFromWorld(IBuilderContext context, TileEntity anchorTile) {
|
public void readEntitiesFromWorld(IBuilderContext context, TileEntity anchorTile) {
|
||||||
|
BptContext bptContext = (BptContext) context;
|
||||||
Translation transform = new Translation();
|
Translation transform = new Translation();
|
||||||
|
|
||||||
transform.x = -context.surroundingBox().pMin().x;
|
transform.x = -context.surroundingBox().pMin().x;
|
||||||
|
@ -146,7 +147,22 @@ public class Blueprint extends BlueprintBase {
|
||||||
|
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
s.readFromWorld(context, e);
|
s.readFromWorld(context, e);
|
||||||
|
switch (s.getBuildingPermission()) {
|
||||||
|
case ALL:
|
||||||
entities.add(s);
|
entities.add(s);
|
||||||
|
break;
|
||||||
|
case CREATIVE_ONLY:
|
||||||
|
if (bptContext.readConfiguration.allowCreative) {
|
||||||
|
if (buildingPermission == BuildingPermission.ALL) {
|
||||||
|
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||||
|
}
|
||||||
|
entities.add(s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NONE:
|
||||||
|
buildingPermission = BuildingPermission.NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue