mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Remove unnecessary API, hopefully fixed build
This commit is contained in:
1 parent
22b2b0747e
commit
5f2d8d2b8e
175 files changed
-6222
No files matched your search
@@ -1,9 +0,0 @@
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IColorRemovable {
|
||||
boolean removeColorFromBlock(World world, BlockPos pos, EnumFacing facing);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blocks")
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,30 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** This class is provided as a utility class for third-party mods that would like to easily deploy structures that are
|
||||
* written in blueprints. It does not offer control on material that needs to get in, or how the structure is deployed,
|
||||
* but allows to create contents of a blueprint in one cycle. Note that these functionalities will only work if
|
||||
* BuildCraft is installed. */
|
||||
public abstract class BlueprintDeployer {
|
||||
|
||||
/** The deployed instantiated by BuildCraft. This is set by the BuildCraft builder mod. Mods that want to work with
|
||||
* BuildCraft not installed should check for this value to be not null. */
|
||||
public static BlueprintDeployer instance;
|
||||
|
||||
/** Deploy the contents of the blueprints as if the builder was located at {pos} facing the direction dir. */
|
||||
public abstract void deployBlueprint(World world, BlockPos pos, EnumFacing facing, File file);
|
||||
|
||||
/** Deploy the contents of the byte array as if the builder was located at {pos} facing the direction dir. */
|
||||
|
||||
public abstract void deployBlueprintFromFileStream(World world, BlockPos pos, EnumFacing dir, byte[] data);
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
public final class BuilderAPI {
|
||||
public static ISchematicRegistry schematicRegistry;
|
||||
public static ISchematicHelper schematicHelper;
|
||||
|
||||
public static final int BREAK_ENERGY = 160;
|
||||
public static final int BUILD_ENERGY = 240;
|
||||
|
||||
private BuilderAPI() {}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
/** Schematics recorded in the blueprints can restrict situations where a blueprint can be used. A same schematic class
|
||||
* can have different permissions depending on its contents. It's particularly useful when fixing a schematic, if
|
||||
* blueprints that saved the previous version should not be built because of a bug (such as dupe bug on inventories). */
|
||||
public enum BuildingPermission {
|
||||
/** No restrictions, blueprints using this schematic are good in all contexts. */
|
||||
ALL,
|
||||
|
||||
/** This blueprints containing this schematic can only be used in creative. Maybe the block can't be crafted in
|
||||
* survival in the first place, or the content of the schematic is known to have dupe bugs. */
|
||||
CREATIVE_ONLY,
|
||||
|
||||
/** Blueprints containing this schematic should not be built. This is typically used when a critical problems have
|
||||
* been fixed, but older versions of the schematic are too badly broken to be retreived. */
|
||||
NONE,
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
|
||||
/** This interface provide contextual information when building or initializing blueprint slots. */
|
||||
public interface IBuilderContext {
|
||||
|
||||
Vec3d rotatePositionLeft(Vec3d pos);
|
||||
|
||||
IBox surroundingBox();
|
||||
|
||||
World world();
|
||||
|
||||
MappingRegistry getMappingRegistry();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISchematicHelper {
|
||||
boolean isEqualItem(ItemStack a, ItemStack b);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface ISchematicRegistry {
|
||||
void registerSchematicBlock(Block block, Class<? extends Schematic> clazz, Object... params);
|
||||
|
||||
void registerSchematicBlock(IBlockState state, Class<? extends Schematic> clazz, Object... params);
|
||||
|
||||
void registerSchematicEntity(Class<? extends Entity> entityClass, Class<? extends SchematicEntity> schematicClass, Object... params);
|
||||
|
||||
boolean isSupported(IBlockState state);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public interface ITileBuilder extends IInventory {
|
||||
|
||||
boolean isBuildingMaterialSlot(int i);
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
public class MappingNotFoundException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MappingNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,426 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.FMLModContainer;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
// Deprecated as NBT will be saved in a compressing format rather than only for blocks, items and entities.
|
||||
@Deprecated
|
||||
public class MappingRegistry {
|
||||
|
||||
public HashMap<Block, Integer> blockToId = new HashMap<Block, Integer>();
|
||||
public ArrayList<Block> idToBlock = new ArrayList<Block>();
|
||||
|
||||
public HashMap<Item, Integer> itemToId = new HashMap<Item, Integer>();
|
||||
public ArrayList<Item> idToItem = new ArrayList<Item>();
|
||||
|
||||
public HashMap<Class<? extends Entity>, Integer> entityToId = new HashMap<Class<? extends Entity>, Integer>();
|
||||
public ArrayList<Class<? extends Entity>> idToEntity = new ArrayList<Class<? extends Entity>>();
|
||||
|
||||
private void registerItem(Item item) {
|
||||
if (item == null) throw new IllegalArgumentException("Cannot register a null item!");
|
||||
if (!itemToId.containsKey(item)) {
|
||||
idToItem.add(item);
|
||||
itemToId.put(item, idToItem.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBlock(Block block) {
|
||||
if (block == null) throw new IllegalArgumentException("Cannot register a null block!");
|
||||
if (!blockToId.containsKey(block)) {
|
||||
idToBlock.add(block);
|
||||
blockToId.put(block, idToBlock.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerEntity(Class<? extends Entity> entityClass) {
|
||||
if (entityClass == null) throw new IllegalArgumentException("Cannot register a null entityClass!");
|
||||
if (!entityToId.containsKey(entityClass)) {
|
||||
idToEntity.add(entityClass);
|
||||
entityToId.put(entityClass, idToEntity.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public Item getItemForId(int id) throws MappingNotFoundException {
|
||||
if (id >= idToItem.size()) {
|
||||
throw new MappingNotFoundException("no item mapping at position " + id);
|
||||
}
|
||||
|
||||
Item result = idToItem.get(id);
|
||||
|
||||
if (result == null) {
|
||||
throw new MappingNotFoundException("no item mapping at position " + id);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIdForItem(Item item) {
|
||||
if (item == null) throw new NullPointerException("item");
|
||||
if (!itemToId.containsKey(item)) {
|
||||
registerItem(item);
|
||||
}
|
||||
|
||||
return itemToId.get(item);
|
||||
}
|
||||
|
||||
public int itemIdToRegistry(int id) {
|
||||
Item item = Item.getItemById(id);
|
||||
|
||||
return getIdForItem(item);
|
||||
}
|
||||
|
||||
public ResourceLocation itemIdToWorld(int id) throws MappingNotFoundException {
|
||||
Item item = getItemForId(id);
|
||||
|
||||
return Item.REGISTRY.getNameForObject(item);
|
||||
}
|
||||
|
||||
public Block getBlockForId(int id) throws MappingNotFoundException {
|
||||
if (id >= idToBlock.size()) {
|
||||
throw new MappingNotFoundException("no block mapping at position " + id);
|
||||
}
|
||||
|
||||
Block result = idToBlock.get(id);
|
||||
|
||||
if (result == null) {
|
||||
throw new MappingNotFoundException("no block mapping at position " + id);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIdForBlock(Block block) {
|
||||
if (!blockToId.containsKey(block)) {
|
||||
registerBlock(block);
|
||||
}
|
||||
|
||||
return blockToId.get(block);
|
||||
}
|
||||
|
||||
public int blockIdToRegistry(int id) {
|
||||
Block block = Block.getBlockById(id);
|
||||
|
||||
return getIdForBlock(block);
|
||||
}
|
||||
|
||||
public ResourceLocation blockIdToWorld(int id) throws MappingNotFoundException {
|
||||
Block block = getBlockForId(id);
|
||||
|
||||
return Block.REGISTRY.getNameForObject(block);
|
||||
}
|
||||
|
||||
public Class<? extends Entity> getEntityForId(int id) throws MappingNotFoundException {
|
||||
if (id >= idToEntity.size()) {
|
||||
throw new MappingNotFoundException("no entity mapping at position " + id);
|
||||
}
|
||||
|
||||
Class<? extends Entity> result = idToEntity.get(id);
|
||||
|
||||
if (result == null) {
|
||||
throw new MappingNotFoundException("no entity mapping at position " + id);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIdForEntity(Class<? extends Entity> entity) {
|
||||
if (!entityToId.containsKey(entity)) {
|
||||
registerEntity(entity);
|
||||
}
|
||||
|
||||
return entityToId.get(entity);
|
||||
}
|
||||
|
||||
/** Relocates a stack nbt from the registry referential to the world referential. */
|
||||
public void stackToWorld(NBTTagCompound nbt) throws MappingNotFoundException {
|
||||
// 1.7.10 back-compat
|
||||
if (nbt.hasKey("id", Constants.NBT.TAG_SHORT)) {
|
||||
Item item = getItemForId(nbt.getShort("id"));
|
||||
nbt.setString("id", (Item.REGISTRY.getNameForObject(item).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// versions before 1.8 saved stacks with an Item ID as a short
|
||||
private boolean isOldStackLayout(NBTTagCompound nbt) {
|
||||
return nbt.hasKey("id") && nbt.hasKey("Count") && nbt.hasKey("Damage") && nbt.getTag("id") instanceof NBTTagShort && nbt.getTag(
|
||||
"Count") instanceof NBTTagByte && nbt.getTag("Damage") instanceof NBTTagShort;
|
||||
}
|
||||
|
||||
// 1.7.10 Back compat
|
||||
public void scanAndTranslateStacksToWorld(NBTTagCompound nbt) throws MappingNotFoundException {
|
||||
// First, check if this nbt is itself a stack
|
||||
|
||||
if (isOldStackLayout(nbt)) {
|
||||
stackToWorld(nbt);
|
||||
}
|
||||
|
||||
// Then, look at the nbt compound contained in this nbt (even if it's a
|
||||
// stack) and checks for stacks in it.
|
||||
for (String key : (Collection<String>) nbt.getKeySet()) {
|
||||
if (nbt.getTag(key) instanceof NBTTagCompound) {
|
||||
try {
|
||||
scanAndTranslateStacksToWorld(nbt.getCompoundTag(key));
|
||||
} catch (MappingNotFoundException e) {
|
||||
nbt.removeTag(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (nbt.getTag(key) instanceof NBTTagList) {
|
||||
NBTTagList list = (NBTTagList) nbt.getTag(key);
|
||||
|
||||
if (list.getTagType() == Constants.NBT.TAG_COMPOUND) {
|
||||
for (int i = list.tagCount() - 1; i >= 0; --i) {
|
||||
try {
|
||||
scanAndTranslateStacksToWorld(list.getCompoundTagAt(i));
|
||||
} catch (MappingNotFoundException e) {
|
||||
list.removeTag(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void write(NBTTagCompound nbt) {
|
||||
NBTTagList blocksMapping = new NBTTagList();
|
||||
|
||||
for (Block b : idToBlock) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
if (b != null) {
|
||||
Object obj = Block.REGISTRY.getNameForObject(b);
|
||||
if (obj == null) {
|
||||
BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName()
|
||||
+ ") does not have a registry name! This is a bug!");
|
||||
} else {
|
||||
String name = obj.toString();
|
||||
if (name == null || name.length() == 0) {
|
||||
BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName()
|
||||
+ ") has an empty registry name! This is a bug!");
|
||||
} else {
|
||||
sub.setString("name", name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Found a null block!");
|
||||
}
|
||||
blocksMapping.appendTag(sub);
|
||||
}
|
||||
|
||||
nbt.setTag("blocksMapping", blocksMapping);
|
||||
|
||||
NBTTagList itemsMapping = new NBTTagList();
|
||||
|
||||
for (Item i : idToItem) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
if (i != null) {
|
||||
ResourceLocation obj = Item.REGISTRY.getNameForObject(i);
|
||||
if (obj == null) {
|
||||
BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName()
|
||||
+ ") does not have a registry name! This is a bug!");
|
||||
} else {
|
||||
String name = obj.toString();
|
||||
if (name == null || name.length() == 0) {
|
||||
BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName()
|
||||
+ ") has an empty registry name! This is a bug!");
|
||||
} else {
|
||||
sub.setString("name", name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Found a null item!");
|
||||
}
|
||||
itemsMapping.appendTag(sub);
|
||||
}
|
||||
|
||||
nbt.setTag("itemsMapping", itemsMapping);
|
||||
|
||||
NBTTagList entitiesMapping = new NBTTagList();
|
||||
|
||||
for (Class<? extends Entity> e : idToEntity) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
sub.setString("name", e.getCanonicalName());
|
||||
entitiesMapping.appendTag(sub);
|
||||
}
|
||||
|
||||
nbt.setTag("entitiesMapping", entitiesMapping);
|
||||
|
||||
// System.out.println("[W] idToItem size : " + idToItem.size());
|
||||
// for (Item i : idToItem) {
|
||||
// System.out.println("- " + (i != null ? i.toString() : "null"));
|
||||
// }
|
||||
}
|
||||
|
||||
private Object getMissingMappingFromFML(boolean isBlock, String name, int i) {
|
||||
ResourceLocation location = new ResourceLocation(name);
|
||||
String modName = name.split(":")[0];
|
||||
if (Loader.isModLoaded(modName)) {
|
||||
try {
|
||||
FMLMissingMappingsEvent.MissingMapping mapping = new FMLMissingMappingsEvent.MissingMapping(isBlock ? GameRegistry.Type.BLOCK
|
||||
: GameRegistry.Type.ITEM, location, i);
|
||||
ListMultimap<String, FMLMissingMappingsEvent.MissingMapping> missingMapping = ArrayListMultimap.create();
|
||||
missingMapping.put(modName, mapping);
|
||||
FMLMissingMappingsEvent event = new FMLMissingMappingsEvent(missingMapping);
|
||||
for (ModContainer container : Loader.instance().getModList()) {
|
||||
if (container instanceof FMLModContainer) {
|
||||
event.applyModContainer(container);
|
||||
((FMLModContainer) container).handleModStateEvent(event);
|
||||
if (mapping.getAction() != FMLMissingMappingsEvent.Action.DEFAULT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mapping.getAction() == FMLMissingMappingsEvent.Action.REMAP) {
|
||||
return mapping.getTarget();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void read(NBTTagCompound nbt) {
|
||||
NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < blocksMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
|
||||
if (!sub.hasKey("name")) {
|
||||
// Keeping the order correct
|
||||
idToBlock.add(null);
|
||||
BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
|
||||
continue;
|
||||
}
|
||||
String name = sub.getString("name");
|
||||
ResourceLocation location = new ResourceLocation(name);
|
||||
Block b = null;
|
||||
|
||||
if (!Block.REGISTRY.containsKey(location) && name.contains(":")) {
|
||||
b = (Block) getMissingMappingFromFML(true, name, i);
|
||||
if (b != null) {
|
||||
BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b));
|
||||
}
|
||||
}
|
||||
|
||||
if (b == null && Block.REGISTRY.containsKey(location)) {
|
||||
b = (Block) Block.REGISTRY.getObject(location);
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
registerBlock(b);
|
||||
} else {
|
||||
// Keeping the order correct
|
||||
idToBlock.add(null);
|
||||
BCLog.logger.log(Level.WARN, "Can't load block " + name);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < itemsMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
|
||||
if (!sub.hasKey("name")) {
|
||||
// Keeping the order correct
|
||||
idToItem.add(null);
|
||||
BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = sub.getString("name");
|
||||
ResourceLocation location = new ResourceLocation(name);
|
||||
Item item = null;
|
||||
|
||||
if (!Item.REGISTRY.containsKey(location) && name.contains(":")) {
|
||||
item = (Item) getMissingMappingFromFML(false, name, i);
|
||||
if (item != null) {
|
||||
BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item));
|
||||
}
|
||||
}
|
||||
|
||||
if (item == null && Item.REGISTRY.containsKey(location)) {
|
||||
item = (Item) Item.REGISTRY.getObject(location);
|
||||
}
|
||||
|
||||
if (item != null) {
|
||||
registerItem(item);
|
||||
} else {
|
||||
// Keeping the order correct
|
||||
idToItem.add(null);
|
||||
BCLog.logger.log(Level.WARN, "Can't load item " + name);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
|
||||
String name = sub.getString("name");
|
||||
Class<? extends Entity> e = null;
|
||||
|
||||
try {
|
||||
e = (Class<? extends Entity>) Class.forName(name);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (e != null) {
|
||||
registerEntity(e);
|
||||
} else {
|
||||
// Keeping the order correct
|
||||
idToEntity.add(null);
|
||||
BCLog.logger.log(Level.WARN, "Can't load entity " + name);
|
||||
}
|
||||
}
|
||||
|
||||
// System.out.println("[R] idToItem size : " + idToItem.size());
|
||||
// for (Item i : idToItem) {
|
||||
// System.out.println("- " + (i != null ? i.toString() : "null"));
|
||||
// }
|
||||
}
|
||||
|
||||
public void addToCrashReport(CrashReportCategory cat) {
|
||||
cat.addCrashSection("Item Map Count", itemToId.size());
|
||||
for (Entry<Item, Integer> e : itemToId.entrySet()) {
|
||||
cat.addCrashSection(" - ID " + e.getValue(), Item.REGISTRY.getNameForObject(e.getKey()));
|
||||
}
|
||||
|
||||
cat.addCrashSection("Block Map Count", blockToId.size());
|
||||
for (Entry<Block, Integer> e : blockToId.entrySet()) {
|
||||
cat.addCrashSection(" - ID " + e.getValue(), Block.REGISTRY.getNameForObject(e.getKey()));
|
||||
}
|
||||
|
||||
cat.addCrashSection("Entity Map Count", entityToId.size());
|
||||
for (Entry<Class<? extends Entity>, Integer> e : entityToId.entrySet()) {
|
||||
cat.addCrashSection(" - ID " + e.getValue(), e.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import buildcraft.api.core.IInvSlot;
|
||||
|
||||
/** A schematic is a piece of a blueprint. It allows to stock blocks or entities to blueprints, and can have a state
|
||||
* that moves from a blueprint referential to a world referential. Although default schematic behavior will be OK for a
|
||||
* lot of objects, specific blocks and entities may be associated with a dedicated schematic class, which will be
|
||||
* instantiated automatically.
|
||||
*
|
||||
* Schematic perform "id translation" in case the block ids between a blueprint and the world installation are
|
||||
* different. Mapping is done through the builder context.
|
||||
*
|
||||
* Detailed documentation on the schematic behavior can be found on
|
||||
* http://www.mod-buildcraft.com/wiki/doku.php?id=builder_support
|
||||
*
|
||||
* Example of schematics for minecraft blocks are available in the package buildcraft.core.schematics. */
|
||||
public abstract class Schematic {
|
||||
/** Blocks are build in various stages, in order to make sure that a block can indeed be placed, and that it's
|
||||
* unlikely to disturb other blocks. */
|
||||
public enum BuildingStage {
|
||||
/** Standalone blocks do not change once placed. */
|
||||
STANDALONE,
|
||||
|
||||
/** Expanding blocks will grow and may disturb other block locations, like liquids. */
|
||||
EXPANDING
|
||||
}
|
||||
|
||||
/** This is called to verify whether the required item is equal to the supplied item.
|
||||
*
|
||||
* Primarily rely on this for checking metadata/NBT - the item ID itself might have been filtered out by previously
|
||||
* running code. */
|
||||
public boolean isItemMatchingRequirement(ItemStack suppliedStack, ItemStack requiredStack) {
|
||||
return BuilderAPI.schematicHelper.isEqualItem(suppliedStack, requiredStack);
|
||||
}
|
||||
|
||||
/** This is called each time an item matches a requirement. By default, it will increase damage of items that can be
|
||||
* damaged by the amount of the requirement, and remove the intended amount of items that can't be damaged.
|
||||
*
|
||||
* Client may override this behavior. Note that this subprogram may be called twice with the same parameters, once
|
||||
* with a copy of requirements and stack to check if the entire requirements can be fulfilled, and once with the
|
||||
* real inventory. Implementer is responsible for updating req (with the remaining requirements if any) and slot
|
||||
* (after usage).
|
||||
*
|
||||
* returns what was used (similar to req, but created from slot, so that any NBT based differences are drawn from
|
||||
* the correct source) */
|
||||
public ItemStack useItem(IBuilderContext context, ItemStack req, IInvSlot slot) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
ItemStack result = stack.copy();
|
||||
|
||||
if (stack.isItemStackDamageable()) {
|
||||
if (req.getItemDamage() + stack.getItemDamage() <= stack.getMaxDamage()) {
|
||||
stack.setItemDamage(req.getItemDamage() + stack.getItemDamage());
|
||||
result.setItemDamage(req.getItemDamage());
|
||||
req.stackSize = 0;
|
||||
}
|
||||
|
||||
if (stack.getItemDamage() >= stack.getMaxDamage()) {
|
||||
slot.decreaseStackInSlot(1);
|
||||
}
|
||||
} else {
|
||||
if (stack.stackSize >= req.stackSize) {
|
||||
result.stackSize = req.stackSize;
|
||||
stack.stackSize -= req.stackSize;
|
||||
req.stackSize = 0;
|
||||
} else {
|
||||
req.stackSize -= stack.stackSize;
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.stackSize == 0) {
|
||||
stack.stackSize = 1;
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
ItemStack newStack = stack.getItem().getContainerItem(stack);
|
||||
slot.setStackInSlot(newStack);
|
||||
} else {
|
||||
slot.setStackInSlot(null);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Perform a 90 degree rotation to the slot. */
|
||||
public void rotateLeft(IBuilderContext context) {
|
||||
|
||||
}
|
||||
|
||||
/** Applies translations to all positions in the schematic to center in the blueprint referential */
|
||||
public void translateToBlueprint(Vec3d transform) {
|
||||
|
||||
}
|
||||
|
||||
/** Apply translations to all positions in the schematic to center in the builder referential */
|
||||
public void translateToWorld(Vec3d transform) {}
|
||||
|
||||
/** Translates blocks and item ids to the blueprint referential */
|
||||
public void idsToBlueprint(MappingRegistry registry) {}
|
||||
|
||||
/** Translates blocks and item ids to the world referential */
|
||||
public void idsToWorld(MappingRegistry registry) {}
|
||||
|
||||
/** Initializes a schematic for blueprint according to an objet placed on {x, y, z} on the world. For blocks, block
|
||||
* and meta fields will be initialized automatically. */
|
||||
public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) {}
|
||||
|
||||
/** Places the block in the world, at the location specified in the slot, using the stack in parameters */
|
||||
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {}
|
||||
|
||||
/** Write specific requirements coming from the world to the blueprint. */
|
||||
public void storeRequirements(IBuilderContext context, BlockPos pos) {}
|
||||
|
||||
/** Returns the requirements needed to build this block. When the requirements are met, they will be removed all at
|
||||
* once from the builder, before calling writeToWorld. */
|
||||
public void getRequirementsForPlacement(IBuilderContext context, List<ItemStack> requirements) {}
|
||||
|
||||
/** Returns the amount of energy required to build this slot, depends on the stacks selected for the build. */
|
||||
public int getEnergyRequirement(List<ItemStack> stacksUsed) {
|
||||
int result = 0;
|
||||
|
||||
if (stacksUsed != null) {
|
||||
for (ItemStack s : stacksUsed) {
|
||||
result += s.stackSize * BuilderAPI.BUILD_ENERGY;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the flying stacks to display in the builder animation. */
|
||||
public List<ItemStack> getStacksToDisplay(List<ItemStack> stackConsumed) {
|
||||
return stackConsumed;
|
||||
}
|
||||
|
||||
/** Return the stage where this schematic has to be built. */
|
||||
public BuildingStage getBuildStage() {
|
||||
return BuildingStage.STANDALONE;
|
||||
}
|
||||
|
||||
/** Return true if the block on the world correspond to the block stored in the blueprint at the location given by
|
||||
* the slot. By default, this subprogram is permissive and doesn't take into account metadata.
|
||||
*
|
||||
* Post processing will be called on these blocks. */
|
||||
public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* Post processing will be called on these blocks. */
|
||||
public boolean doNotBuild() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Return true if the schematic should not be used at all. This is computed straight after readFromNBT can be used
|
||||
* to deactivate schematics in which an inconsistency is detected. It will be considered as a block of air instead.
|
||||
*
|
||||
* Post processing will *not* be called on these blocks. */
|
||||
public boolean doNotUse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Return the maximium building permission for blueprint containing this schematic. */
|
||||
public BuildingPermission getBuildingPermission() {
|
||||
return BuildingPermission.ALL;
|
||||
}
|
||||
|
||||
/** Called on a block when the blueprint has finished to place all the blocks. This may be useful to adjust variable
|
||||
* depending on surrounding blocks that may not be there already at initial building. */
|
||||
public void postProcessing(IBuilderContext context, BlockPos pos) {}
|
||||
|
||||
/** Saves this schematic to the blueprint NBT. */
|
||||
public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {}
|
||||
|
||||
/** Loads this schematic from the blueprint NBT. */
|
||||
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {}
|
||||
|
||||
/** Returns the number of cycles to wait after building this schematic. Tiles and entities typically require more
|
||||
* wait, around 5 cycles. */
|
||||
public int buildTime() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
public class SchematicBlock extends SchematicBlockBase {
|
||||
public IBlockState state = null;
|
||||
public BuildingPermission defaultPermission = BuildingPermission.ALL;
|
||||
|
||||
/** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this
|
||||
* list or compute their own int Schematic. */
|
||||
public ItemStack[] storedRequirements = new ItemStack[0];
|
||||
|
||||
private boolean doNotUse = false;
|
||||
|
||||
@Override
|
||||
public void getRequirementsForPlacement(IBuilderContext context, List<ItemStack> requirements) {
|
||||
if (state != null) {
|
||||
if (storedRequirements.length != 0) {
|
||||
Collections.addAll(requirements, storedRequirements);
|
||||
} else {
|
||||
requirements.add(getItemStack(state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) {
|
||||
IBlockState placed = context.world().getBlockState(pos);
|
||||
if (state == placed) return true;
|
||||
if (state.getBlock() != placed.getBlock()) return false;
|
||||
// This fixes bugs with blocks like stairs that return extra properties that were not visible from the meta.
|
||||
if (state.getBlock().getMetaFromState(state) == placed.getBlock().getMetaFromState(placed)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
|
||||
super.placeInWorld(context, pos, stacks);
|
||||
|
||||
this.setBlockInWorld(context, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeRequirements(IBuilderContext context, BlockPos pos) {
|
||||
super.storeRequirements(context, pos);
|
||||
|
||||
if (state != null) {
|
||||
List<ItemStack> req = state.getBlock().getDrops(context.world(), pos, state, 0);
|
||||
|
||||
if (req != null) {
|
||||
storedRequirements = new ItemStack[req.size()];
|
||||
req.toArray(storedRequirements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.writeSchematicToNBT(nbt, registry);
|
||||
|
||||
writeBlockToNBT(nbt, registry);
|
||||
writeRequirementsToNBT(nbt, registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.readSchematicFromNBT(nbt, registry);
|
||||
|
||||
readBlockFromNBT(nbt, registry);
|
||||
if (!doNotUse()) {
|
||||
readRequirementsFromNBT(nbt, registry);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a list of relative block coordinates which have to be built before this block can be placed. */
|
||||
public Set<BlockPos> getPrerequisiteBlocks(IBuilderContext context) {
|
||||
Set<BlockPos> indexes = new HashSet<BlockPos>();
|
||||
if (state.getBlock() instanceof BlockFalling) {
|
||||
indexes.add(new BlockPos(0, -1, 0));
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildingStage getBuildStage() {
|
||||
if (state.getBlock() instanceof BlockFluidBase || state.getBlock() instanceof BlockLiquid) {
|
||||
return BuildingStage.EXPANDING;
|
||||
} else {
|
||||
return BuildingStage.STANDALONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildingPermission getBuildingPermission() {
|
||||
return defaultPermission;
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
protected void setBlockInWorld(IBuilderContext context, BlockPos pos) {
|
||||
context.world().setBlockState(pos, state, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doNotUse() {
|
||||
return doNotUse;
|
||||
}
|
||||
|
||||
protected void readBlockFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
try {
|
||||
Block block = registry.getBlockForId(nbt.getInteger("blockId"));
|
||||
state = block.getStateFromMeta(nbt.getInteger("blockMeta"));
|
||||
} catch (MappingNotFoundException e) {
|
||||
BCLog.logger.info(e);
|
||||
doNotUse = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void readRequirementsFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
if (nbt.hasKey("rq")) {
|
||||
NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < rq.tagCount(); ++i) {
|
||||
try {
|
||||
NBTTagCompound sub = rq.getCompoundTagAt(i);
|
||||
registry.stackToWorld(sub);
|
||||
rqs.add(ItemStack.loadItemStackFromNBT(sub));
|
||||
} catch (MappingNotFoundException e) {
|
||||
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
storedRequirements = rqs.toArray(new ItemStack[rqs.size()]);
|
||||
} else {
|
||||
storedRequirements = new ItemStack[0];
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeBlockToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
nbt.setInteger("blockId", registry.getIdForBlock(state.getBlock()));
|
||||
nbt.setInteger("blockMeta", state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
|
||||
protected void writeRequirementsToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
if (storedRequirements.length > 0) {
|
||||
NBTTagList rq = new NBTTagList();
|
||||
|
||||
for (ItemStack stack : storedRequirements) {
|
||||
if (stack == null || stack.getItem() == null) throw new IllegalStateException("Found a null requirement! " + getClass());
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
stack.writeToNBT(sub);
|
||||
rq.appendTag(sub);
|
||||
}
|
||||
|
||||
nbt.setTag("rq", rq);
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getItemStack(IBlockState state, int quantity) {
|
||||
return new ItemStack(state.getBlock(), quantity, state.getBlock().damageDropped(state));
|
||||
}
|
||||
|
||||
protected ItemStack getItemStack(IBlockState state) {
|
||||
return getItemStack(state, 1);
|
||||
}
|
||||
|
||||
// Pretty much all blocks (that rotate) rotate this way now
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context) {
|
||||
// FIXME: This might be the wrong way
|
||||
state = state.withRotation(Rotation.CLOCKWISE_90);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
public abstract class SchematicBlockBase extends Schematic {
|
||||
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class SchematicEntity extends Schematic {
|
||||
public Class<? extends Entity> entity;
|
||||
|
||||
/** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from
|
||||
* Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded
|
||||
* from BptBlock.writeToWorld using the standard writeNBT function. */
|
||||
public NBTTagCompound entityNBT = new NBTTagCompound();
|
||||
|
||||
/** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this
|
||||
* list or compute their own int Schematic. */
|
||||
public ItemStack[] storedRequirements = new ItemStack[0];
|
||||
public BuildingPermission defaultPermission = BuildingPermission.ALL;
|
||||
|
||||
@Override
|
||||
public void getRequirementsForPlacement(IBuilderContext context, List<ItemStack> requirements) {
|
||||
Collections.addAll(requirements, storedRequirements);
|
||||
}
|
||||
|
||||
public void writeToWorld(IBuilderContext context) {
|
||||
Entity e = EntityList.createEntityFromNBT(entityNBT, context.world());
|
||||
context.world().spawnEntityInWorld(e);
|
||||
}
|
||||
|
||||
public void readFromWorld(IBuilderContext context, Entity entity) {
|
||||
entity.writeToNBTOptional(entityNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateToBlueprint(Vec3d transform) {
|
||||
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
|
||||
Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2));
|
||||
pos = pos.add(transform);
|
||||
entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateToWorld(Vec3d transform) {
|
||||
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
|
||||
Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2));
|
||||
pos = pos.add(transform);
|
||||
|
||||
entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void idsToBlueprint(MappingRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void idsToWorld(MappingRegistry registry) {
|
||||
try {
|
||||
registry.scanAndTranslateStacksToWorld(entityNBT);
|
||||
} catch (MappingNotFoundException e) {
|
||||
entityNBT = new NBTTagCompound();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context) {
|
||||
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
|
||||
Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2));
|
||||
pos = context.rotatePositionLeft(pos);
|
||||
entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord));
|
||||
|
||||
nbttaglist = entityNBT.getTagList("Rotation", 5);
|
||||
float yaw = nbttaglist.getFloatAt(0);
|
||||
yaw += 90;
|
||||
entityNBT.setTag("Rotation", this.newFloatNBTList(yaw, nbttaglist.getFloatAt(1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.writeSchematicToNBT(nbt, registry);
|
||||
|
||||
nbt.setInteger("entityId", registry.getIdForEntity(entity));
|
||||
nbt.setTag("entity", entityNBT);
|
||||
|
||||
NBTTagList rq = new NBTTagList();
|
||||
|
||||
for (ItemStack stack : storedRequirements) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
stack.writeToNBT(stack.writeToNBT(sub));
|
||||
sub.setInteger("id", registry.getIdForItem(stack.getItem()));
|
||||
rq.appendTag(sub);
|
||||
}
|
||||
|
||||
nbt.setTag("rq", rq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.readSchematicFromNBT(nbt, registry);
|
||||
|
||||
entityNBT = nbt.getCompoundTag("entity");
|
||||
|
||||
NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 0; i < rq.tagCount(); ++i) {
|
||||
try {
|
||||
NBTTagCompound sub = rq.getCompoundTagAt(i);
|
||||
|
||||
if (sub.getInteger("id") >= 0) {
|
||||
// Maps the id in the blueprint to the id in the world
|
||||
sub.setInteger("id", Item.REGISTRY.getIDForObject(registry.getItemForId(sub.getInteger("id"))));
|
||||
|
||||
rqs.add(ItemStack.loadItemStackFromNBT(sub));
|
||||
} else {
|
||||
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
defaultPermission = BuildingPermission.CREATIVE_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
storedRequirements = rqs.toArray(new ItemStack[rqs.size()]);
|
||||
}
|
||||
|
||||
protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
double[] adouble = par1ArrayOfDouble;
|
||||
int i = par1ArrayOfDouble.length;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
double d1 = adouble[j];
|
||||
nbttaglist.appendTag(new NBTTagDouble(d1));
|
||||
}
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
protected NBTTagList newFloatNBTList(float... par1ArrayOfFloat) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
float[] afloat = par1ArrayOfFloat;
|
||||
int i = par1ArrayOfFloat.length;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
float f1 = afloat[j];
|
||||
nbttaglist.appendTag(new NBTTagFloat(f1));
|
||||
}
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public boolean isAlreadyBuilt(IBuilderContext context) {
|
||||
NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
|
||||
Vec3d newPosition = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2));
|
||||
|
||||
for (Object o : context.world().loadedEntityList) {
|
||||
Entity e = (Entity) o;
|
||||
|
||||
Vec3d existingPositon = new Vec3d(e.posX, e.posY, e.posZ);
|
||||
|
||||
if (existingPositon.distanceTo(newPosition) <= 0.1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int buildTime() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildingPermission getBuildingPermission() {
|
||||
return defaultPermission;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class SchematicFactory<S extends Schematic> {
|
||||
|
||||
private static final HashMap<String, SchematicFactory<?>> factories = new HashMap<String, SchematicFactory<?>>();
|
||||
|
||||
private static final HashMap<Class<? extends Schematic>, SchematicFactory<?>> schematicToFactory =
|
||||
new HashMap<Class<? extends Schematic>, SchematicFactory<?>>();
|
||||
|
||||
protected abstract S loadSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException;
|
||||
|
||||
public void saveSchematicToWorldNBT(NBTTagCompound nbt, S object, MappingRegistry registry) {
|
||||
nbt.setString("factoryID", getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
public static Schematic createSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException {
|
||||
String factoryName = nbt.getString("factoryID");
|
||||
|
||||
if (factories.containsKey(factoryName)) {
|
||||
return factories.get(factoryName).loadSchematicFromWorldNBT(nbt, registry);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerSchematicFactory(Class<? extends Schematic> clas, SchematicFactory<?> factory) {
|
||||
schematicToFactory.put(clas, factory);
|
||||
factories.put(factory.getClass().getCanonicalName(), factory);
|
||||
}
|
||||
|
||||
public static SchematicFactory getFactory(Class<? extends Schematic> clas) {
|
||||
Class superClass = clas.getSuperclass();
|
||||
|
||||
if (schematicToFactory.containsKey(clas)) {
|
||||
return schematicToFactory.get(clas);
|
||||
} else if (superClass != null) {
|
||||
return getFactory(superClass);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class SchematicFluid extends SchematicBlock {
|
||||
|
||||
private final ItemStack fluidItem;
|
||||
|
||||
public SchematicFluid(FluidStack fluidStack) {
|
||||
this.fluidItem = new ItemStack(fluidStack.getFluid().getBlock(), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRequirementsForPlacement(IBuilderContext context, List<ItemStack> requirements) {
|
||||
if (getLevel() == 0) {
|
||||
requirements.add(fluidItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeRequirements(IBuilderContext context, BlockPos pos) {
|
||||
// cancel requirements reading
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) {
|
||||
if (getLevel() == 0) {
|
||||
return state == context.world().getBlockState(pos) && ((Integer) context.world().getBlockState(pos).getValue(BlockLiquid.LEVEL)) == 0;
|
||||
} else {
|
||||
return state == context.world().getBlockState(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doNotBuild() {
|
||||
return getLevel() != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
|
||||
if (getLevel() == 0) {
|
||||
context.world().setBlockState(pos, state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessing(IBuilderContext context, BlockPos pos) {
|
||||
if (getLevel() != 0) {
|
||||
context.world().setBlockState(pos, state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getStacksToDisplay(List<ItemStack> stackConsumed) {
|
||||
List<ItemStack> result = new ArrayList<ItemStack>();
|
||||
result.add(fluidItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyRequirement(List<ItemStack> stacksUsed) {
|
||||
return 1 * BuilderAPI.BUILD_ENERGY;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return (Integer) state.getValue(BlockLiquid.LEVEL);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
|
||||
public class SchematicMask extends SchematicBlockBase {
|
||||
/** True of the block should be a solid block (stone, grass or a furnace) and false if it shouldn't (flowers, air or
|
||||
* vines) */
|
||||
public boolean isConcrete = true;
|
||||
|
||||
public SchematicMask() {
|
||||
|
||||
}
|
||||
|
||||
public SchematicMask(boolean isConcrete) {
|
||||
this.isConcrete = isConcrete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
|
||||
if (isConcrete) {
|
||||
if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), pos)) {
|
||||
return;
|
||||
} else {
|
||||
ItemStack stack = stacks.get(0);
|
||||
EntityPlayer player = BuildCraftAPI.fakePlayerProvider.getBuildCraftPlayer((WorldServer) context.world()).get();
|
||||
|
||||
// force the block to be air block, in case it's just a soft
|
||||
// block which replacement is not straightforward
|
||||
context.world().setBlockToAir(pos);
|
||||
|
||||
// Find nearest solid surface to place on
|
||||
EnumFacing solidFace = null;
|
||||
for (EnumFacing face : EnumFacing.values()) {
|
||||
BlockPos offset = pos.offset(face);
|
||||
if (!BuildCraftAPI.isSoftBlock(context.world(), offset)) {
|
||||
solidFace = face;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ItemBlock itemBlock = (ItemBlock) stack.getItem();
|
||||
IBlockState state = itemBlock.block.onBlockPlaced(context.world(), pos, solidFace, 0, 0, 0, stack.getMetadata(), player);
|
||||
itemBlock.placeBlockAt(stack, player, context.world(), pos, solidFace, 0, 0, 0, state);
|
||||
|
||||
}
|
||||
} else {
|
||||
context.world().setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) {
|
||||
if (isConcrete) {
|
||||
return !BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos);
|
||||
} else {
|
||||
return BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
nbt.setBoolean("isConcrete", isConcrete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
isConcrete = nbt.getBoolean("isConcrete");
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import buildcraft.api.core.JavaTools;
|
||||
|
||||
public class SchematicTile extends SchematicBlock {
|
||||
|
||||
/** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from
|
||||
* Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded
|
||||
* from BptBlock.writeToWorld using the standard writeNBT function. */
|
||||
public NBTTagCompound tileNBT = new NBTTagCompound();
|
||||
|
||||
@Override
|
||||
public void idsToBlueprint(MappingRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void idsToWorld(MappingRegistry registry) {
|
||||
try {
|
||||
registry.scanAndTranslateStacksToWorld(tileNBT);
|
||||
} catch (MappingNotFoundException e) {
|
||||
tileNBT = new NBTTagCompound();
|
||||
}
|
||||
}
|
||||
|
||||
public void onNBTLoaded() {
|
||||
|
||||
}
|
||||
|
||||
/** Places the block in the world, at the location specified in the slot. */
|
||||
@Override
|
||||
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
|
||||
super.placeInWorld(context, pos, stacks);
|
||||
|
||||
if (state.getBlock().hasTileEntity(state)) {
|
||||
tileNBT.setInteger("x", pos.getX());
|
||||
tileNBT.setInteger("y", pos.getY());
|
||||
tileNBT.setInteger("z", pos.getZ());
|
||||
// The minecraft server argument doesn't seem to be used...
|
||||
TileEntity tile = TileEntity.create(tileNBT);
|
||||
tile.setWorldObj(context.world());
|
||||
context.world().setTileEntity(pos, tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) {
|
||||
super.initializeFromObjectAt(context, pos);
|
||||
|
||||
if (state.getBlock().hasTileEntity(state)) {
|
||||
TileEntity tile = context.world().getTileEntity(pos);
|
||||
|
||||
if (tile != null) {
|
||||
tile.writeToNBT(tileNBT);
|
||||
}
|
||||
|
||||
tileNBT = (NBTTagCompound) tileNBT.copy();
|
||||
onNBTLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeRequirements(IBuilderContext context, BlockPos pos) {
|
||||
super.storeRequirements(context, pos);
|
||||
|
||||
if (state.getBlock().hasTileEntity(state)) {
|
||||
TileEntity tile = context.world().getTileEntity(pos);
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
IInventory inv = (IInventory) tile;
|
||||
|
||||
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
if (inv.getStackInSlot(i) != null) {
|
||||
rqs.add(inv.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
storedRequirements = JavaTools.concat(storedRequirements, rqs.toArray(new ItemStack[rqs.size()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.writeSchematicToNBT(nbt, registry);
|
||||
|
||||
nbt.setTag("blockCpt", tileNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||
super.readSchematicFromNBT(nbt, registry);
|
||||
|
||||
tileNBT = nbt.getCompoundTag("blockCpt");
|
||||
onNBTLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int buildTime() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.5", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints")
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IRedstoneBoard<T> {
|
||||
|
||||
void updateBoard(T container);
|
||||
|
||||
RedstoneBoardNBT<?> getNBTHandler();
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public abstract class RedstoneBoardNBT<T> {
|
||||
|
||||
private static Random rand = new Random();
|
||||
|
||||
public abstract String getID();
|
||||
|
||||
public abstract void addInformation(ItemStack stack, EntityPlayer player, List<?> list, boolean advanced);
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract IRedstoneBoard<T> create(NBTTagCompound nbt, T object);
|
||||
|
||||
public abstract String getItemModelLocation();
|
||||
|
||||
public void createBoard(NBTTagCompound nbt) {
|
||||
nbt.setString("id", getID());
|
||||
}
|
||||
|
||||
public int getParameterNumber(NBTTagCompound nbt) {
|
||||
if (!nbt.hasKey("parameters")) {
|
||||
return 0;
|
||||
} else {
|
||||
return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount();
|
||||
}
|
||||
}
|
||||
|
||||
public float nextFloat(int difficulty) {
|
||||
return 1F - (float) Math.pow(rand.nextFloat(), 1F / difficulty);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class RedstoneBoardRegistry {
|
||||
|
||||
public static RedstoneBoardRegistry instance;
|
||||
|
||||
/** Register a redstone board type.
|
||||
*
|
||||
* @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information.
|
||||
* @param energyCost RF price of the board, in RF. */
|
||||
public abstract void registerBoardType(RedstoneBoardNBT<?> redstoneBoardNBT, int energyCost);
|
||||
|
||||
@Deprecated
|
||||
/** Register a redstone board type. Deprecated, use registerBoardType now.
|
||||
*
|
||||
* @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information.
|
||||
* @param probability Since 6.4.x, this is used to calculate the RF price of the board in the Programming Table by
|
||||
* doing (160000 / probability). */
|
||||
public abstract void registerBoardClass(RedstoneBoardNBT<?> redstoneBoardNBT, float probability);
|
||||
|
||||
public abstract void setEmptyRobotBoard(RedstoneBoardRobotNBT redstoneBoardNBT);
|
||||
|
||||
public abstract RedstoneBoardRobotNBT getEmptyRobotBoard();
|
||||
|
||||
public abstract RedstoneBoardNBT<?> getRedstoneBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract RedstoneBoardNBT<?> getRedstoneBoard(String id);
|
||||
|
||||
public abstract Collection<RedstoneBoardNBT<?>> getAllBoardNBTs();
|
||||
|
||||
public abstract int getEnergyCost(RedstoneBoardNBT<?> board);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RedstoneBoardRobot extends AIRobot implements IRedstoneBoard<EntityRobotBase> {
|
||||
|
||||
public RedstoneBoardRobot(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract RedstoneBoardRobotNBT getNBTHandler();
|
||||
|
||||
@Override
|
||||
public final void updateBoard(EntityRobotBase container) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT<EntityRobotBase> {
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return create(robot);
|
||||
}
|
||||
|
||||
public abstract RedstoneBoardRobot create(EntityRobotBase robot);
|
||||
|
||||
public abstract ResourceLocation getRobotTexture();
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|boards")
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,79 +0,0 @@
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class CropManager {
|
||||
private static List<ICropHandler> handlers = new ArrayList<ICropHandler>();
|
||||
private static ICropHandler defaultHandler;
|
||||
|
||||
private CropManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void registerHandler(ICropHandler cropHandler) {
|
||||
handlers.add(cropHandler);
|
||||
}
|
||||
|
||||
public static void setDefaultHandler(ICropHandler cropHandler) {
|
||||
defaultHandler = cropHandler;
|
||||
}
|
||||
|
||||
public static ICropHandler getDefaultHandler() {
|
||||
return defaultHandler;
|
||||
}
|
||||
|
||||
public static boolean isSeed(ItemStack stack) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isSeed(stack);
|
||||
}
|
||||
|
||||
public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos);
|
||||
}
|
||||
|
||||
public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos) && cropHandler.plantCrop(world, player, seed, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.plantCrop(world, player, seed, pos);
|
||||
}
|
||||
|
||||
public static boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isMature(blockAccess, state, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isMature(blockAccess, state, pos);
|
||||
}
|
||||
|
||||
public static boolean harvestCrop(World world, BlockPos pos, List<ItemStack> drops) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isMature(world, state, pos)) {
|
||||
return cropHandler.harvestCrop(world, pos, drops);
|
||||
}
|
||||
}
|
||||
return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICropHandler {
|
||||
|
||||
/** Check if an item is a seed.
|
||||
*
|
||||
* @param stack
|
||||
* @return true if the item can be planted. */
|
||||
boolean isSeed(ItemStack stack);
|
||||
|
||||
/** Check if the item can be planted. You can assume canSustainPlant() will only be called if isSeed() returned
|
||||
* true.
|
||||
*
|
||||
* @param world
|
||||
* @param seed
|
||||
* @param pos
|
||||
* @return true if the item can be planted at pos. */
|
||||
boolean canSustainPlant(World world, ItemStack seed, BlockPos pos);
|
||||
|
||||
/** Plant the item in the block. You can assume plantCrop() will only be called if canSustainPlant() returned true.
|
||||
*
|
||||
* @param world
|
||||
* @param player
|
||||
* @param seed
|
||||
* @param pos
|
||||
* @return true if the item was planted at pos. */
|
||||
boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos);
|
||||
|
||||
/** Check if a crop is mature and can be harvested.
|
||||
*
|
||||
* @param blockAccess
|
||||
* @param state
|
||||
* @param pos
|
||||
* @return true if the block at pos is mature and can be harvested. */
|
||||
boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos);
|
||||
|
||||
/** Harvest the crop. You can assume harvestCrop() will only be called if isMature() returned true.
|
||||
*
|
||||
* @param world
|
||||
* @param pos
|
||||
* @param drops a list to return the harvest's drops.
|
||||
* @return true if the block was successfully harvested. */
|
||||
boolean harvestCrop(World world, BlockPos pos, List<ItemStack> drops);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|Core", provides = "BuildCraftAPI|crops")
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,22 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class BlockInteractionEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final IBlockState state;
|
||||
|
||||
public BlockInteractionEvent(EntityPlayer player, IBlockState state) {
|
||||
this.player = player;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class BlockPlacedDownEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final IBlockState state;
|
||||
public final BlockPos pos;
|
||||
|
||||
public BlockPlacedDownEvent(EntityPlayer player, BlockPos pos, IBlockState state) {
|
||||
this.player = player;
|
||||
this.state = state;
|
||||
this.pos = pos;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class PipePlacedEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
public Item pipeType;
|
||||
public BlockPos pos;
|
||||
|
||||
public PipePlacedEvent(EntityPlayer player, Item pipeType, BlockPos pos) {
|
||||
this.player = player;
|
||||
this.pipeType = pipeType;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RobotEvent extends Event {
|
||||
public final EntityRobotBase robot;
|
||||
|
||||
public RobotEvent(EntityRobotBase robot) {
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Place extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
|
||||
public Place(EntityRobotBase robot, EntityPlayer player) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Interact extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack item;
|
||||
|
||||
public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Dismantle extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
|
||||
public Dismantle(EntityRobotBase robot, EntityPlayer player) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class RobotPlacementEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
public String robotProgram;
|
||||
|
||||
public RobotPlacementEvent(EntityPlayer player, String robotProgram) {
|
||||
this.player = player;
|
||||
this.robotProgram = robotProgram;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|events")
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,9 +0,0 @@
|
||||
package buildcraft.api.facades;
|
||||
|
||||
public final class FacadeAPI {
|
||||
public static IFacadeItem facadeItem;
|
||||
|
||||
private FacadeAPI() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.facades;
|
||||
|
||||
public enum FacadeType {
|
||||
Basic,
|
||||
Phased;
|
||||
|
||||
public static FacadeType fromOrdinal(int ordinal) {
|
||||
return ordinal == 1 ? Phased : Basic;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.facades;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFacadeItem {
|
||||
FacadeType getFacadeType(ItemStack facade);
|
||||
|
||||
ItemStack getFacadeForBlock(IBlockState state);
|
||||
|
||||
IBlockState[] getBlockStatesForFacade(ItemStack facade);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|facades")
|
||||
package buildcraft.api.facades;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
public final class FillerManager {
|
||||
|
||||
public static IFillerRegistry registry;
|
||||
|
||||
/** Deactivate constructor */
|
||||
private FillerManager() {}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import buildcraft.api.statements.IStatement;
|
||||
|
||||
public interface IFillerPattern extends IStatement {
|
||||
// Object getBlockOverlay();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IFillerRegistry {
|
||||
void addPattern(IFillerPattern pattern);
|
||||
|
||||
IFillerPattern getPattern(String patternName);
|
||||
|
||||
IFillerPattern getNextPattern(IFillerPattern currentPattern);
|
||||
|
||||
IFillerPattern getPreviousPattern(IFillerPattern currentPattern);
|
||||
|
||||
Collection<IFillerPattern> getPatterns();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "4.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|filler")
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,54 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import buildcraft.api.statements.IActionInternal;
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
|
||||
public abstract class GateExpansionController {
|
||||
|
||||
public final IGateExpansion type;
|
||||
public final TileEntity pipeTile;
|
||||
|
||||
public GateExpansionController(IGateExpansion type, TileEntity pipeTile) {
|
||||
this.pipeTile = pipeTile;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public IGateExpansion getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void tick(IGate gate) {}
|
||||
|
||||
public void startResolution() {}
|
||||
|
||||
public boolean resolveAction(IStatement action, int count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addTriggers(Collection<ITriggerInternal> list) {}
|
||||
|
||||
public void addActions(Collection<IActionInternal> list) {}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
|
||||
public class GateExpansionModelKey<K extends GateExpansionModelKey<K>> {
|
||||
public final BlockRenderLayer layer;
|
||||
public final IExpansionBaker<K> baker;
|
||||
private final int hash;
|
||||
|
||||
public GateExpansionModelKey(BlockRenderLayer layer, IExpansionBaker<K> baker) {
|
||||
if (layer != BlockRenderLayer.CUTOUT && layer != BlockRenderLayer.TRANSLUCENT) {
|
||||
throw new IllegalArgumentException("Unsuported layer! Was " + layer + ", wanted CUTOUT or TRANSLUCENT");
|
||||
}
|
||||
if (baker == null) throw new NullPointerException("baker");
|
||||
this.layer = layer;
|
||||
this.baker = baker;
|
||||
hash = Arrays.hashCode(new int[] { layer.hashCode(), System.identityHashCode(baker) });
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
GateExpansionModelKey<?> other = (GateExpansionModelKey<?>) obj;
|
||||
if (baker != other.baker) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public final class GateExpansions {
|
||||
private static final Map<String, IGateExpansion> expansions = new HashMap<String, IGateExpansion>();
|
||||
private static final ArrayList<IGateExpansion> expansionIDs = new ArrayList<IGateExpansion>();
|
||||
private static final Map<IGateExpansion, ItemStack> recipes = HashBiMap.create();
|
||||
|
||||
private GateExpansions() {}
|
||||
|
||||
public static void registerExpansion(IGateExpansion expansion) {
|
||||
registerExpansion(expansion.getUniqueIdentifier(), expansion);
|
||||
}
|
||||
|
||||
public static void registerExpansion(String identifier, IGateExpansion expansion) {
|
||||
expansions.put(identifier, expansion);
|
||||
expansionIDs.add(expansion);
|
||||
}
|
||||
|
||||
public static void registerExpansion(IGateExpansion expansion, ItemStack addedRecipe) {
|
||||
registerExpansion(expansion.getUniqueIdentifier(), expansion);
|
||||
recipes.put(expansion, addedRecipe);
|
||||
}
|
||||
|
||||
public static IGateExpansion getExpansion(String identifier) {
|
||||
return expansions.get(identifier);
|
||||
}
|
||||
|
||||
public static Set<IGateExpansion> getExpansions() {
|
||||
Set<IGateExpansion> set = new HashSet<IGateExpansion>();
|
||||
set.addAll(expansionIDs);
|
||||
return set;
|
||||
}
|
||||
|
||||
public static Map<IGateExpansion, ItemStack> getRecipesForPostInit() {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
// The code below is used by networking.
|
||||
|
||||
public static IGateExpansion getExpansionByID(int id) {
|
||||
return expansionIDs.get(id);
|
||||
}
|
||||
|
||||
public static int getExpansionID(IGateExpansion expansion) {
|
||||
return expansionIDs.indexOf(expansion);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
|
||||
public interface IExpansionBaker<K extends GateExpansionModelKey<K>> {
|
||||
/** @return The vertex format used to generate the quads. */
|
||||
VertexFormat getVertexFormat();
|
||||
|
||||
ImmutableList<BakedQuad> bake(K key);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementSlot;
|
||||
import buildcraft.api.statements.containers.ISidedStatementContainer;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
||||
public interface IGate extends ISidedStatementContainer {
|
||||
@Deprecated
|
||||
void setPulsing(boolean pulse);
|
||||
|
||||
IPipe getPipe();
|
||||
|
||||
Collection<IGateExpansion> getExpansions();
|
||||
|
||||
List<IStatement> getTriggers();
|
||||
|
||||
List<IStatement> getActions();
|
||||
|
||||
List<StatementSlot> getActiveActions();
|
||||
|
||||
List<IStatementParameter> getTriggerParameters(int slot);
|
||||
|
||||
List<IStatementParameter> getActionParameters(int slot);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IGateExpansion {
|
||||
|
||||
String getUniqueIdentifier();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
GateExpansionController makeController(TileEntity pipeTile);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void textureStitch(TextureMap map);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
GateExpansionModelKey<?> getRenderModelKey(BlockRenderLayer layer);
|
||||
|
||||
// FIXME : This is ugly.
|
||||
boolean canAddToGate(int numTriggerParameters, int numActionParameters);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,18 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface ILibraryTypeHandler {
|
||||
boolean isHandler(ItemStack stack, boolean store);
|
||||
|
||||
String getFileExtension();
|
||||
|
||||
int getTextColor();
|
||||
|
||||
String getName(ItemStack stack);
|
||||
|
||||
ItemStack load(ItemStack stack, NBTTagCompound compound);
|
||||
|
||||
boolean store(ItemStack stack, NBTTagCompound compound);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class LibraryAPI {
|
||||
private static final Set<LibraryTypeHandler> handlers = new HashSet<LibraryTypeHandler>();
|
||||
|
||||
private LibraryAPI() {
|
||||
|
||||
}
|
||||
|
||||
public static Set<LibraryTypeHandler> getHandlerSet() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static void registerHandler(LibraryTypeHandler handler) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
public static LibraryTypeHandler getHandlerFor(String extension) {
|
||||
for (LibraryTypeHandler h : handlers) {
|
||||
if (h.isInputExtension(extension)) {
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class LibraryTypeHandler {
|
||||
public enum HandlerType {
|
||||
LOAD,
|
||||
STORE
|
||||
}
|
||||
|
||||
private final String extension;
|
||||
|
||||
public LibraryTypeHandler(String extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
public abstract boolean isHandler(ItemStack stack, HandlerType type);
|
||||
|
||||
public boolean isInputExtension(String ext) {
|
||||
return extension.equals(ext);
|
||||
}
|
||||
|
||||
public String getOutputExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public abstract int getTextColor();
|
||||
|
||||
public abstract String getName(ItemStack stack);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class LibraryTypeHandlerByteArray extends LibraryTypeHandler {
|
||||
public LibraryTypeHandlerByteArray(String extension) {
|
||||
super(extension);
|
||||
}
|
||||
|
||||
public abstract ItemStack load(ItemStack stack, byte[] data);
|
||||
|
||||
public abstract byte[] store(ItemStack stack);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class LibraryTypeHandlerNBT extends LibraryTypeHandler {
|
||||
public LibraryTypeHandlerNBT(String extension) {
|
||||
super(extension);
|
||||
}
|
||||
|
||||
public abstract ItemStack load(ItemStack stack, NBTTagCompound nbt);
|
||||
|
||||
public abstract boolean store(ItemStack stack, NBTTagCompound nbt);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|library")
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,27 +0,0 @@
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ListMatchHandler {
|
||||
public enum Type {
|
||||
TYPE,
|
||||
MATERIAL,
|
||||
CLASS
|
||||
}
|
||||
|
||||
public abstract boolean matches(Type type, ItemStack stack, ItemStack target, boolean precise);
|
||||
|
||||
public abstract boolean isValidSource(Type type, ItemStack stack);
|
||||
|
||||
/** Get custom client examples.
|
||||
*
|
||||
* @param type
|
||||
* @param stack
|
||||
* @return A List (even empty!) if the examples satisfy this handler, null if iteration and .matches should be used
|
||||
* instead. */
|
||||
public List<ItemStack> getClientExamples(Type type, ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public final class ListRegistry {
|
||||
public static final List<Class<? extends Item>> itemClassAsType = new ArrayList<Class<? extends Item>>();
|
||||
private static final List<ListMatchHandler> handlers = new ArrayList<ListMatchHandler>();
|
||||
|
||||
private ListRegistry() {
|
||||
|
||||
}
|
||||
|
||||
public static void registerHandler(ListMatchHandler h) {
|
||||
if (h != null) {
|
||||
handlers.add(h);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ListMatchHandler> getHandlers() {
|
||||
return Collections.unmodifiableList(handlers);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|lists")
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,26 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.power;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/** Engines should implement this interface if they want to support BuildCraft's behaviour of passing energy between
|
||||
* engines without using receiveEnergy() (which has other issues). */
|
||||
public interface IEngine {
|
||||
/** Returns true if the engine wants to receive power from another engine on this side.
|
||||
*
|
||||
* @param side
|
||||
* @return */
|
||||
boolean canReceiveFromEngine(EnumFacing side);
|
||||
|
||||
/** Receives energy from an engine. See
|
||||
* {@link cofh.api.energy.IEnergyHandler#receiveEnergy(EnumFacing, int, boolean)}
|
||||
*
|
||||
* @param side The side the engine is receiving energy from.
|
||||
* @param energy The amount of energy given to the engine.
|
||||
* @param simulate True if the energy should not actually be added.
|
||||
* @return The amount of energy used by the engine. */
|
||||
int receiveEnergyFromEngine(EnumFacing side, int energy, boolean simulate);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.power;
|
||||
|
||||
/** This interface should be defined by any Tile which wants to receive energy from BuildCraft lasers.
|
||||
*
|
||||
* The respective Block MUST implement ILaserTargetBlock! */
|
||||
public interface ILaserTarget {
|
||||
|
||||
/** Returns true if the target currently needs power. For example, if the Advanced Crafting Table has work to do.
|
||||
*
|
||||
* @return true if needs power */
|
||||
boolean requiresLaserEnergy();
|
||||
|
||||
/** Transfers energy from the laser to the target.
|
||||
*
|
||||
* @param energy */
|
||||
void receiveLaserEnergy(int energy);
|
||||
|
||||
/** Return true if the Tile Entity object is no longer a valid target. For example, if its been invalidated.
|
||||
*
|
||||
* @return true if no longer a valid target object */
|
||||
boolean isInvalidTarget();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.power;
|
||||
|
||||
/** This is a marker interface for laser targets. Implement it on your Block.
|
||||
*
|
||||
* It is used by BuildCraft Lasers for optimization purposes. */
|
||||
public interface ILaserTargetBlock {
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.power;
|
||||
|
||||
public interface IRedstoneEngine {}
|
||||
@@ -1,21 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.power;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
/** Implement this on tiles that you wish to be able to receive Redstone Engine (low-power) energy.
|
||||
*
|
||||
* Please do not implement it on batteries, pipes or machines which can have their energy extracted from. That could
|
||||
* lead to exploits and abuse. */
|
||||
public interface IRedstoneEngineReceiver extends IEnergyReceiver {
|
||||
/** This function is queried on every attempt to receive energy from a redstone engine as well.
|
||||
*
|
||||
* @param side
|
||||
* @return */
|
||||
boolean canConnectRedstoneEngine(EnumFacing side);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.3", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power")
|
||||
package buildcraft.api.power;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,16 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
public final class BuildcraftRecipeRegistry {
|
||||
|
||||
public static IAssemblyRecipeManager assemblyTable;
|
||||
public static IIntegrationRecipeManager integrationTable;
|
||||
public static IRefineryRecipeManager refinery;
|
||||
public static IProgrammingRecipeManager programmingTable;
|
||||
public static IComplexRefineryRecipeManager complexRefinery;
|
||||
|
||||
private BuildcraftRecipeRegistry() {}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CraftingResult<T> {
|
||||
|
||||
public T crafted = null;
|
||||
public ArrayList<ItemStack> usedItems = new ArrayList<ItemStack>();
|
||||
public ArrayList<FluidStack> usedFluids = new ArrayList<FluidStack>();
|
||||
public int energyCost = 0;
|
||||
public long craftingTime = 0;
|
||||
public IFlexibleRecipe<T> recipe;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IAssemblyRecipeManager {
|
||||
|
||||
/** Add an Assembly Table recipe.
|
||||
*
|
||||
* @param input Object... containing either an ItemStack, or a paired string and integer(ex: "dyeBlue", 1)
|
||||
* @param energyCost RF cost to produce
|
||||
* @param output resulting ItemStack */
|
||||
void addRecipe(String id, int energyCost, ItemStack output, Object... input);
|
||||
|
||||
void addRecipe(IFlexibleRecipe<ItemStack> recipe);
|
||||
|
||||
void removeRecipe(String id);
|
||||
|
||||
void removeRecipe(IFlexibleRecipe<ItemStack> recipe);
|
||||
|
||||
Collection<IFlexibleRecipe<ItemStack>> getRecipes();
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IComplexRefineryRecipeManager {
|
||||
IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks);
|
||||
|
||||
IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting);
|
||||
|
||||
ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks);
|
||||
|
||||
ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting);
|
||||
|
||||
IDistilationRecipe createDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks);
|
||||
|
||||
IDistilationRecipe addDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks, boolean replaceExisting);
|
||||
|
||||
IComplexRefineryRegistry<IHeatableRecipe> getHeatableRegistry();
|
||||
|
||||
IComplexRefineryRegistry<ICoolableRecipe> getCoolableRegistry();
|
||||
|
||||
IComplexRefineryRegistry<IDistilationRecipe> getDistilationRegistry();
|
||||
|
||||
public interface IComplexRefineryRegistry<R extends IComplexRefineryRecipe> {
|
||||
/** @return an unmodifiable set containing all of the distilation recipies that satisfy the given predicate. All
|
||||
* of the recipe objects are guarenteed to never be null. */
|
||||
Set<R> getRecipes(Predicate<R> toReturn);
|
||||
|
||||
/** @return an unmodifiable set containing all of the distilation recipies. */
|
||||
Set<R> getAllRecipes();
|
||||
|
||||
R getRecipeForInput(FluidStack fluid);
|
||||
|
||||
Set<R> removeRecipes(Predicate<R> toRemove);
|
||||
|
||||
R addRecipe(R recipe, boolean replaceExisting);
|
||||
}
|
||||
|
||||
public interface IComplexRefineryRecipe {
|
||||
int ticks();
|
||||
|
||||
FluidStack in();
|
||||
}
|
||||
|
||||
public interface IHeatExchangerRecipe extends IComplexRefineryRecipe {
|
||||
FluidStack out();
|
||||
|
||||
int heatFrom();
|
||||
|
||||
int heatTo();
|
||||
}
|
||||
|
||||
public interface IHeatableRecipe extends IHeatExchangerRecipe {}
|
||||
|
||||
public interface ICoolableRecipe extends IHeatExchangerRecipe {}
|
||||
|
||||
public interface IDistilationRecipe extends IComplexRefineryRecipe {
|
||||
FluidStack outGas();
|
||||
|
||||
FluidStack outLiquid();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFlexibleCrafter {
|
||||
|
||||
int getCraftingItemStackSize();
|
||||
|
||||
ItemStack getCraftingItemStack(int slotid);
|
||||
|
||||
ItemStack decrCraftingItemStack(int slotid, int val);
|
||||
|
||||
FluidStack getCraftingFluidStack(int tankid);
|
||||
|
||||
FluidStack decrCraftingFluidStack(int tankid, int val);
|
||||
|
||||
int getCraftingFluidStackSize();
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFlexibleRecipe<T> {
|
||||
|
||||
boolean canBeCrafted(IFlexibleCrafter crafter);
|
||||
|
||||
CraftingResult<T> craft(IFlexibleCrafter crafter, boolean preview);
|
||||
|
||||
CraftingResult<T> canCraft(ItemStack expectedOutput);
|
||||
|
||||
String getId();
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** This class is intended for mods such as Not Enough Items in order for them to be able to look inside a recipe.
|
||||
*
|
||||
* It is intentionally left as a separate interface, so that it remains possible to register a "dynamic" flexible recipe
|
||||
* which does not have static inputs and outputs.
|
||||
*
|
||||
* @author asie */
|
||||
public interface IFlexibleRecipeViewable {
|
||||
Object getOutput();
|
||||
|
||||
/** With BuildCraft's implementation (as of 6.1.3), this might contain either an ItemStack, a List<ItemStack>
|
||||
* or a FluidStack. */
|
||||
Collection<Object> getInputs();
|
||||
|
||||
long getCraftingTime();
|
||||
|
||||
int getEnergyCost();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IIntegrationRecipe {
|
||||
/** Get the energy cost (in RF) of the recipe.
|
||||
*
|
||||
* @return The energy cost of the recipe. */
|
||||
int getEnergyCost();
|
||||
|
||||
/** Get a list of example inputs. This is used for recipe preview.
|
||||
*
|
||||
* @return A list of example inputs. */
|
||||
List<ItemStack> getExampleInput();
|
||||
|
||||
/** Get a list of example expansions. This is used for recipe preview. If the amount of lists of expansions is
|
||||
* smaller than the maximum expansion count, the lists will be repeated.
|
||||
*
|
||||
* @return A list of every slot's list of example expansions. */
|
||||
List<List<ItemStack>> getExampleExpansions();
|
||||
|
||||
/** Get a list of example outputs. This is used for recipe preview.
|
||||
*
|
||||
* @return A list of example outputs. */
|
||||
List<ItemStack> getExampleOutput();
|
||||
|
||||
/** Check if an input is valid.
|
||||
*
|
||||
* @param input The input.
|
||||
* @return Whether the input is valid. */
|
||||
boolean isValidInput(ItemStack input);
|
||||
|
||||
/** Check if an expansion is valid.
|
||||
*
|
||||
* @param input The input currently in.
|
||||
* @param expansion The expansion.
|
||||
* @return Whether the expansion can be fitted to a given input. */
|
||||
boolean isValidExpansion(ItemStack input, ItemStack expansion);
|
||||
|
||||
/** Craft the recipe. Keep in mind that you need to decrease the amount of expansions yourself - the amount of
|
||||
* inputs is decreased for you.
|
||||
*
|
||||
* @param input The input.
|
||||
* @param expansions All inserted expansions.
|
||||
* @param preview If true, do not decrease the amount of expansions.
|
||||
* @return The output stack. */
|
||||
ItemStack craft(ItemStack input, List<ItemStack> expansions, boolean preview);
|
||||
|
||||
/** Returns the maximum count of expansions this recipe can have.
|
||||
*
|
||||
* @return -1 for no limit, a different number otherwise */
|
||||
int getMaximumExpansionCount(ItemStack input);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IIntegrationRecipeManager {
|
||||
void addRecipe(IIntegrationRecipe recipe);
|
||||
|
||||
List<? extends IIntegrationRecipe> getRecipes();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IProgrammingRecipe {
|
||||
String getId();
|
||||
|
||||
/** Get a list (size at least width*height) of ItemStacks representing options.
|
||||
*
|
||||
* @param width The width of the Programming Table panel.
|
||||
* @param height The height of the Programming Table panel.
|
||||
* @return */
|
||||
List<ItemStack> getOptions(int width, int height);
|
||||
|
||||
/** Get the energy cost of a given option ItemStack.
|
||||
*
|
||||
* @param option
|
||||
* @return */
|
||||
int getEnergyCost(ItemStack option);
|
||||
|
||||
/** @param input The input stack.
|
||||
* @return Whether this recipe applies to the given input stack. */
|
||||
boolean canCraft(ItemStack input);
|
||||
|
||||
/** Craft the input ItemStack with the given option into an output ItemStack.
|
||||
*
|
||||
* @param input
|
||||
* @param option
|
||||
* @return The output ItemStack. */
|
||||
ItemStack craft(ItemStack input, ItemStack option);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IProgrammingRecipeManager {
|
||||
void addRecipe(IProgrammingRecipe recipe);
|
||||
|
||||
void removeRecipe(String id);
|
||||
|
||||
void removeRecipe(IProgrammingRecipe recipe);
|
||||
|
||||
IProgrammingRecipe getRecipe(String id);
|
||||
|
||||
Collection<IProgrammingRecipe> getRecipes();
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IRecipeManager<T> {
|
||||
|
||||
/** Add a recipe.
|
||||
*
|
||||
* @param input Object... containing either an ItemStack, or a paired string and integer(ex: "dyeBlue", 1)
|
||||
* @param energyCost RF cost to produce
|
||||
* @param output resulting ItemStack */
|
||||
void addRecipe(String id, int energyCost, T output, Object... input);
|
||||
|
||||
void addRecipe(String id, int energyCost, int craftingDelay, T output, Object... input);
|
||||
|
||||
void addRecipe(IFlexibleRecipe<T> recipe);
|
||||
|
||||
void removeRecipe(String id);
|
||||
|
||||
void removeRecipe(IFlexibleRecipe<T> recipe);
|
||||
|
||||
Collection<IFlexibleRecipe<T>> getRecipes();
|
||||
|
||||
IFlexibleRecipe<T> getRecipe(String id);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IRefineryRecipeManager {
|
||||
|
||||
void addRecipe(String id, FluidStack ingredient, FluidStack result, int energy, int delay);
|
||||
|
||||
void addRecipe(String id, FluidStack ingredient1, FluidStack ingredient2, FluidStack result, int energy, int delay);
|
||||
|
||||
void removeRecipe(String id);
|
||||
|
||||
void removeRecipe(IFlexibleRecipe<FluidStack> recipe);
|
||||
|
||||
Collection<IFlexibleRecipe<FluidStack>> getRecipes();
|
||||
|
||||
IFlexibleRecipe<FluidStack> getRecipe(String currentRecipeId);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|recipes")
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,220 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class AIRobot {
|
||||
public EntityRobotBase robot;
|
||||
|
||||
private AIRobot delegateAI;
|
||||
private AIRobot parentAI;
|
||||
|
||||
private boolean success;
|
||||
|
||||
public AIRobot(EntityRobotBase iRobot) {
|
||||
robot = iRobot;
|
||||
success = true;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
public void preempt(AIRobot ai) {
|
||||
|
||||
}
|
||||
|
||||
public void update() {
|
||||
// Update should always handle terminate. Some AI are not using update
|
||||
// at all, their code being in start() and end(). In these case,
|
||||
// calling update is a malfunction, the ai should be terminated.
|
||||
terminate();
|
||||
}
|
||||
|
||||
public void end() {
|
||||
|
||||
}
|
||||
|
||||
/** This gets called when a delegate AI ends work naturally.
|
||||
*
|
||||
* @param ai The delegate AI which ended work. */
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
|
||||
}
|
||||
|
||||
/** This gets called when a delegate AI is forcibly aborted.
|
||||
*
|
||||
* @param ai The delegate AI which was aborted. */
|
||||
public void delegateAIAborted(AIRobot ai) {
|
||||
|
||||
}
|
||||
|
||||
public void writeSelfToNBT(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
public void loadSelfFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return success;
|
||||
}
|
||||
|
||||
protected void setSuccess(boolean iSuccess) {
|
||||
success = iSuccess;
|
||||
}
|
||||
|
||||
public int getEnergyCost() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean canLoadFromNBT() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Tries to receive items in parameters, return items that are left after the operation. */
|
||||
public ItemStack receiveItem(ItemStack stack) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public final void terminate() {
|
||||
abortDelegateAI();
|
||||
end();
|
||||
|
||||
if (parentAI != null) {
|
||||
parentAI.delegateAI = null;
|
||||
parentAI.delegateAIEnded(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void abort() {
|
||||
abortDelegateAI();
|
||||
|
||||
try {
|
||||
end();
|
||||
|
||||
if (parentAI != null) {
|
||||
parentAI.delegateAI = null;
|
||||
parentAI.delegateAIAborted(this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
delegateAI = null;
|
||||
|
||||
if (parentAI != null) {
|
||||
parentAI.delegateAI = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void cycle() {
|
||||
try {
|
||||
preempt(delegateAI);
|
||||
|
||||
if (delegateAI != null) {
|
||||
delegateAI.cycle();
|
||||
} else {
|
||||
robot.getBattery().extractEnergy(getEnergyCost(), false);
|
||||
update();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
public final void startDelegateAI(AIRobot ai) {
|
||||
abortDelegateAI();
|
||||
delegateAI = ai;
|
||||
ai.parentAI = this;
|
||||
delegateAI.start();
|
||||
}
|
||||
|
||||
public final void abortDelegateAI() {
|
||||
if (delegateAI != null) {
|
||||
delegateAI.abort();
|
||||
}
|
||||
}
|
||||
|
||||
public final AIRobot getActiveAI() {
|
||||
if (delegateAI != null) {
|
||||
return delegateAI.getActiveAI();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public final AIRobot getDelegateAI() {
|
||||
return delegateAI;
|
||||
}
|
||||
|
||||
public final void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setString("aiName", RobotManager.getAIRobotName(getClass()));
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
writeSelfToNBT(data);
|
||||
nbt.setTag("data", data);
|
||||
|
||||
if (delegateAI != null && delegateAI.canLoadFromNBT()) {
|
||||
NBTTagCompound sub = new NBTTagCompound();
|
||||
|
||||
delegateAI.writeToNBT(sub);
|
||||
nbt.setTag("delegateAI", sub);
|
||||
}
|
||||
}
|
||||
|
||||
public final void loadFromNBT(NBTTagCompound nbt) {
|
||||
loadSelfFromNBT(nbt.getCompoundTag("data"));
|
||||
|
||||
if (nbt.hasKey("delegateAI")) {
|
||||
NBTTagCompound sub = nbt.getCompoundTag("delegateAI");
|
||||
|
||||
try {
|
||||
Class<?> aiRobotClass;
|
||||
if (sub.hasKey("class")) {
|
||||
// Migration support for 6.4.x
|
||||
aiRobotClass = RobotManager.getAIRobotByLegacyClassName(sub.getString("class"));
|
||||
} else {
|
||||
aiRobotClass = RobotManager.getAIRobotByName(sub.getString("aiName"));
|
||||
}
|
||||
if (aiRobotClass != null) {
|
||||
delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot);
|
||||
delegateAI.parentAI = this;
|
||||
|
||||
if (delegateAI.canLoadFromNBT()) {
|
||||
delegateAI.loadFromNBT(sub);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AIRobot loadAI(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
AIRobot ai = null;
|
||||
|
||||
try {
|
||||
Class<?> aiRobotClass;
|
||||
if (nbt.hasKey("class")) {
|
||||
// Migration support for 6.4.x
|
||||
aiRobotClass = RobotManager.getAIRobotByLegacyClassName(nbt.getString("class"));
|
||||
} else {
|
||||
aiRobotClass = RobotManager.getAIRobotByName(nbt.getString("aiName"));
|
||||
}
|
||||
if (aiRobotClass != null) {
|
||||
ai = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot);
|
||||
ai.loadFromNBT(nbt);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ai;
|
||||
}
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents
|
||||
* of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import buildcraft.api.core.BCLog;
|
||||
import buildcraft.api.core.EnumPipePart;
|
||||
import buildcraft.api.statements.StatementSlot;
|
||||
import buildcraft.api.transport.IInjectable;
|
||||
|
||||
public abstract class DockingStation {
|
||||
public EnumFacing side;
|
||||
public World world;
|
||||
|
||||
private long robotTakingId = EntityRobotBase.NULL_ROBOT_ID;
|
||||
private EntityRobotBase robotTaking;
|
||||
|
||||
private boolean linkIsMain = false;
|
||||
|
||||
private BlockPos pos;
|
||||
|
||||
public DockingStation(BlockPos iIndex, EnumFacing iSide) {
|
||||
pos = iIndex;
|
||||
side = iSide;
|
||||
}
|
||||
|
||||
public DockingStation() {}
|
||||
|
||||
public boolean isMainStation() {
|
||||
return linkIsMain;
|
||||
}
|
||||
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public EnumFacing side() {
|
||||
return side;
|
||||
}
|
||||
|
||||
public EntityRobotBase robotTaking() {
|
||||
if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) {
|
||||
return null;
|
||||
} else if (robotTaking == null) {
|
||||
robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(robotTakingId);
|
||||
}
|
||||
|
||||
return robotTaking;
|
||||
}
|
||||
|
||||
public void invalidateRobotTakingEntity() {
|
||||
robotTaking = null;
|
||||
}
|
||||
|
||||
public long linkedId() {
|
||||
return robotTakingId;
|
||||
}
|
||||
|
||||
public boolean takeAsMain(EntityRobotBase robot) {
|
||||
if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) {
|
||||
IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world);
|
||||
linkIsMain = true;
|
||||
robotTaking = robot;
|
||||
robotTakingId = robot.getRobotId();
|
||||
registry.registryMarkDirty();
|
||||
robot.setMainStation(this);
|
||||
registry.take(this, robot.getRobotId());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return robotTakingId == robot.getRobotId();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean take(EntityRobotBase robot) {
|
||||
if (robotTaking == null) {
|
||||
IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world);
|
||||
linkIsMain = false;
|
||||
robotTaking = robot;
|
||||
robotTakingId = robot.getRobotId();
|
||||
registry.registryMarkDirty();
|
||||
registry.take(this, robot.getRobotId());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return robot.getRobotId() == robotTakingId;
|
||||
}
|
||||
}
|
||||
|
||||
public void release(EntityRobotBase robot) {
|
||||
if (robotTaking == robot && !linkIsMain) {
|
||||
IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world);
|
||||
unsafeRelease(robot);
|
||||
registry.registryMarkDirty();
|
||||
registry.release(this, robot.getRobotId());
|
||||
}
|
||||
}
|
||||
|
||||
/** Same a release but doesn't clear the registry (presumably called from the registry). */
|
||||
public void unsafeRelease(EntityRobotBase robot) {
|
||||
if (robotTaking == robot) {
|
||||
linkIsMain = false;
|
||||
robotTaking = null;
|
||||
robotTakingId = EntityRobotBase.NULL_ROBOT_ID;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setIntArray("pos", new int[] { getPos().getX(), getPos().getY(), getPos().getZ() });
|
||||
nbt.setByte("side", (byte) side.ordinal());
|
||||
nbt.setBoolean("isMain", linkIsMain);
|
||||
nbt.setLong("robotId", robotTakingId);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("index")) {
|
||||
// For compatibility with older versions of minecraft and buildcraft
|
||||
NBTTagCompound indexNBT = nbt.getCompoundTag("index");
|
||||
int x = indexNBT.getInteger("i");
|
||||
int y = indexNBT.getInteger("j");
|
||||
int z = indexNBT.getInteger("k");
|
||||
pos = new BlockPos(x, y, z);
|
||||
} else {
|
||||
int[] array = nbt.getIntArray("pos");
|
||||
if (array.length == 3) {
|
||||
pos = new BlockPos(array[0], array[1], array[2]);
|
||||
} else if (array.length != 0) {
|
||||
BCLog.logger.warn("Found an integer array that wwas not the right length! (" + array + ")");
|
||||
} else {
|
||||
BCLog.logger.warn("Did not find any integer positions! This is a bug!");
|
||||
}
|
||||
}
|
||||
side = EnumFacing.values()[nbt.getByte("side")];
|
||||
linkIsMain = nbt.getBoolean("isMain");
|
||||
robotTakingId = nbt.getLong("robotId");
|
||||
}
|
||||
|
||||
public boolean isTaken() {
|
||||
return robotTakingId != EntityRobotBase.NULL_ROBOT_ID;
|
||||
}
|
||||
|
||||
public long robotIdTaking() {
|
||||
return robotTakingId;
|
||||
}
|
||||
|
||||
public BlockPos index() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + pos + ", " + side + " :" + robotTakingId + "}";
|
||||
}
|
||||
|
||||
public boolean linkIsDocked() {
|
||||
if (robotTaking() != null) {
|
||||
return robotTaking().getDockingStation() == this;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canRelease() {
|
||||
return !isMainStation() && !linkIsDocked();
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract Iterable<StatementSlot> getActiveActions();
|
||||
|
||||
public IInjectable getItemOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public EnumPipePart getItemOutputSide() {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
|
||||
public IInventory getItemInput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public EnumPipePart getItemInputSide() {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
|
||||
public IFluidHandler getFluidOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public EnumPipePart getFluidOutputSide() {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
|
||||
public IFluidHandler getFluidInput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public EnumPipePart getFluidInputSide() {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
|
||||
public boolean providesPower() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IRequestProvider getRequestProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onChunkUnload() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import cofh.api.energy.IEnergyStorage;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.core.IZone;
|
||||
|
||||
public abstract class EntityRobotBase extends EntityLiving implements IInventory, IFluidHandler {
|
||||
|
||||
public static final int MAX_ENERGY = 100000;
|
||||
public static final int SAFETY_ENERGY = MAX_ENERGY / 5;
|
||||
public static final int SHUTDOWN_ENERGY = 0;
|
||||
public static final long NULL_ROBOT_ID = Long.MAX_VALUE;
|
||||
|
||||
public EntityRobotBase(World par1World) {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public abstract void setItemInUse(ItemStack stack);
|
||||
|
||||
public abstract void setItemActive(boolean b);
|
||||
|
||||
public abstract boolean isMoving();
|
||||
|
||||
public abstract DockingStation getLinkedStation();
|
||||
|
||||
public abstract RedstoneBoardRobot getBoard();
|
||||
|
||||
public abstract void aimItemAt(float yaw, float pitch);
|
||||
|
||||
public abstract void aimItemAt(BlockPos pos);
|
||||
|
||||
public abstract float getAimYaw();
|
||||
|
||||
public abstract float getAimPitch();
|
||||
|
||||
public abstract int getEnergy();
|
||||
|
||||
public abstract IEnergyStorage getBattery();
|
||||
|
||||
public abstract DockingStation getDockingStation();
|
||||
|
||||
public abstract void dock(DockingStation station);
|
||||
|
||||
public abstract void undock();
|
||||
|
||||
public abstract IZone getZoneToWork();
|
||||
|
||||
public abstract IZone getZoneToLoadUnload();
|
||||
|
||||
public abstract boolean containsItems();
|
||||
|
||||
public abstract boolean hasFreeSlot();
|
||||
|
||||
public abstract void unreachableEntityDetected(Entity entity);
|
||||
|
||||
public abstract boolean isKnownUnreachable(Entity entity);
|
||||
|
||||
public abstract long getRobotId();
|
||||
|
||||
public abstract IRobotRegistry getRegistry();
|
||||
|
||||
public abstract void releaseResources();
|
||||
|
||||
public abstract void onChunkUnload();
|
||||
|
||||
public abstract ItemStack receiveItem(TileEntity tile, ItemStack stack);
|
||||
|
||||
public abstract void setMainStation(DockingStation station);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package buildcraft.api.robots;
|
||||
|
||||
/** By default, this can be either an IPipePluggable or a TileEntity. */
|
||||
public interface IDockingStationProvider {
|
||||
DockingStation getStation();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/** Provide requests of items that need to be fulfilled.
|
||||
*
|
||||
* Requests are organized as an linear array, where null entries mark slots without a requests. A request in a slot, or
|
||||
* the amount of slots, is allowed to change before a call to {@link #offerItem(int, ItemStack)}, but it is not
|
||||
* recommended that this is frequent, since the request delivery won't fail until it is offered the previous request. */
|
||||
public interface IRequestProvider {
|
||||
/** Return the total number of request slots available from this provider.
|
||||
*
|
||||
* @return */
|
||||
int getRequestsCount();
|
||||
|
||||
/** Return a stack with the request in the slot.
|
||||
*
|
||||
* @param slot
|
||||
* @return the request in the slot, or null if there's no request. */
|
||||
ItemStack getRequest(int slot);
|
||||
|
||||
/** Fulfill the request in slot with the stack given and return any excess.
|
||||
*
|
||||
* @param slot
|
||||
* @param stack
|
||||
* @return any excess that was not used to fulfill the request. */
|
||||
ItemStack offerItem(int slot, ItemStack stack);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IRobotOverlayItem {
|
||||
boolean isValidRobotOverlay(ItemStack stack);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void renderRobotOverlay(ItemStack stack, TextureManager textureManager);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IRobotRegistry {
|
||||
|
||||
long getNextRobotId();
|
||||
|
||||
void registerRobot(EntityRobotBase robot);
|
||||
|
||||
void killRobot(EntityRobotBase robot);
|
||||
|
||||
void unloadRobot(EntityRobotBase robot);
|
||||
|
||||
EntityRobotBase getLoadedRobot(long id);
|
||||
|
||||
boolean isTaken(ResourceId resourceId);
|
||||
|
||||
long robotIdTaking(ResourceId resourceId);
|
||||
|
||||
EntityRobotBase robotTaking(ResourceId resourceId);
|
||||
|
||||
boolean take(ResourceId resourceId, EntityRobotBase robot);
|
||||
|
||||
boolean take(ResourceId resourceId, long robotId);
|
||||
|
||||
void release(ResourceId resourceId);
|
||||
|
||||
void releaseResources(EntityRobotBase robot);
|
||||
|
||||
DockingStation getStation(BlockPos pos, EnumFacing side);
|
||||
|
||||
Collection<DockingStation> getStations();
|
||||
|
||||
void registerStation(DockingStation station);
|
||||
|
||||
void removeStation(DockingStation station);
|
||||
|
||||
void take(DockingStation station, long robotId);
|
||||
|
||||
void release(DockingStation station, long robotId);
|
||||
|
||||
void writeToNBT(NBTTagCompound nbt);
|
||||
|
||||
void readFromNBT(NBTTagCompound nbt);
|
||||
|
||||
void registryMarkDirty();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IRobotRegistryProvider {
|
||||
IRobotRegistry getRegistry(World world);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class ResourceId {
|
||||
|
||||
protected ResourceId() {}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setString("resourceName", RobotManager.getResourceIdName(getClass()));
|
||||
}
|
||||
|
||||
protected void readFromNBT(NBTTagCompound nbt) {}
|
||||
|
||||
public static ResourceId load(NBTTagCompound nbt) {
|
||||
try {
|
||||
Class<?> cls;
|
||||
if (nbt.hasKey("class")) {
|
||||
// Migration support for 6.4.x
|
||||
cls = RobotManager.getResourceIdByLegacyClassName(nbt.getString("class"));
|
||||
} else {
|
||||
cls = RobotManager.getResourceIdByName(nbt.getString("resourceName"));
|
||||
}
|
||||
|
||||
ResourceId id = (ResourceId) cls.newInstance();
|
||||
id.readFromNBT(nbt);
|
||||
|
||||
return id;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents
|
||||
* of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import buildcraft.api.core.EnumPipePart;
|
||||
|
||||
public class ResourceIdBlock extends ResourceId {
|
||||
|
||||
public BlockPos pos = new BlockPos(0, 0, 0);
|
||||
public EnumPipePart side = EnumPipePart.CENTER;
|
||||
|
||||
public ResourceIdBlock() {
|
||||
|
||||
}
|
||||
|
||||
public ResourceIdBlock(int x, int y, int z) {
|
||||
pos = new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public ResourceIdBlock(BlockPos iIndex) {
|
||||
pos = iIndex;
|
||||
}
|
||||
|
||||
public ResourceIdBlock(TileEntity tile) {
|
||||
pos = tile.getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResourceIdBlock compareId = (ResourceIdBlock) obj;
|
||||
|
||||
return pos.equals(compareId.pos) && side == compareId.side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(pos.hashCode()).append(side != null ? side.ordinal() : 0).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
int[] arr = new int[] { pos.getX(), pos.getY(), pos.getZ() };
|
||||
nbt.setIntArray("pos", arr);
|
||||
|
||||
nbt.setTag("side", side.writeToNBT());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
int[] arr = nbt.getIntArray("pos");
|
||||
pos = new BlockPos(arr[0], arr[1], arr[2]);
|
||||
|
||||
side = EnumPipePart.readFromNBT(nbt.getTag("side"));
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents
|
||||
* of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.core.EnumPipePart;
|
||||
|
||||
public class ResourceIdRequest extends ResourceIdBlock {
|
||||
|
||||
private int slot;
|
||||
|
||||
public ResourceIdRequest() {
|
||||
|
||||
}
|
||||
|
||||
public ResourceIdRequest(DockingStation station, int slot) {
|
||||
pos = station.index();
|
||||
side = EnumPipePart.fromFacing(station.side());
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) return false;
|
||||
ResourceIdRequest compareId = (ResourceIdRequest) obj;
|
||||
|
||||
return slot == compareId.slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(super.hashCode()).append(slot).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("localId", slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
slot = nbt.getInteger("localId");
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents
|
||||
* of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
public abstract class RobotManager {
|
||||
public static IRobotRegistryProvider registryProvider;
|
||||
public static ArrayList<Class<? extends AIRobot>> aiRobots = new ArrayList<Class<? extends AIRobot>>();
|
||||
|
||||
static {
|
||||
aiRobotsByNames = new HashMap<String, Class<? extends AIRobot>>();
|
||||
aiRobotsNames = new HashMap<Class<? extends AIRobot>, String>();
|
||||
aiRobotsByLegacyClassNames = new HashMap<String, Class<? extends AIRobot>>();
|
||||
resourceIdNames = new HashMap<Class<? extends ResourceId>, String>();
|
||||
resourceIdByNames = new HashMap<String, Class<? extends ResourceId>>();
|
||||
resourceIdLegacyClassNames = new HashMap<String, Class<? extends ResourceId>>();
|
||||
dockingStationNames = new HashMap<Class<? extends DockingStation>, String>();
|
||||
dockingStationByNames = new HashMap<String, Class<? extends DockingStation>>();
|
||||
|
||||
registerResourceId(ResourceIdBlock.class, "resourceIdBlock", "buildcraft.core.robots.ResourceIdBlock");
|
||||
registerResourceId(ResourceIdRequest.class, "resourceIdRequest", "buildcraft.core.robots.ResourceIdRequest");
|
||||
}
|
||||
|
||||
private static Map<Class<? extends AIRobot>, String> aiRobotsNames;
|
||||
private static Map<String, Class<? extends AIRobot>> aiRobotsByNames;
|
||||
private static Map<String, Class<? extends AIRobot>> aiRobotsByLegacyClassNames;
|
||||
|
||||
private static Map<Class<? extends ResourceId>, String> resourceIdNames;
|
||||
private static Map<String, Class<? extends ResourceId>> resourceIdByNames;
|
||||
private static Map<String, Class<? extends ResourceId>> resourceIdLegacyClassNames;
|
||||
|
||||
private static Map<Class<? extends DockingStation>, String> dockingStationNames;
|
||||
private static Map<String, Class<? extends DockingStation>> dockingStationByNames;
|
||||
|
||||
public static void registerAIRobot(Class<? extends AIRobot> aiRobot, String name) {
|
||||
registerAIRobot(aiRobot, name, null);
|
||||
}
|
||||
|
||||
public static void registerAIRobot(Class<? extends AIRobot> aiRobot, String name, String legacyClassName) {
|
||||
if (aiRobotsByNames.containsKey(name)) {
|
||||
BCLog.logger.info("Overriding " + aiRobotsByNames.get(name).getName() + " with " + aiRobot.getName());
|
||||
}
|
||||
|
||||
// Check if NBT-load constructor is present
|
||||
try {
|
||||
aiRobot.getConstructor(EntityRobotBase.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load construtor! This is a bug!");
|
||||
}
|
||||
|
||||
aiRobots.add(aiRobot);
|
||||
aiRobotsByNames.put(name, aiRobot);
|
||||
aiRobotsNames.put(aiRobot, name);
|
||||
if (legacyClassName != null) {
|
||||
aiRobotsByLegacyClassNames.put(legacyClassName, aiRobot);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getAIRobotByName(String aiRobotName) {
|
||||
return aiRobotsByNames.get(aiRobotName);
|
||||
}
|
||||
|
||||
public static String getAIRobotName(Class<? extends AIRobot> aiRobotClass) {
|
||||
return aiRobotsNames.get(aiRobotClass);
|
||||
}
|
||||
|
||||
public static Class<?> getAIRobotByLegacyClassName(String aiRobotLegacyClassName) {
|
||||
return aiRobotsByLegacyClassNames.get(aiRobotLegacyClassName);
|
||||
}
|
||||
|
||||
public static void registerResourceId(Class<? extends ResourceId> resourceId, String name) {
|
||||
registerResourceId(resourceId, name, null);
|
||||
}
|
||||
|
||||
public static void registerResourceId(Class<? extends ResourceId> resourceId, String name, String legacyClassName) {
|
||||
resourceIdByNames.put(name, resourceId);
|
||||
resourceIdNames.put(resourceId, name);
|
||||
if (legacyClassName != null) {
|
||||
resourceIdLegacyClassNames.put(legacyClassName, resourceId);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getResourceIdByName(String resourceIdName) {
|
||||
return resourceIdByNames.get(resourceIdName);
|
||||
}
|
||||
|
||||
public static String getResourceIdName(Class<? extends ResourceId> resouceIdClass) {
|
||||
return resourceIdNames.get(resouceIdClass);
|
||||
}
|
||||
|
||||
public static Class<?> getResourceIdByLegacyClassName(String resourceIdLegacyClassName) {
|
||||
return resourceIdLegacyClassNames.get(resourceIdLegacyClassName);
|
||||
}
|
||||
|
||||
public static void registerDockingStation(Class<? extends DockingStation> dockingStation, String name) {
|
||||
dockingStationByNames.put(name, dockingStation);
|
||||
dockingStationNames.put(dockingStation, name);
|
||||
}
|
||||
|
||||
public static Class<? extends DockingStation> getDockingStationByName(String dockingStationTypeName) {
|
||||
return dockingStationByNames.get(dockingStationTypeName);
|
||||
}
|
||||
|
||||
public static String getDockingStationName(Class<? extends DockingStation> dockingStation) {
|
||||
return dockingStationNames.get(dockingStation);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics")
|
||||
package buildcraft.api.robots;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,9 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
public class ActionState {
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IActionExternal extends IStatement {
|
||||
void actionActivate(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
public interface IActionInternal extends IStatement {
|
||||
|
||||
void actionActivate(IStatementContainer source, IStatementParameter[] parameters);
|
||||
|
||||
public interface IActionInternalSingle extends IActionInternal {
|
||||
/** @return True if this action should only be fired for the first tick of it being active. */
|
||||
boolean singleActionTick();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IActionProvider {
|
||||
void addInternalActions(Collection<IActionInternal> actions, IStatementContainer container);
|
||||
|
||||
void addExternalActions(Collection<IActionExternal> actions, EnumFacing side, TileEntity tile);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
public interface IActionReceptor {
|
||||
void actionActivated(IStatement statement, IStatementParameter[] parameters);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IOverrideDefaultStatements {
|
||||
List<ITriggerExternal> overrideTriggers();
|
||||
|
||||
List<IActionExternal> overrideActions();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IStatement {
|
||||
/** Every statement needs a unique tag, it should be in the format of "<modid>:<name>.
|
||||
*
|
||||
* @return the unique id */
|
||||
String getUniqueTag();
|
||||
|
||||
/** Return the maximum number of parameter this statement can have, 0 if none. */
|
||||
int maxParameters();
|
||||
|
||||
/** Return the minimum number of parameter this statement can have, 0 if none. */
|
||||
int minParameters();
|
||||
|
||||
/** Return the statement description in the UI */
|
||||
String getDescription();
|
||||
|
||||
/** Create parameters for the statement. */
|
||||
IStatementParameter createParameter(int index);
|
||||
|
||||
/** This returns the statement after a left rotation. Used in particular in blueprints orientation. */
|
||||
IStatement rotateLeft();
|
||||
|
||||
/** This should return the icon for this statement, suitable for rending directly into a GUI. This should refer to a
|
||||
* texture on the map block texture map. */
|
||||
@SideOnly(Side.CLIENT)
|
||||
TextureAtlasSprite getGuiSprite();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(TextureMap register);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.statements;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/** This is implemented by objects containing Statements, such as Gates and TileEntities. */
|
||||
public interface IStatementContainer {
|
||||
TileEntity getTile();
|
||||
}
|
||||
Loaded 100 of 175 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user