mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
Unstable build, hoping Matt can help me out
Changelog revealed next beta!
This commit is contained in:
1 parent
152cbc9ac2
commit
8a3f374cb6
96 files changed
+4111
-4042
No files matched your search
@@ -1,77 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
public class BlockSignature {
|
||||
|
||||
public String blockClassName;
|
||||
public String tileClassName;
|
||||
public String blockName;
|
||||
public String mod;
|
||||
public String modVersion;
|
||||
public String customField;
|
||||
|
||||
public BlockSignature(String str) {
|
||||
String[] values = str.split("/");
|
||||
|
||||
int i = 0;
|
||||
|
||||
if (values[0].equals("#B")) {
|
||||
i++;
|
||||
}
|
||||
|
||||
blockClassName = values[i];
|
||||
tileClassName = values[i + 1];
|
||||
blockName = values[i + 2];
|
||||
mod = values[i + 3];
|
||||
modVersion = values[i + 4];
|
||||
customField = values[i + 5];
|
||||
|
||||
replaceNullWithStar();
|
||||
|
||||
}
|
||||
|
||||
public BlockSignature() {
|
||||
replaceNullWithStar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
replaceNullWithStar();
|
||||
|
||||
return "#B/" + blockClassName + "/" + tileClassName + "/" + blockName + "/" + mod + "/" + modVersion + "/" + customField;
|
||||
}
|
||||
|
||||
public void replaceNullWithStar() {
|
||||
if (blockClassName == null) {
|
||||
blockClassName = "*";
|
||||
}
|
||||
|
||||
if (tileClassName == null) {
|
||||
tileClassName = "*";
|
||||
}
|
||||
|
||||
if (blockName == null) {
|
||||
blockName = "*";
|
||||
}
|
||||
|
||||
if (mod == null) {
|
||||
mod = "*";
|
||||
}
|
||||
|
||||
if (modVersion == null) {
|
||||
modVersion = "*";
|
||||
}
|
||||
|
||||
if (customField == null) {
|
||||
customField = "*";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
public class BlockSignature {
|
||||
|
||||
public String blockClassName;
|
||||
public String tileClassName;
|
||||
public String blockName;
|
||||
public String mod;
|
||||
public String modVersion;
|
||||
public String customField;
|
||||
|
||||
public BlockSignature(String str) {
|
||||
String[] values = str.split("/");
|
||||
|
||||
int i = 0;
|
||||
|
||||
if (values[0].equals("#B")) {
|
||||
i++;
|
||||
}
|
||||
|
||||
blockClassName = values[i];
|
||||
tileClassName = values[i + 1];
|
||||
blockName = values[i + 2];
|
||||
mod = values[i + 3];
|
||||
modVersion = values[i + 4];
|
||||
customField = values[i + 5];
|
||||
|
||||
replaceNullWithStar();
|
||||
|
||||
}
|
||||
|
||||
public BlockSignature() {
|
||||
replaceNullWithStar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
replaceNullWithStar();
|
||||
|
||||
return "#B/" + blockClassName + "/" + tileClassName + "/" + blockName + "/" + mod + "/" + modVersion + "/" + customField;
|
||||
}
|
||||
|
||||
public void replaceNullWithStar() {
|
||||
if (blockClassName == null) {
|
||||
blockClassName = "*";
|
||||
}
|
||||
|
||||
if (tileClassName == null) {
|
||||
tileClassName = "*";
|
||||
}
|
||||
|
||||
if (blockName == null) {
|
||||
blockName = "*";
|
||||
}
|
||||
|
||||
if (mod == null) {
|
||||
mod = "*";
|
||||
}
|
||||
|
||||
if (modVersion == null) {
|
||||
modVersion = "*";
|
||||
}
|
||||
|
||||
if (customField == null) {
|
||||
customField = "*";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BlueprintManager {
|
||||
|
||||
public static BptBlock[] blockBptProps = new BptBlock[Block.blocksList.length];
|
||||
|
||||
public static ItemSignature getItemSignature(Item item) {
|
||||
ItemSignature sig = new ItemSignature();
|
||||
|
||||
if (item.shiftedIndex >= Block.blocksList.length + BuildCraftAPI.LAST_ORIGINAL_ITEM) {
|
||||
sig.itemClassName = item.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
sig.itemName = item.getItemNameIS(new ItemStack(item));
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static BlockSignature getBlockSignature(Block block) {
|
||||
return BlueprintManager.blockBptProps[0].getSignature(block);
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize defaults for block properties.
|
||||
for (int i = 0; i < BlueprintManager.blockBptProps.length; ++i) {
|
||||
new BptBlock(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BlueprintManager {
|
||||
|
||||
public static BptBlock[] blockBptProps = new BptBlock[Block.blocksList.length];
|
||||
|
||||
public static ItemSignature getItemSignature(Item item) {
|
||||
ItemSignature sig = new ItemSignature();
|
||||
|
||||
if (item.shiftedIndex >= Block.blocksList.length + BuildCraftAPI.LAST_ORIGINAL_ITEM) {
|
||||
sig.itemClassName = item.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
sig.itemName = item.getItemNameIS(new ItemStack(item));
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
public static BlockSignature getBlockSignature(Block block) {
|
||||
return BlueprintManager.blockBptProps[0].getSignature(block);
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize defaults for block properties.
|
||||
for (int i = 0; i < BlueprintManager.blockBptProps.length; ++i) {
|
||||
new BptBlock(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,266 +1,266 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
/**
|
||||
* This class allow to specify specific behavior for blocks stored in
|
||||
* blueprints:
|
||||
*
|
||||
* - what items needs to be used to create that block - how the block has to be
|
||||
* built on the world - how to rotate the block - what extra data to store /
|
||||
* load in the blueprint
|
||||
*
|
||||
* Default implementations of this can be seen in the package
|
||||
* buildcraft.api.bptblocks. The class BptBlockUtils provide
|
||||
* some additional utilities.
|
||||
*
|
||||
* Blueprints perform "id translation" in case the block ids between a blueprint
|
||||
* and the world installation are different. In order to translate block ids,
|
||||
* blocks needs to be uniquely identified. By default, this identification is
|
||||
* done by:
|
||||
*
|
||||
* - the block simple class name - the tile simple class name (if any) - the
|
||||
* block name
|
||||
*
|
||||
* In certain circumstances, the above is not enough (e.g. if several blocks
|
||||
* share the same class and the same name, with no tile). In this case,
|
||||
* additional data may be provided by children of this class:
|
||||
*
|
||||
* - mod name - custom signature
|
||||
*
|
||||
* At blueprint load time, BuildCraft will check that each block id of the
|
||||
* blueprint corresponds to the block id in the installation. If not, it will
|
||||
* perform a search through the block list, and upon matching signature, it will
|
||||
* translate all blocks ids of the blueprint to the installation ones. If no
|
||||
* such block id is found, BuildCraft will assume that the block is not
|
||||
* installed and will not load the blueprint.
|
||||
*/
|
||||
public class BptBlock {
|
||||
|
||||
public final int blockId;
|
||||
|
||||
public BptBlock(int blockId) {
|
||||
this.blockId = blockId;
|
||||
|
||||
BlueprintManager.blockBptProps[blockId] = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 buildBlock.
|
||||
*/
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.blockId != 0) {
|
||||
if (slot.storedRequirements.size() != 0) {
|
||||
requirements.addAll(slot.storedRequirements);
|
||||
} else {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, slot.meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called each time an item matches a reqquirement, that is: (req id
|
||||
* == stack id) for damageable items (req id == stack id && req dmg == stack
|
||||
* dmg) for other items by default, it will increase damage of damageable
|
||||
* items by the amount of damage of the requirement, and remove the intended
|
||||
* amount of non damageable item.
|
||||
*
|
||||
* Client may override this behavior for default items. 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
|
||||
* fullfilled, and once with the real inventory. Implementer is responsible
|
||||
* for updating req (with the remaining requirements if any) and stack
|
||||
* (after usage)
|
||||
*
|
||||
* returns: what was used (similer to req, but created from stack, so that any NBT based differences are drawn from the correct source)
|
||||
*/
|
||||
public ItemStack useItem(BptSlotInfo slot, IBptContext context, ItemStack req, ItemStack stack) {
|
||||
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()) {
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
} 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.getItem().getContainerItem() != null) {
|
||||
Item container = stack.getItem().getContainerItem();
|
||||
|
||||
stack.itemID = container.shiftedIndex;
|
||||
stack.stackSize = 1;
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Added metadata sensitivity //Krapht
|
||||
*/
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z)
|
||||
&& slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a 90 degree rotation to the slot.
|
||||
*/
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the block in the world, at the location specified in the slot.
|
||||
*/
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
// Meta needs to be specified twice, depending on the block behavior
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta);
|
||||
|
||||
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
slot.cpt.setInteger("x", slot.x);
|
||||
slot.cpt.setInteger("y", slot.y);
|
||||
slot.cpt.setInteger("z", slot.z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(slot.cpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a slot from the blueprint according to an objet placed on {x,
|
||||
* y, z} on the world. This typically means adding entries in slot.cpt. Note
|
||||
* that "id" and "meta" will be set automatically, corresponding to the
|
||||
* block id and meta.
|
||||
*
|
||||
* By default, if the block is a BlockContainer, tile information will be to
|
||||
* save / load the block.
|
||||
*/
|
||||
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
|
||||
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.writeToNBT(slot.cpt);
|
||||
}
|
||||
}
|
||||
|
||||
if (Block.blocksList[slot.blockId] != null) {
|
||||
ArrayList<ItemStack> req = Block.blocksList[slot.blockId].getBlockDropped(context.world(), x, y, z, context.world()
|
||||
.getBlockMetadata(x, y, z), 0);
|
||||
|
||||
if (req != null) {
|
||||
slot.storedRequirements.addAll(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, block class name, block tile name and block name are used to
|
||||
* define block signature. Overriding this subprogram may allow to replace
|
||||
* some of these with stars, specify the mod that this block kind is coming
|
||||
* from or add custom data to the signature.
|
||||
*/
|
||||
public BlockSignature getSignature(Block block) {
|
||||
BlockSignature sig = new BlockSignature();
|
||||
|
||||
if (block.blockID > BuildCraftAPI.LAST_ORIGINAL_BLOCK) {
|
||||
sig.blockClassName = block.getClass().getSimpleName();
|
||||
|
||||
if (block instanceof BlockContainer) {
|
||||
//TODO: Try to see if we can get a world instance to call with instead of null
|
||||
TileEntity tile = ((BlockContainer) block).createNewTileEntity(null);
|
||||
|
||||
if (tile != null) {
|
||||
sig.tileClassName = tile.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sig.blockName = block.getBlockName();
|
||||
sig.replaceNullWithStar();
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, block name, block and tile classes, mod name and custom
|
||||
* signature are matched to verify if a blueprint block corresponds to the
|
||||
* installation block - except for the default blocks which don't check for
|
||||
* classes. For any value, * means match with anything. For compatibilty and
|
||||
* evolution reasons, mods may want to write a different policy, allowing to
|
||||
* migrate one format to the other.
|
||||
*/
|
||||
public boolean match(Block block, BlockSignature sig) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockSignature inst = BlueprintManager.getBlockSignature(block);
|
||||
|
||||
return starMatch(sig.blockName, inst.blockName) && starMatch(sig.blockClassName, inst.blockClassName)
|
||||
&& starMatch(sig.tileClassName, inst.tileClassName) && starMatch(sig.customField, inst.customField)
|
||||
&& starMatch(sig.mod, inst.mod);
|
||||
}
|
||||
|
||||
private boolean starMatch(String s1, String s2) {
|
||||
return s1.equals("*") || s2.equals("*") || s1.equals(s2);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
/**
|
||||
* This class allow to specify specific behavior for blocks stored in
|
||||
* blueprints:
|
||||
*
|
||||
* - what items needs to be used to create that block - how the block has to be
|
||||
* built on the world - how to rotate the block - what extra data to store /
|
||||
* load in the blueprint
|
||||
*
|
||||
* Default implementations of this can be seen in the package
|
||||
* buildcraft.api.bptblocks. The class BptBlockUtils provide
|
||||
* some additional utilities.
|
||||
*
|
||||
* Blueprints perform "id translation" in case the block ids between a blueprint
|
||||
* and the world installation are different. In order to translate block ids,
|
||||
* blocks needs to be uniquely identified. By default, this identification is
|
||||
* done by:
|
||||
*
|
||||
* - the block simple class name - the tile simple class name (if any) - the
|
||||
* block name
|
||||
*
|
||||
* In certain circumstances, the above is not enough (e.g. if several blocks
|
||||
* share the same class and the same name, with no tile). In this case,
|
||||
* additional data may be provided by children of this class:
|
||||
*
|
||||
* - mod name - custom signature
|
||||
*
|
||||
* At blueprint load time, BuildCraft will check that each block id of the
|
||||
* blueprint corresponds to the block id in the installation. If not, it will
|
||||
* perform a search through the block list, and upon matching signature, it will
|
||||
* translate all blocks ids of the blueprint to the installation ones. If no
|
||||
* such block id is found, BuildCraft will assume that the block is not
|
||||
* installed and will not load the blueprint.
|
||||
*/
|
||||
public class BptBlock {
|
||||
|
||||
public final int blockId;
|
||||
|
||||
public BptBlock(int blockId) {
|
||||
this.blockId = blockId;
|
||||
|
||||
BlueprintManager.blockBptProps[blockId] = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 buildBlock.
|
||||
*/
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.blockId != 0) {
|
||||
if (slot.storedRequirements.size() != 0) {
|
||||
requirements.addAll(slot.storedRequirements);
|
||||
} else {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, slot.meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called each time an item matches a reqquirement, that is: (req id
|
||||
* == stack id) for damageable items (req id == stack id && req dmg == stack
|
||||
* dmg) for other items by default, it will increase damage of damageable
|
||||
* items by the amount of damage of the requirement, and remove the intended
|
||||
* amount of non damageable item.
|
||||
*
|
||||
* Client may override this behavior for default items. 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
|
||||
* fullfilled, and once with the real inventory. Implementer is responsible
|
||||
* for updating req (with the remaining requirements if any) and stack
|
||||
* (after usage)
|
||||
*
|
||||
* returns: what was used (similer to req, but created from stack, so that any NBT based differences are drawn from the correct source)
|
||||
*/
|
||||
public ItemStack useItem(BptSlotInfo slot, IBptContext context, ItemStack req, ItemStack stack) {
|
||||
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()) {
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
} 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.getItem().getContainerItem() != null) {
|
||||
Item container = stack.getItem().getContainerItem();
|
||||
|
||||
stack.itemID = container.shiftedIndex;
|
||||
stack.stackSize = 1;
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Added metadata sensitivity //Krapht
|
||||
*/
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z)
|
||||
&& slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a 90 degree rotation to the slot.
|
||||
*/
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the block in the world, at the location specified in the slot.
|
||||
*/
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
// Meta needs to be specified twice, depending on the block behavior
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta);
|
||||
|
||||
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
slot.cpt.setInteger("x", slot.x);
|
||||
slot.cpt.setInteger("y", slot.y);
|
||||
slot.cpt.setInteger("z", slot.z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(slot.cpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a slot from the blueprint according to an objet placed on {x,
|
||||
* y, z} on the world. This typically means adding entries in slot.cpt. Note
|
||||
* that "id" and "meta" will be set automatically, corresponding to the
|
||||
* block id and meta.
|
||||
*
|
||||
* By default, if the block is a BlockContainer, tile information will be to
|
||||
* save / load the block.
|
||||
*/
|
||||
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
|
||||
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
|
||||
TileEntity tile = context.world().getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.writeToNBT(slot.cpt);
|
||||
}
|
||||
}
|
||||
|
||||
if (Block.blocksList[slot.blockId] != null) {
|
||||
ArrayList<ItemStack> req = Block.blocksList[slot.blockId].getBlockDropped(context.world(), x, y, z, context.world()
|
||||
.getBlockMetadata(x, y, z), 0);
|
||||
|
||||
if (req != null) {
|
||||
slot.storedRequirements.addAll(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, block class name, block tile name and block name are used to
|
||||
* define block signature. Overriding this subprogram may allow to replace
|
||||
* some of these with stars, specify the mod that this block kind is coming
|
||||
* from or add custom data to the signature.
|
||||
*/
|
||||
public BlockSignature getSignature(Block block) {
|
||||
BlockSignature sig = new BlockSignature();
|
||||
|
||||
if (block.blockID > BuildCraftAPI.LAST_ORIGINAL_BLOCK) {
|
||||
sig.blockClassName = block.getClass().getSimpleName();
|
||||
|
||||
if (block instanceof BlockContainer) {
|
||||
//TODO: Try to see if we can get a world instance to call with instead of null
|
||||
TileEntity tile = ((BlockContainer) block).createNewTileEntity(null);
|
||||
|
||||
if (tile != null) {
|
||||
sig.tileClassName = tile.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sig.blockName = block.getBlockName();
|
||||
sig.replaceNullWithStar();
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, block name, block and tile classes, mod name and custom
|
||||
* signature are matched to verify if a blueprint block corresponds to the
|
||||
* installation block - except for the default blocks which don't check for
|
||||
* classes. For any value, * means match with anything. For compatibilty and
|
||||
* evolution reasons, mods may want to write a different policy, allowing to
|
||||
* migrate one format to the other.
|
||||
*/
|
||||
public boolean match(Block block, BlockSignature sig) {
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockSignature inst = BlueprintManager.getBlockSignature(block);
|
||||
|
||||
return starMatch(sig.blockName, inst.blockName) && starMatch(sig.blockClassName, inst.blockClassName)
|
||||
&& starMatch(sig.tileClassName, inst.tileClassName) && starMatch(sig.customField, inst.customField)
|
||||
&& starMatch(sig.mod, inst.mod);
|
||||
}
|
||||
|
||||
private boolean starMatch(String s1, String s2) {
|
||||
return s1.equals("*") || s2.equals("*") || s1.equals(s2);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
|
||||
public class BptBlockUtils {
|
||||
|
||||
public static void requestInventoryContents(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
ItemStack[] stacks = getItemStacks(slot, context);
|
||||
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
requirements.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializeInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) {
|
||||
ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
stacks[i] = inventory.getStackInSlot(i);
|
||||
}
|
||||
|
||||
setItemStacks(slot, context, stacks);
|
||||
}
|
||||
|
||||
public static void buildInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) {
|
||||
ItemStack[] stacks = getItemStacks(slot, context);
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
inventory.setInventorySlotContents(i, stacks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack[] getItemStacks(BptSlotInfo slot, IBptContext context) {
|
||||
NBTTagList list = (NBTTagList) slot.cpt.getTag("inv");
|
||||
|
||||
if (list == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
ItemStack stacks[] = new ItemStack[list.tagCount()];
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) list.tagAt(i));
|
||||
|
||||
if (stack != null && stack.itemID != 0 && stack.stackSize > 0) {
|
||||
stacks[i] = context.mapItemStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static void setItemStacks(BptSlotInfo slot, IBptContext context, ItemStack[] stacks) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
nbttaglist.appendTag(cpt);
|
||||
ItemStack stack = stacks[i];
|
||||
|
||||
if (stack != null && stack.stackSize != 0) {
|
||||
stack.writeToNBT(cpt);
|
||||
context.storeId(stack.itemID);
|
||||
}
|
||||
}
|
||||
|
||||
slot.cpt.setTag("inv", nbttaglist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
|
||||
public class BptBlockUtils {
|
||||
|
||||
public static void requestInventoryContents(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
ItemStack[] stacks = getItemStacks(slot, context);
|
||||
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
requirements.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializeInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) {
|
||||
ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
stacks[i] = inventory.getStackInSlot(i);
|
||||
}
|
||||
|
||||
setItemStacks(slot, context, stacks);
|
||||
}
|
||||
|
||||
public static void buildInventoryContents(BptSlotInfo slot, IBptContext context, IInventory inventory) {
|
||||
ItemStack[] stacks = getItemStacks(slot, context);
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
inventory.setInventorySlotContents(i, stacks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack[] getItemStacks(BptSlotInfo slot, IBptContext context) {
|
||||
NBTTagList list = (NBTTagList) slot.cpt.getTag("inv");
|
||||
|
||||
if (list == null) {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
ItemStack stacks[] = new ItemStack[list.tagCount()];
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) list.tagAt(i));
|
||||
|
||||
if (stack != null && stack.itemID != 0 && stack.stackSize > 0) {
|
||||
stacks[i] = context.mapItemStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static void setItemStacks(BptSlotInfo slot, IBptContext context, ItemStack[] stacks) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
nbttaglist.appendTag(cpt);
|
||||
ItemStack stack = stacks[i];
|
||||
|
||||
if (stack != null && stack.stackSize != 0) {
|
||||
stack.writeToNBT(cpt);
|
||||
context.storeId(stack.itemID);
|
||||
}
|
||||
}
|
||||
|
||||
slot.cpt.setTag("inv", nbttaglist);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* This class records a slot, either from a blueprint or from a block placed in
|
||||
* the world.
|
||||
*/
|
||||
public class BptSlotInfo {
|
||||
|
||||
public int blockId = 0;
|
||||
public int meta = 0;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* BptBlock.
|
||||
*/
|
||||
public LinkedList<ItemStack> storedRequirements = new LinkedList<ItemStack>();
|
||||
|
||||
/**
|
||||
* This tree contains additional data to be stored in the blueprint. By
|
||||
* default, it will be initialized from BptBlock.initializeFromWorld with
|
||||
* the standard readNBT function of the corresponding tile (if any) and will
|
||||
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
|
||||
*/
|
||||
public NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
@Override
|
||||
public BptSlotInfo clone() {
|
||||
BptSlotInfo obj = new BptSlotInfo();
|
||||
|
||||
obj.x = x;
|
||||
obj.y = y;
|
||||
obj.z = z;
|
||||
obj.blockId = blockId;
|
||||
obj.meta = meta;
|
||||
obj.cpt = (NBTTagCompound) cpt.copy();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* This class records a slot, either from a blueprint or from a block placed in
|
||||
* the world.
|
||||
*/
|
||||
public class BptSlotInfo {
|
||||
|
||||
public int blockId = 0;
|
||||
public int meta = 0;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* BptBlock.
|
||||
*/
|
||||
public LinkedList<ItemStack> storedRequirements = new LinkedList<ItemStack>();
|
||||
|
||||
/**
|
||||
* This tree contains additional data to be stored in the blueprint. By
|
||||
* default, it will be initialized from BptBlock.initializeFromWorld with
|
||||
* the standard readNBT function of the corresponding tile (if any) and will
|
||||
* be loaded from BptBlock.buildBlock using the standard writeNBT function.
|
||||
*/
|
||||
public NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
@Override
|
||||
public BptSlotInfo clone() {
|
||||
BptSlotInfo obj = new BptSlotInfo();
|
||||
|
||||
obj.x = x;
|
||||
obj.y = y;
|
||||
obj.z = z;
|
||||
obj.blockId = blockId;
|
||||
obj.meta = meta;
|
||||
obj.cpt = (NBTTagCompound) cpt.copy();
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.api.core.Position;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
/**
|
||||
* This interface provide contextual information when building or initializing
|
||||
* blueprint slots.
|
||||
*/
|
||||
public interface IBptContext {
|
||||
|
||||
/**
|
||||
* If bptItemStack is an ItemStack extracted from the blueprint containing
|
||||
* this mapping, this will return an item stack with the id of the current
|
||||
* world
|
||||
*/
|
||||
public ItemStack mapItemStack(ItemStack bptItemStack);
|
||||
|
||||
/**
|
||||
* Blueprints may be created in a world with a given id setting, and then
|
||||
* ported to a world with different ids. Heuristics are used to retreive
|
||||
* these new ids automatically. This interface provide services to map ids
|
||||
* from a blueprints to current ids in the world, and should be used
|
||||
* whenever storing block numbers or item stacks in blueprints..
|
||||
*/
|
||||
public int mapWorldId(int bptWorldId);
|
||||
|
||||
/**
|
||||
* This asks the id mapping to store a mapping from this Id, which may be
|
||||
* either an itemId or a blockId. In effect, the blueprint will record it
|
||||
* and make it available upon blueprint load. Note that block present in the
|
||||
* blueprint are automatically stored upon blueprint save, so this is really
|
||||
* only needed when writing ids that are e.g. in inventory stacks.
|
||||
*/
|
||||
public void storeId(int worldId);
|
||||
|
||||
public Position rotatePositionLeft(Position pos);
|
||||
|
||||
public IBox surroundingBox();
|
||||
|
||||
public World world();
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.api.core.Position;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
/**
|
||||
* This interface provide contextual information when building or initializing
|
||||
* blueprint slots.
|
||||
*/
|
||||
public interface IBptContext {
|
||||
|
||||
/**
|
||||
* If bptItemStack is an ItemStack extracted from the blueprint containing
|
||||
* this mapping, this will return an item stack with the id of the current
|
||||
* world
|
||||
*/
|
||||
public ItemStack mapItemStack(ItemStack bptItemStack);
|
||||
|
||||
/**
|
||||
* Blueprints may be created in a world with a given id setting, and then
|
||||
* ported to a world with different ids. Heuristics are used to retreive
|
||||
* these new ids automatically. This interface provide services to map ids
|
||||
* from a blueprints to current ids in the world, and should be used
|
||||
* whenever storing block numbers or item stacks in blueprints..
|
||||
*/
|
||||
public int mapWorldId(int bptWorldId);
|
||||
|
||||
/**
|
||||
* This asks the id mapping to store a mapping from this Id, which may be
|
||||
* either an itemId or a blockId. In effect, the blueprint will record it
|
||||
* and make it available upon blueprint load. Note that block present in the
|
||||
* blueprint are automatically stored upon blueprint save, so this is really
|
||||
* only needed when writing ids that are e.g. in inventory stacks.
|
||||
*/
|
||||
public void storeId(int worldId);
|
||||
|
||||
public Position rotatePositionLeft(Position pos);
|
||||
|
||||
public IBox surroundingBox();
|
||||
|
||||
public World world();
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
public class ItemSignature {
|
||||
|
||||
public String itemClassName;
|
||||
public String itemName;
|
||||
|
||||
public ItemSignature(String str) {
|
||||
String[] values = str.split("/");
|
||||
|
||||
itemClassName = values[1];
|
||||
itemName = values[2];
|
||||
|
||||
replaceNullWithStar();
|
||||
|
||||
}
|
||||
|
||||
public ItemSignature() {
|
||||
replaceNullWithStar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
replaceNullWithStar();
|
||||
|
||||
return "#I/" + itemClassName + "/" + itemName;
|
||||
}
|
||||
|
||||
public void replaceNullWithStar() {
|
||||
if (itemClassName == null) {
|
||||
itemClassName = "*";
|
||||
}
|
||||
|
||||
if (itemName == null) {
|
||||
itemName = "*";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.blueprints;
|
||||
|
||||
public class ItemSignature {
|
||||
|
||||
public String itemClassName;
|
||||
public String itemName;
|
||||
|
||||
public ItemSignature(String str) {
|
||||
String[] values = str.split("/");
|
||||
|
||||
itemClassName = values[1];
|
||||
itemName = values[2];
|
||||
|
||||
replaceNullWithStar();
|
||||
|
||||
}
|
||||
|
||||
public ItemSignature() {
|
||||
replaceNullWithStar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
replaceNullWithStar();
|
||||
|
||||
return "#I/" + itemClassName + "/" + itemName;
|
||||
}
|
||||
|
||||
public void replaceNullWithStar() {
|
||||
if (itemClassName == null) {
|
||||
itemClassName = "*";
|
||||
}
|
||||
|
||||
if (itemName == null) {
|
||||
itemName = "*";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +1,88 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockBed extends BptBlock {
|
||||
|
||||
public BptBlockBed(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
requirements.add(new ItemStack(Item.bed));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 7);
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if ((slot.meta & 8) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
|
||||
int x2 = slot.x;
|
||||
int z2 = slot.z;
|
||||
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
z2++;
|
||||
break;
|
||||
case 1:
|
||||
x2--;
|
||||
break;
|
||||
case 2:
|
||||
z2--;
|
||||
break;
|
||||
case 3:
|
||||
x2++;
|
||||
break;
|
||||
}
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(x2, slot.y, z2, slot.blockId, slot.meta + 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockBed extends BptBlock {
|
||||
|
||||
public BptBlockBed(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
requirements.add(new ItemStack(Item.bed));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 7);
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if ((slot.meta & 8) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
|
||||
int x2 = slot.x;
|
||||
int z2 = slot.z;
|
||||
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
z2++;
|
||||
break;
|
||||
case 1:
|
||||
x2--;
|
||||
break;
|
||||
case 2:
|
||||
z2--;
|
||||
break;
|
||||
case 3:
|
||||
x2++;
|
||||
break;
|
||||
}
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(x2, slot.y, z2, slot.blockId, slot.meta + 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockCustomStack extends BptBlock {
|
||||
|
||||
final ItemStack customStack;
|
||||
|
||||
public BptBlockCustomStack(int blockId, ItemStack customStack) {
|
||||
super(blockId);
|
||||
|
||||
this.customStack = customStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(customStack.copy());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockCustomStack extends BptBlock {
|
||||
|
||||
final ItemStack customStack;
|
||||
|
||||
public BptBlockCustomStack(int blockId, ItemStack customStack) {
|
||||
super(blockId);
|
||||
|
||||
this.customStack = customStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(customStack.copy());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDelegate extends BptBlock {
|
||||
|
||||
final int delegateTo;
|
||||
|
||||
public BptBlockDelegate(int blockId, int delegateTo) {
|
||||
super(blockId);
|
||||
|
||||
this.delegateTo = delegateTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements);
|
||||
} else {
|
||||
super.addRequirements(newSlot, context, requirements);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context);
|
||||
} else {
|
||||
return super.isValid(newSlot, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context);
|
||||
} else {
|
||||
super.rotateLeft(newSlot, context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BlueprintManager;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDelegate extends BptBlock {
|
||||
|
||||
final int delegateTo;
|
||||
|
||||
public BptBlockDelegate(int blockId, int delegateTo) {
|
||||
super(blockId);
|
||||
|
||||
this.delegateTo = delegateTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements);
|
||||
} else {
|
||||
super.addRequirements(newSlot, context, requirements);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context);
|
||||
} else {
|
||||
return super.isValid(newSlot, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
BptSlotInfo newSlot = slot.clone();
|
||||
slot.blockId = delegateTo;
|
||||
|
||||
if (BlueprintManager.blockBptProps[delegateTo] != null) {
|
||||
BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context);
|
||||
} else {
|
||||
super.rotateLeft(newSlot, context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDirt extends BptBlock {
|
||||
|
||||
public BptBlockDirt(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Block.dirt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, Block.dirt.blockID, slot.meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
int id = context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
|
||||
return id == Block.dirt.blockID || id == Block.grass.blockID || id == Block.tilledField.blockID;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDirt extends BptBlock {
|
||||
|
||||
public BptBlockDirt(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Block.dirt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, Block.dirt.blockID, slot.meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
int id = context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
|
||||
return id == Block.dirt.blockID || id == Block.grass.blockID || id == Block.tilledField.blockID;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDoor extends BptBlock {
|
||||
|
||||
final ItemStack stack;
|
||||
|
||||
public BptBlockDoor(int blockId, ItemStack stack) {
|
||||
super(blockId);
|
||||
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
requirements.add(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 3);
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.blockId, slot.meta + 8);
|
||||
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.meta + 8);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta);
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockDoor extends BptBlock {
|
||||
|
||||
final ItemStack stack;
|
||||
|
||||
public BptBlockDoor(int blockId, ItemStack stack) {
|
||||
super(blockId);
|
||||
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if ((slot.meta & 8) == 0) {
|
||||
requirements.add(stack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int orientation = (slot.meta & 3);
|
||||
int others = slot.meta - orientation;
|
||||
|
||||
switch (orientation) {
|
||||
case 0:
|
||||
slot.meta = 1 + others;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + others;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + others;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + others;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return (slot.meta & 8) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.blockId, slot.meta + 8);
|
||||
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.meta + 8);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockIgnore extends BptBlock {
|
||||
|
||||
public BptBlockIgnore(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockIgnore extends BptBlock {
|
||||
|
||||
public BptBlockIgnore(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockIgnoreMeta extends BptBlock {
|
||||
|
||||
public BptBlockIgnoreMeta(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockIgnoreMeta extends BptBlock {
|
||||
|
||||
public BptBlockIgnoreMeta(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public class BptBlockInventory extends BptBlock {
|
||||
|
||||
public BptBlockInventory(int blockId) {
|
||||
super(blockId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
|
||||
IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public class BptBlockInventory extends BptBlock {
|
||||
|
||||
public BptBlockInventory(int blockId) {
|
||||
super(blockId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
|
||||
IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockLever extends BptBlockWallSide {
|
||||
|
||||
public BptBlockLever(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int status = slot.meta - (slot.meta & 7);
|
||||
|
||||
slot.meta -= status;
|
||||
super.rotateLeft(slot, context);
|
||||
slot.meta += status;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockLever extends BptBlockWallSide {
|
||||
|
||||
public BptBlockLever(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int status = slot.meta - (slot.meta & 7);
|
||||
|
||||
slot.meta -= status;
|
||||
super.rotateLeft(slot, context);
|
||||
slot.meta += status;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockLiquid extends BptBlock {
|
||||
|
||||
private final ItemStack bucketStack;
|
||||
|
||||
public BptBlockLiquid(int blockId, ItemStack bucketStack) {
|
||||
super(blockId);
|
||||
|
||||
this.bucketStack = bucketStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.meta == 0) {
|
||||
requirements.add(bucketStack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z)
|
||||
&& context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return slot.meta != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockLiquid extends BptBlock {
|
||||
|
||||
private final ItemStack bucketStack;
|
||||
|
||||
public BptBlockLiquid(int blockId, ItemStack bucketStack) {
|
||||
super(blockId);
|
||||
|
||||
this.bucketStack = bucketStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
if (slot.meta == 0) {
|
||||
requirements.add(bucketStack.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z)
|
||||
&& context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreBuilding(BptSlotInfo slot) {
|
||||
return slot.meta != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
if (slot.meta == 0) {
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockPiston extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockPiston(int blockId) {
|
||||
super(blockId, new int[] { 2, 5, 3, 4 }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
int meta = slot.meta & 7;
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, meta);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
public class BptBlockPiston extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockPiston(int blockId) {
|
||||
super(blockId, new int[] { 2, 5, 3, 4 }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
int meta = slot.meta & 7;
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, meta);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockPumpkin extends BptBlock {
|
||||
|
||||
public BptBlockPumpkin(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
slot.meta = 1;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockPumpkin extends BptBlock {
|
||||
|
||||
public BptBlockPumpkin(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
slot.meta = 1;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockRedstoneRepeater extends BptBlock {
|
||||
|
||||
public BptBlockRedstoneRepeater(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Item.redstoneRepeater));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int step = slot.meta - (slot.meta & 3);
|
||||
|
||||
switch (slot.meta - step) {
|
||||
case 0:
|
||||
slot.meta = 1 + step;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + step;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + step;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockRedstoneRepeater extends BptBlock {
|
||||
|
||||
public BptBlockRedstoneRepeater(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Item.redstoneRepeater));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int step = slot.meta - (slot.meta & 3);
|
||||
|
||||
switch (slot.meta - step) {
|
||||
case 0:
|
||||
slot.meta = 1 + step;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 2 + step;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 3 + step;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0 + step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public class BptBlockRotateInventory extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockRotateInventory(int blockId, int[] rotations, boolean rotateForward) {
|
||||
super(blockId, rotations, rotateForward);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
|
||||
IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package buildcraft.api.bptblocks;
|
||||
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public class BptBlockRotateInventory extends BptBlockRotateMeta {
|
||||
|
||||
public BptBlockRotateInventory(int blockId, int[] rotations, boolean rotateForward) {
|
||||
super(blockId, rotations, rotateForward);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
super.buildBlock(slot, context);
|
||||
|
||||
IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
|
||||
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
inv.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +1,85 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockRotateMeta extends BptBlock {
|
||||
|
||||
int[] rot;
|
||||
boolean rotateForward;
|
||||
|
||||
int infoMask = 0;
|
||||
|
||||
public BptBlockRotateMeta(int blockId, int[] rotations, boolean rotateForward) {
|
||||
super(blockId);
|
||||
|
||||
rot = rotations;
|
||||
|
||||
for (int i = 0; i < rot.length; ++i) {
|
||||
if (rot[i] < 4) {
|
||||
infoMask = (infoMask < 3 ? 3 : infoMask);
|
||||
} else if (rot[i] < 8) {
|
||||
infoMask = (infoMask < 7 ? 7 : infoMask);
|
||||
} else if (rot[i] < 16) {
|
||||
infoMask = (infoMask < 15 ? 15 : infoMask);
|
||||
}
|
||||
}
|
||||
|
||||
this.rotateForward = rotateForward;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int pos = slot.meta & infoMask;
|
||||
int others = slot.meta - pos;
|
||||
|
||||
if (rotateForward) {
|
||||
if (pos == rot[0]) {
|
||||
pos = rot[1];
|
||||
} else if (pos == rot[1]) {
|
||||
pos = rot[2];
|
||||
} else if (pos == rot[2]) {
|
||||
pos = rot[3];
|
||||
} else if (pos == rot[3]) {
|
||||
pos = rot[0];
|
||||
}
|
||||
} else {
|
||||
if (pos == rot[0]) {
|
||||
pos = rot[3];
|
||||
} else if (pos == rot[1]) {
|
||||
pos = rot[2];
|
||||
} else if (pos == rot[2]) {
|
||||
pos = rot[0];
|
||||
} else if (pos == rot[3]) {
|
||||
pos = rot[1];
|
||||
}
|
||||
}
|
||||
|
||||
slot.meta = pos + others;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockRotateMeta extends BptBlock {
|
||||
|
||||
int[] rot;
|
||||
boolean rotateForward;
|
||||
|
||||
int infoMask = 0;
|
||||
|
||||
public BptBlockRotateMeta(int blockId, int[] rotations, boolean rotateForward) {
|
||||
super(blockId);
|
||||
|
||||
rot = rotations;
|
||||
|
||||
for (int i = 0; i < rot.length; ++i) {
|
||||
if (rot[i] < 4) {
|
||||
infoMask = (infoMask < 3 ? 3 : infoMask);
|
||||
} else if (rot[i] < 8) {
|
||||
infoMask = (infoMask < 7 ? 7 : infoMask);
|
||||
} else if (rot[i] < 16) {
|
||||
infoMask = (infoMask < 15 ? 15 : infoMask);
|
||||
}
|
||||
}
|
||||
|
||||
this.rotateForward = rotateForward;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
int pos = slot.meta & infoMask;
|
||||
int others = slot.meta - pos;
|
||||
|
||||
if (rotateForward) {
|
||||
if (pos == rot[0]) {
|
||||
pos = rot[1];
|
||||
} else if (pos == rot[1]) {
|
||||
pos = rot[2];
|
||||
} else if (pos == rot[2]) {
|
||||
pos = rot[3];
|
||||
} else if (pos == rot[3]) {
|
||||
pos = rot[0];
|
||||
}
|
||||
} else {
|
||||
if (pos == rot[0]) {
|
||||
pos = rot[3];
|
||||
} else if (pos == rot[1]) {
|
||||
pos = rot[2];
|
||||
} else if (pos == rot[2]) {
|
||||
pos = rot[0];
|
||||
} else if (pos == rot[3]) {
|
||||
pos = rot[1];
|
||||
}
|
||||
}
|
||||
|
||||
slot.meta = pos + others;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BlockSignature;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockSign extends BptBlock {
|
||||
|
||||
boolean isWall;
|
||||
|
||||
public BptBlockSign(int blockId, boolean isWall) {
|
||||
super(blockId);
|
||||
|
||||
this.isWall = isWall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Item.sign));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
if (!isWall) {
|
||||
double angle = ((slot.meta) * 360.0) / 16.0;
|
||||
angle += 90.0;
|
||||
if (angle >= 360) {
|
||||
angle -= 360;
|
||||
}
|
||||
slot.meta = (int) (angle / 360.0 * 16.0);
|
||||
} else {
|
||||
slot.meta = Orientations.values()[slot.meta].rotateLeft().ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockSignature getSignature(Block block) {
|
||||
BlockSignature sig = super.getSignature(block);
|
||||
|
||||
if (isWall) {
|
||||
sig.customField = "wall";
|
||||
} else {
|
||||
sig.customField = "floor";
|
||||
}
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BlockSignature;
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockSign extends BptBlock {
|
||||
|
||||
boolean isWall;
|
||||
|
||||
public BptBlockSign(int blockId, boolean isWall) {
|
||||
super(blockId);
|
||||
|
||||
this.isWall = isWall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(Item.sign));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
if (!isWall) {
|
||||
double angle = ((slot.meta) * 360.0) / 16.0;
|
||||
angle += 90.0;
|
||||
if (angle >= 360) {
|
||||
angle -= 360;
|
||||
}
|
||||
slot.meta = (int) (angle / 360.0 * 16.0);
|
||||
} else {
|
||||
slot.meta = Orientations.values()[slot.meta].rotateLeft().ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockSignature getSignature(Block block) {
|
||||
BlockSignature sig = super.getSignature(block);
|
||||
|
||||
if (isWall) {
|
||||
sig.customField = "wall";
|
||||
} else {
|
||||
sig.customField = "floor";
|
||||
}
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockStairs extends BptBlock {
|
||||
|
||||
public BptBlockStairs(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
slot.meta = 2;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 3;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 1;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockStairs extends BptBlock {
|
||||
|
||||
public BptBlockStairs(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(BptSlotInfo slot, IBptContext context) {
|
||||
return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
switch (slot.meta) {
|
||||
case 0:
|
||||
slot.meta = 2;
|
||||
break;
|
||||
case 1:
|
||||
slot.meta = 3;
|
||||
break;
|
||||
case 2:
|
||||
slot.meta = 1;
|
||||
break;
|
||||
case 3:
|
||||
slot.meta = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockWallSide extends BptBlock {
|
||||
|
||||
public BptBlockWallSide(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
final int XPos = 2;
|
||||
final int XNeg = 1;
|
||||
final int ZPos = 4;
|
||||
final int ZNeg = 3;
|
||||
|
||||
switch (slot.meta) {
|
||||
case XPos:
|
||||
slot.meta = ZPos;
|
||||
break;
|
||||
case ZNeg:
|
||||
slot.meta = XPos;
|
||||
break;
|
||||
case XNeg:
|
||||
slot.meta = ZNeg;
|
||||
break;
|
||||
case ZPos:
|
||||
slot.meta = XNeg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.bptblocks;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.blueprints.BptBlock;
|
||||
import buildcraft.api.blueprints.BptSlotInfo;
|
||||
import buildcraft.api.blueprints.IBptContext;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class BptBlockWallSide extends BptBlock {
|
||||
|
||||
public BptBlockWallSide(int blockId) {
|
||||
super(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList<ItemStack> requirements) {
|
||||
requirements.add(new ItemStack(slot.blockId, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(BptSlotInfo slot, IBptContext context) {
|
||||
final int XPos = 2;
|
||||
final int XNeg = 1;
|
||||
final int ZPos = 4;
|
||||
final int ZNeg = 3;
|
||||
|
||||
switch (slot.meta) {
|
||||
case XPos:
|
||||
slot.meta = ZPos;
|
||||
break;
|
||||
case ZNeg:
|
||||
slot.meta = XPos;
|
||||
break;
|
||||
case XNeg:
|
||||
slot.meta = ZNeg;
|
||||
break;
|
||||
case ZPos:
|
||||
slot.meta = XNeg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class BuildCraftAPI {
|
||||
|
||||
@Deprecated
|
||||
// To be removed, see LiquidManager
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static final int LAST_ORIGINAL_BLOCK = 122;
|
||||
public static final int LAST_ORIGINAL_ITEM = 126;
|
||||
|
||||
public static boolean[] softBlocks = new boolean[Block.blocksList.length];
|
||||
/**
|
||||
* Return true if the block given in parameter is pass through (e.g. air,
|
||||
* water...)
|
||||
*/
|
||||
public static boolean softBlock(int blockId) {
|
||||
return blockId == 0 || softBlocks[blockId] || Block.blocksList[blockId] == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the block cannot be broken, typically bedrock and lava
|
||||
*/
|
||||
public static boolean unbreakableBlock(int blockId) {
|
||||
return blockId == Block.bedrock.blockID || blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// To be removed
|
||||
public static void breakBlock(World world, int x, int y, int z) {
|
||||
int blockId = world.getBlockId(x, y, z);
|
||||
|
||||
if (blockId != 0) {
|
||||
Block.blocksList[blockId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
}
|
||||
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < softBlocks.length; ++i) {
|
||||
softBlocks[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class BuildCraftAPI {
|
||||
|
||||
@Deprecated
|
||||
// To be removed, see LiquidManager
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static final int LAST_ORIGINAL_BLOCK = 122;
|
||||
public static final int LAST_ORIGINAL_ITEM = 126;
|
||||
|
||||
public static boolean[] softBlocks = new boolean[Block.blocksList.length];
|
||||
/**
|
||||
* Return true if the block given in parameter is pass through (e.g. air,
|
||||
* water...)
|
||||
*/
|
||||
public static boolean softBlock(int blockId) {
|
||||
return blockId == 0 || softBlocks[blockId] || Block.blocksList[blockId] == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the block cannot be broken, typically bedrock and lava
|
||||
*/
|
||||
public static boolean unbreakableBlock(int blockId) {
|
||||
return blockId == Block.bedrock.blockID || blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// To be removed
|
||||
public static void breakBlock(World world, int x, int y, int z) {
|
||||
int blockId = world.getBlockId(x, y, z);
|
||||
|
||||
if (blockId != 0) {
|
||||
Block.blocksList[blockId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
}
|
||||
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < softBlocks.length; ++i) {
|
||||
softBlocks[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
/**
|
||||
* To be implemented by TileEntities able to provide a square area on the world,
|
||||
* typically BuildCraft markers.
|
||||
*/
|
||||
public interface IAreaProvider {
|
||||
|
||||
public int xMin();
|
||||
|
||||
public int yMin();
|
||||
|
||||
public int zMin();
|
||||
|
||||
public int xMax();
|
||||
|
||||
public int yMax();
|
||||
|
||||
public int zMax();
|
||||
|
||||
/**
|
||||
* Remove from the world all objects used to define the area.
|
||||
*/
|
||||
public void removeFromWorld();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
/**
|
||||
* To be implemented by TileEntities able to provide a square area on the world,
|
||||
* typically BuildCraft markers.
|
||||
*/
|
||||
public interface IAreaProvider {
|
||||
|
||||
public int xMin();
|
||||
|
||||
public int yMin();
|
||||
|
||||
public int zMin();
|
||||
|
||||
public int xMax();
|
||||
|
||||
public int yMax();
|
||||
|
||||
public int zMax();
|
||||
|
||||
/**
|
||||
* Remove from the world all objects used to define the area.
|
||||
*/
|
||||
public void removeFromWorld();
|
||||
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface IBox {
|
||||
|
||||
public void expand(int amount);
|
||||
|
||||
public void contract(int amount);
|
||||
|
||||
public boolean contains(int x, int y, int z);
|
||||
|
||||
public Position pMin();
|
||||
|
||||
public Position pMax();
|
||||
|
||||
public void createLasers(World world, LaserKind kind);
|
||||
|
||||
public void deleteLasers();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface IBox {
|
||||
|
||||
public void expand(int amount);
|
||||
|
||||
public void contract(int amount);
|
||||
|
||||
public boolean contains(int x, int y, int z);
|
||||
|
||||
public Position pMin();
|
||||
|
||||
public Position pMax();
|
||||
|
||||
public void createLasers(World world, LaserKind kind);
|
||||
|
||||
public void deleteLasers();
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
public enum LaserKind {
|
||||
Red, Blue, Stripes
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
public enum LaserKind {
|
||||
Red, Blue, Stripes
|
||||
}
|
||||
@@ -1,80 +1,80 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public enum Orientations {
|
||||
YNeg, // 0
|
||||
YPos, // 1
|
||||
ZNeg, // 2
|
||||
ZPos, // 3
|
||||
XNeg, // 4
|
||||
XPos, // 5
|
||||
Unknown;
|
||||
|
||||
public Orientations reverse() {
|
||||
switch (this) {
|
||||
case YPos:
|
||||
return Orientations.YNeg;
|
||||
case YNeg:
|
||||
return Orientations.YPos;
|
||||
case ZPos:
|
||||
return Orientations.ZNeg;
|
||||
case ZNeg:
|
||||
return Orientations.ZPos;
|
||||
case XPos:
|
||||
return Orientations.XNeg;
|
||||
case XNeg:
|
||||
return Orientations.XPos;
|
||||
default:
|
||||
return Orientations.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection toDirection(){
|
||||
switch(this){
|
||||
case YNeg:
|
||||
return ForgeDirection.DOWN;
|
||||
case YPos:
|
||||
return ForgeDirection.UP;
|
||||
case ZNeg:
|
||||
return ForgeDirection.NORTH;
|
||||
case ZPos:
|
||||
return ForgeDirection.SOUTH;
|
||||
case XNeg:
|
||||
return ForgeDirection.WEST;
|
||||
case XPos:
|
||||
return ForgeDirection.EAST;
|
||||
default:
|
||||
return ForgeDirection.UNKNOWN;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Orientations rotateLeft() {
|
||||
switch (this) {
|
||||
case XPos:
|
||||
return ZPos;
|
||||
case ZNeg:
|
||||
return XPos;
|
||||
case XNeg:
|
||||
return ZNeg;
|
||||
case ZPos:
|
||||
return XNeg;
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static Orientations[] dirs() {
|
||||
return new Orientations[] { YNeg, YPos, ZNeg, ZPos, XNeg, XPos };
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public enum Orientations {
|
||||
YNeg, // 0
|
||||
YPos, // 1
|
||||
ZNeg, // 2
|
||||
ZPos, // 3
|
||||
XNeg, // 4
|
||||
XPos, // 5
|
||||
Unknown;
|
||||
|
||||
public Orientations reverse() {
|
||||
switch (this) {
|
||||
case YPos:
|
||||
return Orientations.YNeg;
|
||||
case YNeg:
|
||||
return Orientations.YPos;
|
||||
case ZPos:
|
||||
return Orientations.ZNeg;
|
||||
case ZNeg:
|
||||
return Orientations.ZPos;
|
||||
case XPos:
|
||||
return Orientations.XNeg;
|
||||
case XNeg:
|
||||
return Orientations.XPos;
|
||||
default:
|
||||
return Orientations.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection toDirection(){
|
||||
switch(this){
|
||||
case YNeg:
|
||||
return ForgeDirection.DOWN;
|
||||
case YPos:
|
||||
return ForgeDirection.UP;
|
||||
case ZNeg:
|
||||
return ForgeDirection.NORTH;
|
||||
case ZPos:
|
||||
return ForgeDirection.SOUTH;
|
||||
case XNeg:
|
||||
return ForgeDirection.WEST;
|
||||
case XPos:
|
||||
return ForgeDirection.EAST;
|
||||
default:
|
||||
return ForgeDirection.UNKNOWN;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Orientations rotateLeft() {
|
||||
switch (this) {
|
||||
case XPos:
|
||||
return ZPos;
|
||||
case ZNeg:
|
||||
return XPos;
|
||||
case XNeg:
|
||||
return ZNeg;
|
||||
case ZPos:
|
||||
return XNeg;
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static Orientations[] dirs() {
|
||||
return new Orientations[] { YNeg, YPos, ZNeg, ZPos, XNeg, XPos };
|
||||
}
|
||||
}
|
||||
@@ -1,141 +1,141 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class Position {
|
||||
|
||||
public double x, y, z;
|
||||
public Orientations orientation;
|
||||
|
||||
public Position(double ci, double cj, double ck) {
|
||||
x = ci;
|
||||
y = cj;
|
||||
z = ck;
|
||||
orientation = Orientations.Unknown;
|
||||
}
|
||||
|
||||
public Position(double ci, double cj, double ck, Orientations corientation) {
|
||||
x = ci;
|
||||
y = cj;
|
||||
z = ck;
|
||||
orientation = corientation;
|
||||
}
|
||||
|
||||
public Position(Position p) {
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
z = p.z;
|
||||
orientation = p.orientation;
|
||||
}
|
||||
|
||||
public Position(NBTTagCompound nbttagcompound) {
|
||||
x = nbttagcompound.getDouble("i");
|
||||
y = nbttagcompound.getDouble("j");
|
||||
z = nbttagcompound.getDouble("k");
|
||||
|
||||
orientation = Orientations.Unknown;
|
||||
}
|
||||
|
||||
public Position(TileEntity tile) {
|
||||
x = tile.xCoord;
|
||||
y = tile.yCoord;
|
||||
z = tile.zCoord;
|
||||
}
|
||||
|
||||
public void moveRight(double step) {
|
||||
switch (orientation) {
|
||||
case ZPos:
|
||||
x = x - step;
|
||||
break;
|
||||
case ZNeg:
|
||||
x = x + step;
|
||||
break;
|
||||
case XPos:
|
||||
z = z + step;
|
||||
break;
|
||||
case XNeg:
|
||||
z = z - step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void moveLeft(double step) {
|
||||
moveRight(-step);
|
||||
}
|
||||
|
||||
public void moveForwards(double step) {
|
||||
switch (orientation) {
|
||||
case YPos:
|
||||
y = y + step;
|
||||
break;
|
||||
case YNeg:
|
||||
y = y - step;
|
||||
break;
|
||||
case ZPos:
|
||||
z = z + step;
|
||||
break;
|
||||
case ZNeg:
|
||||
z = z - step;
|
||||
break;
|
||||
case XPos:
|
||||
x = x + step;
|
||||
break;
|
||||
case XNeg:
|
||||
x = x - step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void moveBackwards(double step) {
|
||||
moveForwards(-step);
|
||||
}
|
||||
|
||||
public void moveUp(double step) {
|
||||
switch (orientation) {
|
||||
case ZPos:
|
||||
case ZNeg:
|
||||
case XPos:
|
||||
case XNeg:
|
||||
y = y + step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void moveDown(double step) {
|
||||
moveUp(-step);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setDouble("i", x);
|
||||
nbttagcompound.setDouble("j", y);
|
||||
nbttagcompound.setDouble("k", z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + x + ", " + y + ", " + z + "}";
|
||||
}
|
||||
|
||||
public Position min(Position p) {
|
||||
return new Position(p.x > x ? x : p.x, p.y > y ? y : p.y, p.z > z ? z : p.z);
|
||||
}
|
||||
|
||||
public Position max(Position p) {
|
||||
return new Position(p.x < x ? x : p.x, p.y < y ? y : p.y, p.z < z ? z : p.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class Position {
|
||||
|
||||
public double x, y, z;
|
||||
public Orientations orientation;
|
||||
|
||||
public Position(double ci, double cj, double ck) {
|
||||
x = ci;
|
||||
y = cj;
|
||||
z = ck;
|
||||
orientation = Orientations.Unknown;
|
||||
}
|
||||
|
||||
public Position(double ci, double cj, double ck, Orientations corientation) {
|
||||
x = ci;
|
||||
y = cj;
|
||||
z = ck;
|
||||
orientation = corientation;
|
||||
}
|
||||
|
||||
public Position(Position p) {
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
z = p.z;
|
||||
orientation = p.orientation;
|
||||
}
|
||||
|
||||
public Position(NBTTagCompound nbttagcompound) {
|
||||
x = nbttagcompound.getDouble("i");
|
||||
y = nbttagcompound.getDouble("j");
|
||||
z = nbttagcompound.getDouble("k");
|
||||
|
||||
orientation = Orientations.Unknown;
|
||||
}
|
||||
|
||||
public Position(TileEntity tile) {
|
||||
x = tile.xCoord;
|
||||
y = tile.yCoord;
|
||||
z = tile.zCoord;
|
||||
}
|
||||
|
||||
public void moveRight(double step) {
|
||||
switch (orientation) {
|
||||
case ZPos:
|
||||
x = x - step;
|
||||
break;
|
||||
case ZNeg:
|
||||
x = x + step;
|
||||
break;
|
||||
case XPos:
|
||||
z = z + step;
|
||||
break;
|
||||
case XNeg:
|
||||
z = z - step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void moveLeft(double step) {
|
||||
moveRight(-step);
|
||||
}
|
||||
|
||||
public void moveForwards(double step) {
|
||||
switch (orientation) {
|
||||
case YPos:
|
||||
y = y + step;
|
||||
break;
|
||||
case YNeg:
|
||||
y = y - step;
|
||||
break;
|
||||
case ZPos:
|
||||
z = z + step;
|
||||
break;
|
||||
case ZNeg:
|
||||
z = z - step;
|
||||
break;
|
||||
case XPos:
|
||||
x = x + step;
|
||||
break;
|
||||
case XNeg:
|
||||
x = x - step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public void moveBackwards(double step) {
|
||||
moveForwards(-step);
|
||||
}
|
||||
|
||||
public void moveUp(double step) {
|
||||
switch (orientation) {
|
||||
case ZPos:
|
||||
case ZNeg:
|
||||
case XPos:
|
||||
case XNeg:
|
||||
y = y + step;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void moveDown(double step) {
|
||||
moveUp(-step);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setDouble("i", x);
|
||||
nbttagcompound.setDouble("j", y);
|
||||
nbttagcompound.setDouble("k", z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + x + ", " + y + ", " + z + "}";
|
||||
}
|
||||
|
||||
public Position min(Position p) {
|
||||
return new Position(p.x > x ? x : p.x, p.y > y ? y : p.y, p.z > z ? z : p.z);
|
||||
}
|
||||
|
||||
public Position max(Position p) {
|
||||
return new Position(p.x < x ? x : p.x, p.y < y ? y : p.y, p.z < z ? z : p.z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class SafeTimeTracker {
|
||||
|
||||
private long lastMark = 0;
|
||||
|
||||
/**
|
||||
* Return true if a given delay has passed since last time marked was called
|
||||
* successfully.
|
||||
*/
|
||||
public boolean markTimeIfDelay(World world, long delay) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long currentTime = world.getWorldTime();
|
||||
|
||||
if (currentTime < lastMark) {
|
||||
lastMark = currentTime;
|
||||
return false;
|
||||
} else if (lastMark + delay <= currentTime) {
|
||||
lastMark = world.getWorldTime();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void markTime(World world) {
|
||||
lastMark = world.getWorldTime();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.core;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class SafeTimeTracker {
|
||||
|
||||
private long lastMark = 0;
|
||||
|
||||
/**
|
||||
* Return true if a given delay has passed since last time marked was called
|
||||
* successfully.
|
||||
*/
|
||||
public boolean markTimeIfDelay(World world, long delay) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
long currentTime = world.getWorldTime();
|
||||
|
||||
if (currentTime < lastMark) {
|
||||
lastMark = currentTime;
|
||||
return false;
|
||||
} else if (lastMark + delay <= currentTime) {
|
||||
lastMark = world.getWorldTime();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void markTime(World world) {
|
||||
lastMark = world.getWorldTime();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package buildcraft.api.filler;
|
||||
|
||||
public class FillerManager {
|
||||
|
||||
public static IFillerRegistry registry;
|
||||
|
||||
}
|
||||
package buildcraft.api.filler;
|
||||
|
||||
public class FillerManager {
|
||||
|
||||
public static IFillerRegistry registry;
|
||||
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IFillerPattern {
|
||||
|
||||
public int getId();
|
||||
|
||||
public void setId(int id);
|
||||
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace);
|
||||
|
||||
public String getTextureFile();
|
||||
|
||||
public int getTextureIndex();
|
||||
|
||||
public String getName();
|
||||
|
||||
}
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IFillerPattern {
|
||||
|
||||
public int getId();
|
||||
|
||||
public void setId(int id);
|
||||
|
||||
public boolean iteratePattern(TileEntity tile, IBox box, ItemStack stackToPlace);
|
||||
|
||||
public String getTextureFile();
|
||||
|
||||
public int getTextureIndex();
|
||||
|
||||
public String getName();
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public interface IFillerRegistry {
|
||||
|
||||
public void addRecipe(IFillerPattern pattern, Object aobj[]);
|
||||
|
||||
public IFillerPattern findMatchingRecipe(IInventory inventorycrafting);
|
||||
|
||||
public int getPatternNumber(IFillerPattern pattern);
|
||||
|
||||
public IFillerPattern getPattern(int n);
|
||||
|
||||
}
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraft.src.IInventory;
|
||||
|
||||
public interface IFillerRegistry {
|
||||
|
||||
public void addRecipe(IFillerPattern pattern, Object aobj[]);
|
||||
|
||||
public IFillerPattern findMatchingRecipe(IInventory inventorycrafting);
|
||||
|
||||
public int getPatternNumber(IFillerPattern pattern);
|
||||
|
||||
public IFillerPattern getPattern(int n);
|
||||
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class IronEngineCoolant {
|
||||
|
||||
public static LinkedList<IronEngineCoolant> coolants = new LinkedList<IronEngineCoolant>();
|
||||
|
||||
public static IronEngineCoolant getCoolantForLiquid(LiquidStack liquid) {
|
||||
if(liquid == null)
|
||||
return null;
|
||||
if(liquid.itemID <= 0)
|
||||
return null;
|
||||
|
||||
for(IronEngineCoolant coolant : coolants)
|
||||
if(coolant.liquid.isLiquidEqual(liquid))
|
||||
return coolant;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack liquid;
|
||||
public final float coolingPerUnit;
|
||||
|
||||
public IronEngineCoolant(LiquidStack liquid, float coolingPerUnit) {
|
||||
this.liquid = liquid;
|
||||
this.coolingPerUnit = coolingPerUnit;
|
||||
}
|
||||
|
||||
}
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class IronEngineCoolant {
|
||||
|
||||
public static LinkedList<IronEngineCoolant> coolants = new LinkedList<IronEngineCoolant>();
|
||||
|
||||
public static IronEngineCoolant getCoolantForLiquid(LiquidStack liquid) {
|
||||
if(liquid == null)
|
||||
return null;
|
||||
if(liquid.itemID <= 0)
|
||||
return null;
|
||||
|
||||
for(IronEngineCoolant coolant : coolants)
|
||||
if(coolant.liquid.isLiquidEqual(liquid))
|
||||
return coolant;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack liquid;
|
||||
public final float coolingPerUnit;
|
||||
|
||||
public IronEngineCoolant(LiquidStack liquid, float coolingPerUnit) {
|
||||
this.liquid = liquid;
|
||||
this.coolingPerUnit = coolingPerUnit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.fuels;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidManager;
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class IronEngineFuel {
|
||||
|
||||
public static LinkedList<IronEngineFuel> fuels = new LinkedList<IronEngineFuel>();
|
||||
|
||||
public static IronEngineFuel getFuelForLiquid(LiquidStack liquid) {
|
||||
if(liquid == null)
|
||||
return null;
|
||||
if(liquid.itemID <= 0)
|
||||
return null;
|
||||
|
||||
for(IronEngineFuel fuel : fuels)
|
||||
if(fuel.liquid.isLiquidEqual(liquid))
|
||||
return fuel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack liquid;
|
||||
public final float powerPerCycle;
|
||||
public final int totalBurningTime;
|
||||
|
||||
public IronEngineFuel(int liquidId, float powerPerCycle, int totalBurningTime) {
|
||||
this(new LiquidStack(liquidId, LiquidManager.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime);
|
||||
}
|
||||
public IronEngineFuel(LiquidStack liquid, float powerPerCycle, int totalBurningTime) {
|
||||
this.liquid = liquid;
|
||||
this.powerPerCycle = powerPerCycle;
|
||||
this.totalBurningTime = totalBurningTime;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.fuels;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidManager;
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class IronEngineFuel {
|
||||
|
||||
public static LinkedList<IronEngineFuel> fuels = new LinkedList<IronEngineFuel>();
|
||||
|
||||
public static IronEngineFuel getFuelForLiquid(LiquidStack liquid) {
|
||||
if(liquid == null)
|
||||
return null;
|
||||
if(liquid.itemID <= 0)
|
||||
return null;
|
||||
|
||||
for(IronEngineFuel fuel : fuels)
|
||||
if(fuel.liquid.isLiquidEqual(liquid))
|
||||
return fuel;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack liquid;
|
||||
public final float powerPerCycle;
|
||||
public final int totalBurningTime;
|
||||
|
||||
public IronEngineFuel(int liquidId, float powerPerCycle, int totalBurningTime) {
|
||||
this(new LiquidStack(liquidId, LiquidManager.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime);
|
||||
}
|
||||
public IronEngineFuel(LiquidStack liquid, float powerPerCycle, int totalBurningTime) {
|
||||
this.liquid = liquid;
|
||||
this.powerPerCycle = powerPerCycle;
|
||||
this.totalBurningTime = totalBurningTime;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
|
||||
public abstract class Action implements IAction {
|
||||
|
||||
protected int id;
|
||||
|
||||
public Action(int id) {
|
||||
this.id = id;
|
||||
ActionManager.actions[id] = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getTexture();
|
||||
|
||||
@Override
|
||||
public int getIndexInTexture() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
|
||||
public abstract class Action implements IAction {
|
||||
|
||||
protected int id;
|
||||
|
||||
public Action(int id) {
|
||||
this.id = id;
|
||||
ActionManager.actions[id] = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getTexture();
|
||||
|
||||
@Override
|
||||
public int getIndexInTexture() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,85 +1,85 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class ActionManager {
|
||||
|
||||
public static Trigger[] triggers = new Trigger[1024];
|
||||
public static Action[] actions = new Action[1024];
|
||||
|
||||
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
|
||||
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
|
||||
|
||||
public static void registerTriggerProvider(ITriggerProvider provider) {
|
||||
if (provider != null && !triggerProviders.contains(provider)) {
|
||||
triggerProviders.add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity entity) {
|
||||
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
|
||||
|
||||
for (ITriggerProvider provider : triggerProviders) {
|
||||
LinkedList<ITrigger> toAdd = provider.getNeighborTriggers(block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (ITrigger t : toAdd) {
|
||||
if (!triggers.contains(t)) {
|
||||
triggers.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return triggers;
|
||||
}
|
||||
|
||||
public static void registerActionProvider(IActionProvider provider) {
|
||||
if (provider != null && !actionProviders.contains(provider)) {
|
||||
actionProviders.add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedList<IAction> getNeighborActions(Block block, TileEntity entity) {
|
||||
LinkedList<IAction> actions = new LinkedList<IAction>();
|
||||
|
||||
for (IActionProvider provider : actionProviders) {
|
||||
LinkedList<IAction> toAdd = provider.getNeighborActions(block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (IAction t : toAdd) {
|
||||
if (!actions.contains(t)) {
|
||||
actions.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static LinkedList<ITrigger> getPipeTriggers(IPipe pipe) {
|
||||
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
|
||||
|
||||
for (ITriggerProvider provider : triggerProviders) {
|
||||
LinkedList<ITrigger> toAdd = provider.getPipeTriggers(pipe);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (ITrigger t : toAdd) {
|
||||
if (!triggers.contains(t)) {
|
||||
triggers.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return triggers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class ActionManager {
|
||||
|
||||
public static Trigger[] triggers = new Trigger[1024];
|
||||
public static Action[] actions = new Action[1024];
|
||||
|
||||
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
|
||||
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
|
||||
|
||||
public static void registerTriggerProvider(ITriggerProvider provider) {
|
||||
if (provider != null && !triggerProviders.contains(provider)) {
|
||||
triggerProviders.add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity entity) {
|
||||
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
|
||||
|
||||
for (ITriggerProvider provider : triggerProviders) {
|
||||
LinkedList<ITrigger> toAdd = provider.getNeighborTriggers(block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (ITrigger t : toAdd) {
|
||||
if (!triggers.contains(t)) {
|
||||
triggers.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return triggers;
|
||||
}
|
||||
|
||||
public static void registerActionProvider(IActionProvider provider) {
|
||||
if (provider != null && !actionProviders.contains(provider)) {
|
||||
actionProviders.add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkedList<IAction> getNeighborActions(Block block, TileEntity entity) {
|
||||
LinkedList<IAction> actions = new LinkedList<IAction>();
|
||||
|
||||
for (IActionProvider provider : actionProviders) {
|
||||
LinkedList<IAction> toAdd = provider.getNeighborActions(block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (IAction t : toAdd) {
|
||||
if (!actions.contains(t)) {
|
||||
actions.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static LinkedList<ITrigger> getPipeTriggers(IPipe pipe) {
|
||||
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
|
||||
|
||||
for (ITriggerProvider provider : triggerProviders) {
|
||||
LinkedList<ITrigger> toAdd = provider.getPipeTriggers(pipe);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (ITrigger t : toAdd) {
|
||||
if (!triggers.contains(t)) {
|
||||
triggers.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return triggers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
public interface IAction {
|
||||
|
||||
int getId();
|
||||
String getTexture();
|
||||
int getIndexInTexture();
|
||||
boolean hasParameter();
|
||||
String getDescription();
|
||||
|
||||
package buildcraft.api.gates;
|
||||
|
||||
public interface IAction {
|
||||
|
||||
int getId();
|
||||
String getTexture();
|
||||
int getIndexInTexture();
|
||||
boolean hasParameter();
|
||||
String getDescription();
|
||||
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IActionProvider {
|
||||
|
||||
/**
|
||||
* Returns the list of actions available to a gate next to the given block.
|
||||
*/
|
||||
public abstract LinkedList<IAction> getNeighborActions(Block block, TileEntity tile);
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IActionProvider {
|
||||
|
||||
/**
|
||||
* Returns the list of actions available to a gate next to the given block.
|
||||
*/
|
||||
public abstract LinkedList<IAction> getNeighborActions(Block block, TileEntity tile);
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2012
|
||||
* 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.gates;
|
||||
|
||||
|
||||
public interface IActionReceptor {
|
||||
|
||||
public void actionActivated(IAction action);
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2012
|
||||
* 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.gates;
|
||||
|
||||
|
||||
public interface IActionReceptor {
|
||||
|
||||
public void actionActivated(IAction action);
|
||||
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
/**
|
||||
* This interface has to be implemented by a TileEntity or a Pipe that wants to
|
||||
* provide triggers different from the ones installed by default with
|
||||
* BuildCraft.
|
||||
*/
|
||||
public interface IOverrideDefaultTriggers {
|
||||
|
||||
LinkedList<ITrigger> getTriggers();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
/**
|
||||
* This interface has to be implemented by a TileEntity or a Pipe that wants to
|
||||
* provide triggers different from the ones installed by default with
|
||||
* BuildCraft.
|
||||
*/
|
||||
public interface IOverrideDefaultTriggers {
|
||||
|
||||
LinkedList<ITrigger> getTriggers();
|
||||
|
||||
}
|
||||
@@ -1,41 +1,41 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface ITrigger {
|
||||
|
||||
public abstract int getId();
|
||||
|
||||
/**
|
||||
* Return the texture file for this trigger icon
|
||||
*/
|
||||
public abstract String getTextureFile();
|
||||
|
||||
/**
|
||||
* Return the icon id in the texture file
|
||||
*/
|
||||
public abstract int getIndexInTexture();
|
||||
|
||||
/**
|
||||
* Return true if this trigger can accept parameters
|
||||
*/
|
||||
public abstract boolean hasParameter();
|
||||
|
||||
/**
|
||||
* Return the trigger description in the UI
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
public abstract boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter);
|
||||
|
||||
/**
|
||||
* Create parameters for the trigger. As for now, there is only one kind of
|
||||
* trigger parameter available so this subprogram is final.
|
||||
*/
|
||||
public abstract ITriggerParameter createParameter();
|
||||
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface ITrigger {
|
||||
|
||||
public abstract int getId();
|
||||
|
||||
/**
|
||||
* Return the texture file for this trigger icon
|
||||
*/
|
||||
public abstract String getTextureFile();
|
||||
|
||||
/**
|
||||
* Return the icon id in the texture file
|
||||
*/
|
||||
public abstract int getIndexInTexture();
|
||||
|
||||
/**
|
||||
* Return true if this trigger can accept parameters
|
||||
*/
|
||||
public abstract boolean hasParameter();
|
||||
|
||||
/**
|
||||
* Return the trigger description in the UI
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
public abstract boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter);
|
||||
|
||||
/**
|
||||
* Create parameters for the trigger. As for now, there is only one kind of
|
||||
* trigger parameter available so this subprogram is final.
|
||||
*/
|
||||
public abstract ITriggerParameter createParameter();
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface ITriggerParameter {
|
||||
|
||||
public abstract ItemStack getItemStack();
|
||||
|
||||
public abstract void set(ItemStack stack);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
public abstract ItemStack getItem();
|
||||
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface ITriggerParameter {
|
||||
|
||||
public abstract ItemStack getItemStack();
|
||||
|
||||
public abstract void set(ItemStack stack);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
public abstract ItemStack getItem();
|
||||
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface ITriggerProvider {
|
||||
|
||||
/**
|
||||
* Returns the list of triggers that are available from the pipe holding the
|
||||
* gate.
|
||||
*/
|
||||
public abstract LinkedList<ITrigger> getPipeTriggers(IPipe pipe);
|
||||
|
||||
/**
|
||||
* Returns the list of triggers available to a gate next to the given block.
|
||||
*/
|
||||
public abstract LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile);
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface ITriggerProvider {
|
||||
|
||||
/**
|
||||
* Returns the list of triggers that are available from the pipe holding the
|
||||
* gate.
|
||||
*/
|
||||
public abstract LinkedList<ITrigger> getPipeTriggers(IPipe pipe);
|
||||
|
||||
/**
|
||||
* Returns the list of triggers available to a gate next to the given block.
|
||||
*/
|
||||
public abstract LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile);
|
||||
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
/**
|
||||
* This class has to be implemented to create new triggers kinds to BuildCraft
|
||||
* gates. There is an instance per kind, which will get called wherever the
|
||||
* trigger can be active.
|
||||
*/
|
||||
public abstract class Trigger implements ITrigger {
|
||||
|
||||
protected int id;
|
||||
|
||||
/**
|
||||
* Creates a new triggers, and stores it in the trigger list
|
||||
*/
|
||||
public Trigger(int id) {
|
||||
this.id = id;
|
||||
ActionManager.triggers[id] = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getId()
|
||||
*/
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getTextureFile()
|
||||
*/
|
||||
@Override
|
||||
public abstract String getTextureFile();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getIndexInTexture()
|
||||
*/
|
||||
@Override
|
||||
public int getIndexInTexture() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#hasParameter()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#isTriggerActive(net.minecraft.src.TileEntity, net.minecraft.src.buildcraft.api.gates.TriggerParameter)
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#createParameter()
|
||||
*/
|
||||
@Override
|
||||
public final ITriggerParameter createParameter() {
|
||||
return new TriggerParameter();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
/**
|
||||
* This class has to be implemented to create new triggers kinds to BuildCraft
|
||||
* gates. There is an instance per kind, which will get called wherever the
|
||||
* trigger can be active.
|
||||
*/
|
||||
public abstract class Trigger implements ITrigger {
|
||||
|
||||
protected int id;
|
||||
|
||||
/**
|
||||
* Creates a new triggers, and stores it in the trigger list
|
||||
*/
|
||||
public Trigger(int id) {
|
||||
this.id = id;
|
||||
ActionManager.triggers[id] = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getId()
|
||||
*/
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getTextureFile()
|
||||
*/
|
||||
@Override
|
||||
public abstract String getTextureFile();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getIndexInTexture()
|
||||
*/
|
||||
@Override
|
||||
public int getIndexInTexture() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#hasParameter()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#isTriggerActive(net.minecraft.src.TileEntity, net.minecraft.src.buildcraft.api.gates.TriggerParameter)
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#createParameter()
|
||||
*/
|
||||
@Override
|
||||
public final ITriggerParameter createParameter() {
|
||||
return new TriggerParameter();
|
||||
}
|
||||
}
|
||||
@@ -1,69 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class TriggerParameter implements ITriggerParameter {
|
||||
|
||||
protected ItemStack stack;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack)
|
||||
*/
|
||||
@Override
|
||||
public void set(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (stack != null) {
|
||||
compound.setInteger("itemID", stack.itemID);
|
||||
compound.setInteger("itemDMG", stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
int itemID = compound.getInteger("itemID");
|
||||
|
||||
if (itemID != 0) {
|
||||
stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG"));
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItem()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.gates;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class TriggerParameter implements ITriggerParameter {
|
||||
|
||||
protected ItemStack stack;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack)
|
||||
*/
|
||||
@Override
|
||||
public void set(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (stack != null) {
|
||||
compound.setInteger("itemID", stack.itemID);
|
||||
compound.setInteger("itemDMG", stack.getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
int itemID = compound.getInteger("itemID");
|
||||
|
||||
if (itemID != 0) {
|
||||
stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG"));
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItem()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface ISecuredInventory {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return true if the user/player with the given name has access permissions on this machine.
|
||||
*/
|
||||
boolean canAccess(String name);
|
||||
|
||||
/**
|
||||
* Informs the inventory with whose permissions the next item or liquid transaction will be performed. It is up to the inventory to determine the effect.
|
||||
* @param orientation Orientation the transaction will be performed from.
|
||||
* @param name Name of the user/player who owns the transaction.
|
||||
*/
|
||||
void prepareTransaction(Orientations orientation, String name);
|
||||
|
||||
}
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface ISecuredInventory {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return true if the user/player with the given name has access permissions on this machine.
|
||||
*/
|
||||
boolean canAccess(String name);
|
||||
|
||||
/**
|
||||
* Informs the inventory with whose permissions the next item or liquid transaction will be performed. It is up to the inventory to determine the effect.
|
||||
* @param orientation Orientation the transaction will be performed from.
|
||||
* @param name Name of the user/player who owns the transaction.
|
||||
*/
|
||||
void prepareTransaction(Orientations orientation, String name);
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface ISelectiveInventory extends ISpecialInventory {
|
||||
/**
|
||||
* Requests specified items to be extracted from the inventory
|
||||
* @param desired Array which can contain ItemStacks, Items, or classes describing the type of item accepted or excluded.
|
||||
* @param exclusion If true desired items are not eligible for returning.
|
||||
* @param doRemove If false no actual extraction may occur.
|
||||
* @param from Orientation the ItemStack is requested from.
|
||||
* @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks)
|
||||
* @return Array of item stacks extracted from the inventory
|
||||
*/
|
||||
ItemStack[] extractItem(Object[] desired, boolean exclusion, boolean doRemove, Orientations from, int maxItemCount);
|
||||
}
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface ISelectiveInventory extends ISpecialInventory {
|
||||
/**
|
||||
* Requests specified items to be extracted from the inventory
|
||||
* @param desired Array which can contain ItemStacks, Items, or classes describing the type of item accepted or excluded.
|
||||
* @param exclusion If true desired items are not eligible for returning.
|
||||
* @param doRemove If false no actual extraction may occur.
|
||||
* @param from Orientation the ItemStack is requested from.
|
||||
* @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks)
|
||||
* @return Array of item stacks extracted from the inventory
|
||||
*/
|
||||
ItemStack[] extractItem(Object[] desired, boolean exclusion, boolean doRemove, Orientations from, int maxItemCount);
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface ISpecialInventory extends IInventory {
|
||||
|
||||
/**
|
||||
* Offers an ItemStack for addition to the inventory.
|
||||
* @param stack ItemStack offered for addition. Do not manipulate this!
|
||||
* @param doAdd If false no actual addition should take place.
|
||||
* @param from Orientation the ItemStack is offered from.
|
||||
* @return Amount of items used from the passed stack.
|
||||
*/
|
||||
int addItem(ItemStack stack, boolean doAdd, Orientations from);
|
||||
/**
|
||||
* Requests items to be extracted from the inventory
|
||||
* @param doRemove If false no actual extraction may occur.
|
||||
* @param from Orientation the ItemStack is requested from.
|
||||
* @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks)
|
||||
* @return Array of item stacks extracted from the inventory
|
||||
*/
|
||||
ItemStack[] extractItem(boolean doRemove, Orientations from, int maxItemCount);
|
||||
|
||||
}
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface ISpecialInventory extends IInventory {
|
||||
|
||||
/**
|
||||
* Offers an ItemStack for addition to the inventory.
|
||||
* @param stack ItemStack offered for addition. Do not manipulate this!
|
||||
* @param doAdd If false no actual addition should take place.
|
||||
* @param from Orientation the ItemStack is offered from.
|
||||
* @return Amount of items used from the passed stack.
|
||||
*/
|
||||
int addItem(ItemStack stack, boolean doAdd, Orientations from);
|
||||
/**
|
||||
* Requests items to be extracted from the inventory
|
||||
* @param doRemove If false no actual extraction may occur.
|
||||
* @param from Orientation the ItemStack is requested from.
|
||||
* @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks)
|
||||
* @return Array of item stacks extracted from the inventory
|
||||
*/
|
||||
ItemStack[] extractItem(boolean doRemove, Orientations from, int maxItemCount);
|
||||
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.liquids;
|
||||
|
||||
public interface ILiquid {
|
||||
|
||||
public int stillLiquidId();
|
||||
|
||||
public boolean isMetaSensitive();
|
||||
|
||||
public int stillLiquidMeta();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.liquids;
|
||||
|
||||
public interface ILiquid {
|
||||
|
||||
public int stillLiquidId();
|
||||
|
||||
public boolean isMetaSensitive();
|
||||
|
||||
public int stillLiquidMeta();
|
||||
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
public interface ILiquidTank {
|
||||
|
||||
/**
|
||||
* @return LiquidStack representing the liquid contained in the tank, null if empty.
|
||||
*/
|
||||
LiquidStack getLiquid();
|
||||
void setLiquid(LiquidStack liquid);
|
||||
void setCapacity(int capacity);
|
||||
int getCapacity();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resource
|
||||
* @param doFill
|
||||
* @return Amount of liquid used for filling.
|
||||
*/
|
||||
int fill(LiquidStack resource, boolean doFill);
|
||||
/**
|
||||
*
|
||||
* @param maxDrain
|
||||
* @param doDrain
|
||||
* @return Null if nothing was drained, otherwise a LiquidStack containing the drained.
|
||||
*/
|
||||
LiquidStack drain(int maxDrain, boolean doDrain);
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
public interface ILiquidTank {
|
||||
|
||||
/**
|
||||
* @return LiquidStack representing the liquid contained in the tank, null if empty.
|
||||
*/
|
||||
LiquidStack getLiquid();
|
||||
void setLiquid(LiquidStack liquid);
|
||||
void setCapacity(int capacity);
|
||||
int getCapacity();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resource
|
||||
* @param doFill
|
||||
* @return Amount of liquid used for filling.
|
||||
*/
|
||||
int fill(LiquidStack resource, boolean doFill);
|
||||
/**
|
||||
*
|
||||
* @param maxDrain
|
||||
* @param doDrain
|
||||
* @return Null if nothing was drained, otherwise a LiquidStack containing the drained.
|
||||
*/
|
||||
LiquidStack drain(int maxDrain, boolean doDrain);
|
||||
}
|
||||
@@ -1,46 +1,46 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface ITankContainer {
|
||||
|
||||
/**
|
||||
* Fills liquid into internal tanks, distribution is left to the ITankContainer.
|
||||
* @param from Orientation the liquid is pumped in from.
|
||||
* @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer
|
||||
* @param doFill If false filling will only be simulated.
|
||||
* @return Amount of resource that was filled into internal tanks.
|
||||
*/
|
||||
int fill(Orientations from, LiquidStack resource, boolean doFill);
|
||||
/**
|
||||
* Fills liquid into the specified internal tank.
|
||||
* @param from Orientation the liquid is pumped in from.
|
||||
* @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer
|
||||
* @param doFill If false filling will only be simulated.
|
||||
* @return Amount of resource that was filled into internal tanks.
|
||||
*/
|
||||
int fill(int tankIndex, LiquidStack resource, boolean doFill);
|
||||
|
||||
/**
|
||||
* Drains liquid out of internal tanks, distribution is left to the ITankContainer.
|
||||
* @param from Orientation the liquid is drained to.
|
||||
* @param maxDrain Maximum amount of liquid to drain.
|
||||
* @param doDrain If false draining will only be simulated.
|
||||
* @return LiquidStack representing the liquid and amount actually drained from the ITankContainer
|
||||
*/
|
||||
LiquidStack drain(Orientations from, int maxDrain, boolean doDrain);
|
||||
/**
|
||||
* Drains liquid out of the specified internal tank.
|
||||
* @param from Orientation the liquid is drained to.
|
||||
* @param maxDrain Maximum amount of liquid to drain.
|
||||
* @param doDrain If false draining will only be simulated.
|
||||
* @return LiquidStack representing the liquid and amount actually drained from the ITankContainer
|
||||
*/
|
||||
LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain);
|
||||
|
||||
/**
|
||||
* @return Array of {@link LiquidTank}s contained in this ITankContainer
|
||||
*/
|
||||
ILiquidTank[] getTanks();
|
||||
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface ITankContainer {
|
||||
|
||||
/**
|
||||
* Fills liquid into internal tanks, distribution is left to the ITankContainer.
|
||||
* @param from Orientation the liquid is pumped in from.
|
||||
* @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer
|
||||
* @param doFill If false filling will only be simulated.
|
||||
* @return Amount of resource that was filled into internal tanks.
|
||||
*/
|
||||
int fill(Orientations from, LiquidStack resource, boolean doFill);
|
||||
/**
|
||||
* Fills liquid into the specified internal tank.
|
||||
* @param from Orientation the liquid is pumped in from.
|
||||
* @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer
|
||||
* @param doFill If false filling will only be simulated.
|
||||
* @return Amount of resource that was filled into internal tanks.
|
||||
*/
|
||||
int fill(int tankIndex, LiquidStack resource, boolean doFill);
|
||||
|
||||
/**
|
||||
* Drains liquid out of internal tanks, distribution is left to the ITankContainer.
|
||||
* @param from Orientation the liquid is drained to.
|
||||
* @param maxDrain Maximum amount of liquid to drain.
|
||||
* @param doDrain If false draining will only be simulated.
|
||||
* @return LiquidStack representing the liquid and amount actually drained from the ITankContainer
|
||||
*/
|
||||
LiquidStack drain(Orientations from, int maxDrain, boolean doDrain);
|
||||
/**
|
||||
* Drains liquid out of the specified internal tank.
|
||||
* @param from Orientation the liquid is drained to.
|
||||
* @param maxDrain Maximum amount of liquid to drain.
|
||||
* @param doDrain If false draining will only be simulated.
|
||||
* @return LiquidStack representing the liquid and amount actually drained from the ITankContainer
|
||||
*/
|
||||
LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain);
|
||||
|
||||
/**
|
||||
* @return Array of {@link LiquidTank}s contained in this ITankContainer
|
||||
*/
|
||||
ILiquidTank[] getTanks();
|
||||
|
||||
}
|
||||
@@ -1,45 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.liquids;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class LiquidData {
|
||||
|
||||
public final LiquidStack stillLiquid;
|
||||
public final LiquidStack movingLiquid;
|
||||
|
||||
public final ItemStack filled;
|
||||
public final ItemStack container;
|
||||
|
||||
public LiquidData(int stillLiquidId, int movingLiquidId, Item filled) {
|
||||
this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), new ItemStack(filled, 1), new ItemStack(Item.bucketEmpty));
|
||||
}
|
||||
|
||||
public LiquidData(int stillLiquidId, int movingLiquidId, ItemStack filled) {
|
||||
this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty));
|
||||
}
|
||||
|
||||
public LiquidData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) {
|
||||
this(stillLiquid, stillLiquid, filled, container);
|
||||
}
|
||||
|
||||
public LiquidData(LiquidStack stillLiquid, LiquidStack movingLiquid, ItemStack filled, ItemStack container) {
|
||||
this.stillLiquid = stillLiquid;
|
||||
this.movingLiquid = movingLiquid;
|
||||
this.filled = filled;
|
||||
this.container = container;
|
||||
|
||||
if(stillLiquid == null || filled == null || container == null)
|
||||
throw new RuntimeException("stillLiquid, filled, or container is null, this is an error");
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.liquids;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class LiquidData {
|
||||
|
||||
public final LiquidStack stillLiquid;
|
||||
public final LiquidStack movingLiquid;
|
||||
|
||||
public final ItemStack filled;
|
||||
public final ItemStack container;
|
||||
|
||||
public LiquidData(int stillLiquidId, int movingLiquidId, Item filled) {
|
||||
this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), new ItemStack(filled, 1), new ItemStack(Item.bucketEmpty));
|
||||
}
|
||||
|
||||
public LiquidData(int stillLiquidId, int movingLiquidId, ItemStack filled) {
|
||||
this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty));
|
||||
}
|
||||
|
||||
public LiquidData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) {
|
||||
this(stillLiquid, stillLiquid, filled, container);
|
||||
}
|
||||
|
||||
public LiquidData(LiquidStack stillLiquid, LiquidStack movingLiquid, ItemStack filled, ItemStack container) {
|
||||
this.stillLiquid = stillLiquid;
|
||||
this.movingLiquid = movingLiquid;
|
||||
this.filled = filled;
|
||||
this.container = container;
|
||||
|
||||
if(stillLiquid == null || filled == null || container == null)
|
||||
throw new RuntimeException("stillLiquid, filled, or container is null, this is an error");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +1,57 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When creating liquids you should register them with this class.
|
||||
*
|
||||
* @author CovertJaguar <railcraft.wikispaces.com>
|
||||
*/
|
||||
public abstract class LiquidDictionary
|
||||
{
|
||||
|
||||
private static Map<String, LiquidStack> liquids = new HashMap<String, LiquidStack>();
|
||||
|
||||
/**
|
||||
* When creating liquids you should call this function.
|
||||
*
|
||||
* Upon passing it a name and liquid item it will return either
|
||||
* a preexisting implementation of that liquid or the liquid passed in.
|
||||
*
|
||||
*
|
||||
* @param name the name of the liquid
|
||||
* @param liquid the liquid to use if one doesn't exist
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack getOrCreateLiquid(String name, LiquidStack liquid)
|
||||
{
|
||||
LiquidStack existing = liquids.get(name);
|
||||
if(existing != null) {
|
||||
return existing.copy();
|
||||
}
|
||||
liquids.put(name, liquid.copy());
|
||||
return liquid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the liquid matching the name,
|
||||
* if such a liquid exists.
|
||||
*
|
||||
* Can return null.
|
||||
*
|
||||
* @param name the name of the liquid
|
||||
* @param amount the amout of liquid
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack getLiquid(String name, int amount)
|
||||
{
|
||||
LiquidStack liquid = liquids.get(name);
|
||||
if(liquid == null)
|
||||
return null;
|
||||
|
||||
liquid = liquid.copy();
|
||||
liquid.amount = amount;
|
||||
return liquid;
|
||||
}
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When creating liquids you should register them with this class.
|
||||
*
|
||||
* @author CovertJaguar <railcraft.wikispaces.com>
|
||||
*/
|
||||
public abstract class LiquidDictionary
|
||||
{
|
||||
|
||||
private static Map<String, LiquidStack> liquids = new HashMap<String, LiquidStack>();
|
||||
|
||||
/**
|
||||
* When creating liquids you should call this function.
|
||||
*
|
||||
* Upon passing it a name and liquid item it will return either
|
||||
* a preexisting implementation of that liquid or the liquid passed in.
|
||||
*
|
||||
*
|
||||
* @param name the name of the liquid
|
||||
* @param liquid the liquid to use if one doesn't exist
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack getOrCreateLiquid(String name, LiquidStack liquid)
|
||||
{
|
||||
LiquidStack existing = liquids.get(name);
|
||||
if(existing != null) {
|
||||
return existing.copy();
|
||||
}
|
||||
liquids.put(name, liquid.copy());
|
||||
return liquid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the liquid matching the name,
|
||||
* if such a liquid exists.
|
||||
*
|
||||
* Can return null.
|
||||
*
|
||||
* @param name the name of the liquid
|
||||
* @param amount the amout of liquid
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack getLiquid(String name, int amount)
|
||||
{
|
||||
LiquidStack liquid = liquids.get(name);
|
||||
if(liquid == null)
|
||||
return null;
|
||||
|
||||
liquid = liquid.copy();
|
||||
liquid.amount = amount;
|
||||
return liquid;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,64 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class LiquidManager {
|
||||
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
|
||||
|
||||
public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) {
|
||||
if (filledItem == null)
|
||||
return null;
|
||||
|
||||
for (LiquidData liquid : liquids)
|
||||
if (liquid.filled.isItemEqual(filledItem))
|
||||
return liquid.stillLiquid;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getLiquidIDForFilledItem(ItemStack filledItem) {
|
||||
LiquidStack liquidForFilledItem = getLiquidForFilledItem(filledItem);
|
||||
|
||||
if (liquidForFilledItem == null)
|
||||
return 0;
|
||||
|
||||
return liquidForFilledItem.itemID;
|
||||
}
|
||||
|
||||
public static ItemStack getFilledItemForLiquid(LiquidStack liquid) {
|
||||
for (LiquidData data : liquids)
|
||||
if(data.stillLiquid.isLiquidEqual(liquid))
|
||||
return data.filled.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) {
|
||||
return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer);
|
||||
}
|
||||
|
||||
public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) {
|
||||
for(LiquidData data : liquids)
|
||||
if(liquid.containsLiquid(data.stillLiquid)
|
||||
&& data.container.isItemEqual(emptyContainer))
|
||||
return data.filled.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isLiquid(ItemStack block) {
|
||||
if (block.itemID == 0)
|
||||
return false;
|
||||
|
||||
for (LiquidData liquid : liquids)
|
||||
if (liquid.stillLiquid.isLiquidEqual(block) || liquid.movingLiquid.isLiquidEqual(block))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class LiquidManager {
|
||||
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
|
||||
|
||||
public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) {
|
||||
if (filledItem == null)
|
||||
return null;
|
||||
|
||||
for (LiquidData liquid : liquids)
|
||||
if (liquid.filled.isItemEqual(filledItem))
|
||||
return liquid.stillLiquid;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getLiquidIDForFilledItem(ItemStack filledItem) {
|
||||
LiquidStack liquidForFilledItem = getLiquidForFilledItem(filledItem);
|
||||
|
||||
if (liquidForFilledItem == null)
|
||||
return 0;
|
||||
|
||||
return liquidForFilledItem.itemID;
|
||||
}
|
||||
|
||||
public static ItemStack getFilledItemForLiquid(LiquidStack liquid) {
|
||||
for (LiquidData data : liquids)
|
||||
if(data.stillLiquid.isLiquidEqual(liquid))
|
||||
return data.filled.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) {
|
||||
return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer);
|
||||
}
|
||||
|
||||
public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) {
|
||||
for(LiquidData data : liquids)
|
||||
if(liquid.containsLiquid(data.stillLiquid)
|
||||
&& data.container.isItemEqual(emptyContainer))
|
||||
return data.filled.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isLiquid(ItemStack block) {
|
||||
if (block.itemID == 0)
|
||||
return false;
|
||||
|
||||
for (LiquidData liquid : liquids)
|
||||
if (liquid.stillLiquid.isLiquidEqual(block) || liquid.movingLiquid.isLiquidEqual(block))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,109 +1,109 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* ItemStack substitute for liquids
|
||||
* @author SirSengir
|
||||
*/
|
||||
public class LiquidStack {
|
||||
public int itemID;
|
||||
public int amount;
|
||||
public int itemMeta;
|
||||
|
||||
private LiquidStack() {
|
||||
}
|
||||
|
||||
public LiquidStack(int itemID, int amount) {
|
||||
this(itemID, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(Item item, int amount) {
|
||||
this(item.shiftedIndex, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(Block block, int amount) {
|
||||
this(block.blockID, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(int itemID, int amount, int itemDamage) {
|
||||
this.itemID = itemID;
|
||||
this.amount = amount;
|
||||
this.itemMeta = itemDamage;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setShort("Id", (short) itemID);
|
||||
nbttagcompound.setInteger("Amount", amount);
|
||||
nbttagcompound.setShort("Meta", (short) itemMeta);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
itemID = nbttagcompound.getShort("Id");
|
||||
amount = nbttagcompound.getInteger("Amount");
|
||||
itemMeta = nbttagcompound.getShort("Meta");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A copy of this LiquidStack
|
||||
*/
|
||||
public LiquidStack copy() {
|
||||
return new LiquidStack(itemID, amount, itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* @return true if this LiquidStack contains the same liquid as the one passed in.
|
||||
*/
|
||||
public boolean isLiquidEqual(LiquidStack other) {
|
||||
if(other == null)
|
||||
return false;
|
||||
|
||||
return itemID == other.itemID && itemMeta == other.itemMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* @return true if this LiquidStack contains the other liquid (liquids are equal and amount >= other.amount).
|
||||
*/
|
||||
public boolean containsLiquid(LiquidStack other) {
|
||||
if(!isLiquidEqual(other))
|
||||
return false;
|
||||
|
||||
return amount >= other.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other ItemStack containing liquids.
|
||||
* @return true if this LiquidStack contains the same liquid as the one passed in.
|
||||
*/
|
||||
public boolean isLiquidEqual(ItemStack other) {
|
||||
if(other == null)
|
||||
return false;
|
||||
|
||||
return itemID == other.itemID && itemMeta == other.getItemDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ItemStack representation of this LiquidStack
|
||||
*/
|
||||
public ItemStack asItemStack() {
|
||||
return new ItemStack(itemID, 1, itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a liquid stack from the passed nbttagcompound and returns it.
|
||||
*
|
||||
* @param nbttagcompound
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack loadLiquidStackFromNBT(NBTTagCompound nbttagcompound) {
|
||||
LiquidStack liquidstack = new LiquidStack();
|
||||
liquidstack.readFromNBT(nbttagcompound);
|
||||
return liquidstack.itemID == 0 ? null : liquidstack;
|
||||
}
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* ItemStack substitute for liquids
|
||||
* @author SirSengir
|
||||
*/
|
||||
public class LiquidStack {
|
||||
public int itemID;
|
||||
public int amount;
|
||||
public int itemMeta;
|
||||
|
||||
private LiquidStack() {
|
||||
}
|
||||
|
||||
public LiquidStack(int itemID, int amount) {
|
||||
this(itemID, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(Item item, int amount) {
|
||||
this(item.shiftedIndex, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(Block block, int amount) {
|
||||
this(block.blockID, amount, 0);
|
||||
}
|
||||
|
||||
public LiquidStack(int itemID, int amount, int itemDamage) {
|
||||
this.itemID = itemID;
|
||||
this.amount = amount;
|
||||
this.itemMeta = itemDamage;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setShort("Id", (short) itemID);
|
||||
nbttagcompound.setInteger("Amount", amount);
|
||||
nbttagcompound.setShort("Meta", (short) itemMeta);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
itemID = nbttagcompound.getShort("Id");
|
||||
amount = nbttagcompound.getInteger("Amount");
|
||||
itemMeta = nbttagcompound.getShort("Meta");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A copy of this LiquidStack
|
||||
*/
|
||||
public LiquidStack copy() {
|
||||
return new LiquidStack(itemID, amount, itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* @return true if this LiquidStack contains the same liquid as the one passed in.
|
||||
*/
|
||||
public boolean isLiquidEqual(LiquidStack other) {
|
||||
if(other == null)
|
||||
return false;
|
||||
|
||||
return itemID == other.itemID && itemMeta == other.itemMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* @return true if this LiquidStack contains the other liquid (liquids are equal and amount >= other.amount).
|
||||
*/
|
||||
public boolean containsLiquid(LiquidStack other) {
|
||||
if(!isLiquidEqual(other))
|
||||
return false;
|
||||
|
||||
return amount >= other.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other ItemStack containing liquids.
|
||||
* @return true if this LiquidStack contains the same liquid as the one passed in.
|
||||
*/
|
||||
public boolean isLiquidEqual(ItemStack other) {
|
||||
if(other == null)
|
||||
return false;
|
||||
|
||||
return itemID == other.itemID && itemMeta == other.getItemDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ItemStack representation of this LiquidStack
|
||||
*/
|
||||
public ItemStack asItemStack() {
|
||||
return new ItemStack(itemID, 1, itemMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a liquid stack from the passed nbttagcompound and returns it.
|
||||
*
|
||||
* @param nbttagcompound
|
||||
* @return
|
||||
*/
|
||||
public static LiquidStack loadLiquidStackFromNBT(NBTTagCompound nbttagcompound) {
|
||||
LiquidStack liquidstack = new LiquidStack();
|
||||
liquidstack.readFromNBT(nbttagcompound);
|
||||
return liquidstack.itemID == 0 ? null : liquidstack;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +1,100 @@
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
/**
|
||||
* Reference implementation of ILiquidTank. Use this or implement your own.
|
||||
*/
|
||||
public class LiquidTank implements ILiquidTank {
|
||||
private LiquidStack liquid;
|
||||
private int capacity;
|
||||
|
||||
public LiquidTank(int capacity) {
|
||||
this(null, capacity);
|
||||
}
|
||||
|
||||
public LiquidTank(int liquidId, int quantity, int capacity) {
|
||||
this(new LiquidStack(liquidId, quantity), capacity);
|
||||
}
|
||||
public LiquidTank(LiquidStack liquid, int capacity) {
|
||||
this.liquid = liquid;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack getLiquid() {
|
||||
return this.liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLiquid(LiquidStack liquid) {
|
||||
this.liquid = liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacity(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(LiquidStack resource, boolean doFill) {
|
||||
if(resource == null || resource.itemID <= 0)
|
||||
return 0;
|
||||
|
||||
if(liquid == null || liquid.itemID <= 0) {
|
||||
if(resource.amount <= capacity) {
|
||||
if(doFill)
|
||||
this.liquid = resource.copy();
|
||||
return resource.amount;
|
||||
} else {
|
||||
if(doFill) {
|
||||
this.liquid = resource.copy();
|
||||
this.liquid.amount = capacity;
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
|
||||
if(!liquid.isLiquidEqual(resource))
|
||||
return 0;
|
||||
|
||||
int space = capacity - liquid.amount;
|
||||
if(resource.amount <= space) {
|
||||
if(doFill)
|
||||
this.liquid.amount += resource.amount;
|
||||
return resource.amount;
|
||||
} else {
|
||||
|
||||
if(doFill)
|
||||
this.liquid.amount = capacity;
|
||||
return space;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public LiquidStack drain(int maxDrain, boolean doDrain) {
|
||||
if(liquid == null || liquid.itemID <= 0)
|
||||
return null;
|
||||
if(liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if(liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if(doDrain) {
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
LiquidStack drained = new LiquidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
|
||||
// Reset liquid if emptied
|
||||
if(liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
return drained;
|
||||
}
|
||||
}
|
||||
package buildcraft.api.liquids;
|
||||
|
||||
/**
|
||||
* Reference implementation of ILiquidTank. Use this or implement your own.
|
||||
*/
|
||||
public class LiquidTank implements ILiquidTank {
|
||||
private LiquidStack liquid;
|
||||
private int capacity;
|
||||
|
||||
public LiquidTank(int capacity) {
|
||||
this(null, capacity);
|
||||
}
|
||||
|
||||
public LiquidTank(int liquidId, int quantity, int capacity) {
|
||||
this(new LiquidStack(liquidId, quantity), capacity);
|
||||
}
|
||||
public LiquidTank(LiquidStack liquid, int capacity) {
|
||||
this.liquid = liquid;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack getLiquid() {
|
||||
return this.liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLiquid(LiquidStack liquid) {
|
||||
this.liquid = liquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacity(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(LiquidStack resource, boolean doFill) {
|
||||
if(resource == null || resource.itemID <= 0)
|
||||
return 0;
|
||||
|
||||
if(liquid == null || liquid.itemID <= 0) {
|
||||
if(resource.amount <= capacity) {
|
||||
if(doFill)
|
||||
this.liquid = resource.copy();
|
||||
return resource.amount;
|
||||
} else {
|
||||
if(doFill) {
|
||||
this.liquid = resource.copy();
|
||||
this.liquid.amount = capacity;
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
|
||||
if(!liquid.isLiquidEqual(resource))
|
||||
return 0;
|
||||
|
||||
int space = capacity - liquid.amount;
|
||||
if(resource.amount <= space) {
|
||||
if(doFill)
|
||||
this.liquid.amount += resource.amount;
|
||||
return resource.amount;
|
||||
} else {
|
||||
|
||||
if(doFill)
|
||||
this.liquid.amount = capacity;
|
||||
return space;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public LiquidStack drain(int maxDrain, boolean doDrain) {
|
||||
if(liquid == null || liquid.itemID <= 0)
|
||||
return null;
|
||||
if(liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if(liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if(doDrain) {
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
LiquidStack drained = new LiquidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
|
||||
// Reset liquid if emptied
|
||||
if(liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
return drained;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,41 @@
|
||||
package buildcraft.api.power;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface IPowerProvider {
|
||||
|
||||
int getLatency();
|
||||
|
||||
int getMinEnergyReceived();
|
||||
|
||||
int getMaxEnergyReceived();
|
||||
|
||||
int getMaxEnergyStored();
|
||||
|
||||
int getActivationEnergy();
|
||||
|
||||
float getEnergyStored();
|
||||
|
||||
void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy);
|
||||
|
||||
void configurePowerPerdition(int powerLoss, int powerLossRegularity);
|
||||
|
||||
boolean update(IPowerReceptor receptor);
|
||||
|
||||
boolean preConditions(IPowerReceptor receptor);
|
||||
|
||||
float useEnergy(float min, float max, boolean doUse);
|
||||
|
||||
void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
void receiveEnergy(float quantity, Orientations from);
|
||||
|
||||
boolean isPowerSource(Orientations from);
|
||||
|
||||
SafeTimeTracker getTimeTracker();
|
||||
|
||||
}
|
||||
package buildcraft.api.power;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface IPowerProvider {
|
||||
|
||||
int getLatency();
|
||||
|
||||
int getMinEnergyReceived();
|
||||
|
||||
int getMaxEnergyReceived();
|
||||
|
||||
int getMaxEnergyStored();
|
||||
|
||||
int getActivationEnergy();
|
||||
|
||||
float getEnergyStored();
|
||||
|
||||
void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy);
|
||||
|
||||
void configurePowerPerdition(int powerLoss, int powerLossRegularity);
|
||||
|
||||
boolean update(IPowerReceptor receptor);
|
||||
|
||||
boolean preConditions(IPowerReceptor receptor);
|
||||
|
||||
float useEnergy(float min, float max, boolean doUse);
|
||||
|
||||
void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
void receiveEnergy(float quantity, Orientations from);
|
||||
|
||||
boolean isPowerSource(Orientations from);
|
||||
|
||||
SafeTimeTracker getTimeTracker();
|
||||
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
|
||||
public interface IPowerReceptor {
|
||||
|
||||
public void setPowerProvider(IPowerProvider provider);
|
||||
|
||||
public IPowerProvider getPowerProvider();
|
||||
|
||||
public void doWork();
|
||||
|
||||
public int powerRequest();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
|
||||
public interface IPowerReceptor {
|
||||
|
||||
public void setPowerProvider(IPowerProvider provider);
|
||||
|
||||
public IPowerProvider getPowerProvider();
|
||||
|
||||
public void doWork();
|
||||
|
||||
public int powerRequest();
|
||||
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public abstract class PowerFramework {
|
||||
|
||||
static private String baseNBTName = "net.minecraft.src.buildcarft.Power";
|
||||
|
||||
public static PowerFramework currentFramework;
|
||||
|
||||
public abstract IPowerProvider createPowerProvider();
|
||||
|
||||
public void loadPowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
|
||||
|
||||
IPowerProvider provider = createPowerProvider();
|
||||
|
||||
if (compound.hasKey(baseNBTName)) {
|
||||
NBTTagCompound cpt = compound.getCompoundTag(baseNBTName);
|
||||
if (cpt.getString("class").equals(this.getClass().getName())) {
|
||||
provider.readFromNBT(cpt.getCompoundTag("contents"));
|
||||
}
|
||||
}
|
||||
|
||||
receptor.setPowerProvider(provider);
|
||||
}
|
||||
|
||||
public void savePowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
|
||||
|
||||
IPowerProvider provider = receptor.getPowerProvider();
|
||||
|
||||
if (provider == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
cpt.setString("class", this.getClass().getName());
|
||||
|
||||
NBTTagCompound contents = new NBTTagCompound();
|
||||
|
||||
provider.writeToNBT(contents);
|
||||
|
||||
cpt.setTag("contents", contents);
|
||||
compound.setTag(baseNBTName, cpt);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public abstract class PowerFramework {
|
||||
|
||||
static private String baseNBTName = "net.minecraft.src.buildcarft.Power";
|
||||
|
||||
public static PowerFramework currentFramework;
|
||||
|
||||
public abstract IPowerProvider createPowerProvider();
|
||||
|
||||
public void loadPowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
|
||||
|
||||
IPowerProvider provider = createPowerProvider();
|
||||
|
||||
if (compound.hasKey(baseNBTName)) {
|
||||
NBTTagCompound cpt = compound.getCompoundTag(baseNBTName);
|
||||
if (cpt.getString("class").equals(this.getClass().getName())) {
|
||||
provider.readFromNBT(cpt.getCompoundTag("contents"));
|
||||
}
|
||||
}
|
||||
|
||||
receptor.setPowerProvider(provider);
|
||||
}
|
||||
|
||||
public void savePowerProvider(IPowerReceptor receptor, NBTTagCompound compound) {
|
||||
|
||||
IPowerProvider provider = receptor.getPowerProvider();
|
||||
|
||||
if (provider == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
cpt.setString("class", this.getClass().getName());
|
||||
|
||||
NBTTagCompound contents = new NBTTagCompound();
|
||||
|
||||
provider.writeToNBT(contents);
|
||||
|
||||
cpt.setTag("contents", contents);
|
||||
compound.setTag(baseNBTName, cpt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,162 +1,162 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public abstract class PowerProvider implements IPowerProvider {
|
||||
|
||||
protected int latency;
|
||||
protected int minEnergyReceived;
|
||||
protected int maxEnergyReceived;
|
||||
protected int maxEnergyStored;
|
||||
protected int minActivationEnergy;
|
||||
protected float energyStored = 0;
|
||||
|
||||
protected int powerLoss = 1;
|
||||
protected int powerLossRegularity = 100;
|
||||
|
||||
public SafeTimeTracker timeTracker = new SafeTimeTracker();
|
||||
public SafeTimeTracker energyLossTracker = new SafeTimeTracker();
|
||||
|
||||
public int[] powerSources = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
@Override public SafeTimeTracker getTimeTracker() { return this.timeTracker; }
|
||||
|
||||
@Override public int getLatency() { return this.latency; }
|
||||
@Override public int getMinEnergyReceived() { return this.minEnergyReceived; }
|
||||
@Override public int getMaxEnergyReceived() { return this.maxEnergyReceived; }
|
||||
@Override public int getMaxEnergyStored() { return this.maxEnergyStored; }
|
||||
@Override public int getActivationEnergy() { return this.minActivationEnergy; }
|
||||
@Override public float getEnergyStored() { return this.energyStored; }
|
||||
|
||||
@Override
|
||||
public void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy) {
|
||||
this.latency = latency;
|
||||
this.minEnergyReceived = minEnergyReceived;
|
||||
this.maxEnergyReceived = maxEnergyReceived;
|
||||
this.maxEnergyStored = maxStoredEnergy;
|
||||
this.minActivationEnergy = minActivationEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
|
||||
this.powerLoss = powerLoss;
|
||||
this.powerLossRegularity = powerLossRegularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(IPowerReceptor receptor) {
|
||||
if (!preConditions(receptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = (TileEntity) receptor;
|
||||
boolean result = false;
|
||||
|
||||
if (energyStored >= minActivationEnergy) {
|
||||
if (latency == 0) {
|
||||
receptor.doWork();
|
||||
result = true;
|
||||
} else {
|
||||
if (timeTracker.markTimeIfDelay(tile.worldObj, latency)) {
|
||||
receptor.doWork();
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (powerLoss > 0 && energyLossTracker.markTimeIfDelay(tile.worldObj, powerLossRegularity)) {
|
||||
|
||||
energyStored -= powerLoss;
|
||||
if (energyStored < 0) {
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (powerSources[i] > 0) {
|
||||
powerSources[i]--;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preConditions(IPowerReceptor receptor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float useEnergy(float min, float max, boolean doUse) {
|
||||
float result = 0;
|
||||
|
||||
if (energyStored >= min) {
|
||||
if (energyStored <= max) {
|
||||
result = energyStored;
|
||||
if (doUse) {
|
||||
energyStored = 0;
|
||||
}
|
||||
} else {
|
||||
result = max;
|
||||
if (doUse) {
|
||||
energyStored -= max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
latency = nbttagcompound.getInteger("latency");
|
||||
minEnergyReceived = nbttagcompound.getInteger("minEnergyReceived");
|
||||
maxEnergyReceived = nbttagcompound.getInteger("maxEnergyReceived");
|
||||
maxEnergyStored = nbttagcompound.getInteger("maxStoreEnergy");
|
||||
minActivationEnergy = nbttagcompound.getInteger("minActivationEnergy");
|
||||
|
||||
try {
|
||||
energyStored = nbttagcompound.getFloat("storedEnergy");
|
||||
} catch (Throwable c) {
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("latency", latency);
|
||||
nbttagcompound.setInteger("minEnergyReceived", minEnergyReceived);
|
||||
nbttagcompound.setInteger("maxEnergyReceived", maxEnergyReceived);
|
||||
nbttagcompound.setInteger("maxStoreEnergy", maxEnergyStored);
|
||||
nbttagcompound.setInteger("minActivationEnergy", minActivationEnergy);
|
||||
nbttagcompound.setFloat("storedEnergy", energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveEnergy(float quantity, Orientations from) {
|
||||
powerSources[from.ordinal()] = 2;
|
||||
|
||||
energyStored += quantity;
|
||||
|
||||
if (energyStored > maxEnergyStored) {
|
||||
energyStored = maxEnergyStored;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSource(Orientations from) {
|
||||
return powerSources[from.ordinal()] != 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.power;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public abstract class PowerProvider implements IPowerProvider {
|
||||
|
||||
protected int latency;
|
||||
protected int minEnergyReceived;
|
||||
protected int maxEnergyReceived;
|
||||
protected int maxEnergyStored;
|
||||
protected int minActivationEnergy;
|
||||
protected float energyStored = 0;
|
||||
|
||||
protected int powerLoss = 1;
|
||||
protected int powerLossRegularity = 100;
|
||||
|
||||
public SafeTimeTracker timeTracker = new SafeTimeTracker();
|
||||
public SafeTimeTracker energyLossTracker = new SafeTimeTracker();
|
||||
|
||||
public int[] powerSources = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
@Override public SafeTimeTracker getTimeTracker() { return this.timeTracker; }
|
||||
|
||||
@Override public int getLatency() { return this.latency; }
|
||||
@Override public int getMinEnergyReceived() { return this.minEnergyReceived; }
|
||||
@Override public int getMaxEnergyReceived() { return this.maxEnergyReceived; }
|
||||
@Override public int getMaxEnergyStored() { return this.maxEnergyStored; }
|
||||
@Override public int getActivationEnergy() { return this.minActivationEnergy; }
|
||||
@Override public float getEnergyStored() { return this.energyStored; }
|
||||
|
||||
@Override
|
||||
public void configure(int latency, int minEnergyReceived, int maxEnergyReceived, int minActivationEnergy, int maxStoredEnergy) {
|
||||
this.latency = latency;
|
||||
this.minEnergyReceived = minEnergyReceived;
|
||||
this.maxEnergyReceived = maxEnergyReceived;
|
||||
this.maxEnergyStored = maxStoredEnergy;
|
||||
this.minActivationEnergy = minActivationEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
|
||||
this.powerLoss = powerLoss;
|
||||
this.powerLossRegularity = powerLossRegularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(IPowerReceptor receptor) {
|
||||
if (!preConditions(receptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = (TileEntity) receptor;
|
||||
boolean result = false;
|
||||
|
||||
if (energyStored >= minActivationEnergy) {
|
||||
if (latency == 0) {
|
||||
receptor.doWork();
|
||||
result = true;
|
||||
} else {
|
||||
if (timeTracker.markTimeIfDelay(tile.worldObj, latency)) {
|
||||
receptor.doWork();
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (powerLoss > 0 && energyLossTracker.markTimeIfDelay(tile.worldObj, powerLossRegularity)) {
|
||||
|
||||
energyStored -= powerLoss;
|
||||
if (energyStored < 0) {
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (powerSources[i] > 0) {
|
||||
powerSources[i]--;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preConditions(IPowerReceptor receptor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float useEnergy(float min, float max, boolean doUse) {
|
||||
float result = 0;
|
||||
|
||||
if (energyStored >= min) {
|
||||
if (energyStored <= max) {
|
||||
result = energyStored;
|
||||
if (doUse) {
|
||||
energyStored = 0;
|
||||
}
|
||||
} else {
|
||||
result = max;
|
||||
if (doUse) {
|
||||
energyStored -= max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
latency = nbttagcompound.getInteger("latency");
|
||||
minEnergyReceived = nbttagcompound.getInteger("minEnergyReceived");
|
||||
maxEnergyReceived = nbttagcompound.getInteger("maxEnergyReceived");
|
||||
maxEnergyStored = nbttagcompound.getInteger("maxStoreEnergy");
|
||||
minActivationEnergy = nbttagcompound.getInteger("minActivationEnergy");
|
||||
|
||||
try {
|
||||
energyStored = nbttagcompound.getFloat("storedEnergy");
|
||||
} catch (Throwable c) {
|
||||
energyStored = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("latency", latency);
|
||||
nbttagcompound.setInteger("minEnergyReceived", minEnergyReceived);
|
||||
nbttagcompound.setInteger("maxEnergyReceived", maxEnergyReceived);
|
||||
nbttagcompound.setInteger("maxStoreEnergy", maxEnergyStored);
|
||||
nbttagcompound.setInteger("minActivationEnergy", minActivationEnergy);
|
||||
nbttagcompound.setFloat("storedEnergy", energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveEnergy(float quantity, Orientations from) {
|
||||
powerSources[from.ordinal()] = 2;
|
||||
|
||||
energyStored += quantity;
|
||||
|
||||
if (energyStored > maxEnergyStored) {
|
||||
energyStored = maxEnergyStored;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSource(Orientations from) {
|
||||
return powerSources[from.ordinal()] != 0;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,46 @@
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class AssemblyRecipe {
|
||||
|
||||
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
|
||||
|
||||
public final ItemStack[] input;
|
||||
public final ItemStack output;
|
||||
public final float energy;
|
||||
|
||||
public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
public boolean canBeDone(ItemStack[] items) {
|
||||
|
||||
for (ItemStack in : input) {
|
||||
|
||||
if (in == null)
|
||||
continue;
|
||||
|
||||
int found = 0; // Amount of ingredient found in inventory
|
||||
|
||||
for (ItemStack item : items) {
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
if (item.isItemEqual(in))
|
||||
found += item.stackSize; // Adds quantity of stack to amount
|
||||
// found
|
||||
}
|
||||
|
||||
if (found < in.stackSize)
|
||||
return false; // Return false if the amount of ingredient found
|
||||
// is not enough
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package buildcraft.api.recipes;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class AssemblyRecipe {
|
||||
|
||||
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
|
||||
|
||||
public final ItemStack[] input;
|
||||
public final ItemStack output;
|
||||
public final float energy;
|
||||
|
||||
public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
public boolean canBeDone(ItemStack[] items) {
|
||||
|
||||
for (ItemStack in : input) {
|
||||
|
||||
if (in == null)
|
||||
continue;
|
||||
|
||||
int found = 0; // Amount of ingredient found in inventory
|
||||
|
||||
for (ItemStack item : items) {
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
if (item.isItemEqual(in))
|
||||
found += item.stackSize; // Adds quantity of stack to amount
|
||||
// found
|
||||
}
|
||||
|
||||
if (found < in.stackSize)
|
||||
return false; // Return false if the amount of ingredient found
|
||||
// is not enough
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.recipes;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class RefineryRecipe {
|
||||
|
||||
private static LinkedList<RefineryRecipe> recipes = new LinkedList<RefineryRecipe>();
|
||||
|
||||
public static void registerRefineryRecipe(RefineryRecipe recipe) {
|
||||
if (!recipes.contains(recipe)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static RefineryRecipe findRefineryRecipe(LiquidStack liquid1, LiquidStack liquid2) {
|
||||
for(RefineryRecipe recipe : recipes)
|
||||
if(recipe.matches(liquid1, liquid2))
|
||||
return recipe;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack ingredient1;
|
||||
public final LiquidStack ingredient2;
|
||||
public final LiquidStack result;
|
||||
|
||||
public final int energy;
|
||||
public final int delay;
|
||||
|
||||
public RefineryRecipe(int ingredientId1, int ingredientQty1, int ingredientId2, int ingredientQty2, int resultId, int resultQty,
|
||||
int energy, int delay) {
|
||||
this(new LiquidStack(ingredientId1, ingredientQty1, 0), new LiquidStack(ingredientId2, ingredientQty2, 0), new LiquidStack(resultId, resultQty, 0), energy, delay);
|
||||
}
|
||||
public RefineryRecipe(LiquidStack ingredient1, LiquidStack ingredient2, LiquidStack result, int energy, int delay) {
|
||||
this.ingredient1 = ingredient1;
|
||||
this.ingredient2 = ingredient2;
|
||||
this.result = result;
|
||||
this.energy = energy;
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public boolean matches(LiquidStack liquid1, LiquidStack liquid2) {
|
||||
|
||||
// No inputs, return.
|
||||
if(liquid1 == null && liquid2 == null)
|
||||
return false;
|
||||
|
||||
// Return if two ingredients are required but only one was supplied.
|
||||
if((ingredient1 != null && ingredient2 != null)
|
||||
&& (liquid1 == null || liquid2 == null))
|
||||
return false;
|
||||
|
||||
if(ingredient1 != null) {
|
||||
|
||||
if(ingredient2 == null)
|
||||
return ingredient1.isLiquidEqual(liquid1) || ingredient1.isLiquidEqual(liquid2);
|
||||
else
|
||||
return (ingredient1.isLiquidEqual(liquid1) && ingredient2.isLiquidEqual(liquid2))
|
||||
|| (ingredient2.isLiquidEqual(liquid1) && ingredient1.isLiquidEqual(liquid2));
|
||||
|
||||
} else if(ingredient2 != null)
|
||||
return ingredient2.isLiquidEqual(liquid1) || ingredient2.isLiquidEqual(liquid2);
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.recipes;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
|
||||
|
||||
public class RefineryRecipe {
|
||||
|
||||
private static LinkedList<RefineryRecipe> recipes = new LinkedList<RefineryRecipe>();
|
||||
|
||||
public static void registerRefineryRecipe(RefineryRecipe recipe) {
|
||||
if (!recipes.contains(recipe)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
public static RefineryRecipe findRefineryRecipe(LiquidStack liquid1, LiquidStack liquid2) {
|
||||
for(RefineryRecipe recipe : recipes)
|
||||
if(recipe.matches(liquid1, liquid2))
|
||||
return recipe;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final LiquidStack ingredient1;
|
||||
public final LiquidStack ingredient2;
|
||||
public final LiquidStack result;
|
||||
|
||||
public final int energy;
|
||||
public final int delay;
|
||||
|
||||
public RefineryRecipe(int ingredientId1, int ingredientQty1, int ingredientId2, int ingredientQty2, int resultId, int resultQty,
|
||||
int energy, int delay) {
|
||||
this(new LiquidStack(ingredientId1, ingredientQty1, 0), new LiquidStack(ingredientId2, ingredientQty2, 0), new LiquidStack(resultId, resultQty, 0), energy, delay);
|
||||
}
|
||||
public RefineryRecipe(LiquidStack ingredient1, LiquidStack ingredient2, LiquidStack result, int energy, int delay) {
|
||||
this.ingredient1 = ingredient1;
|
||||
this.ingredient2 = ingredient2;
|
||||
this.result = result;
|
||||
this.energy = energy;
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public boolean matches(LiquidStack liquid1, LiquidStack liquid2) {
|
||||
|
||||
// No inputs, return.
|
||||
if(liquid1 == null && liquid2 == null)
|
||||
return false;
|
||||
|
||||
// Return if two ingredients are required but only one was supplied.
|
||||
if((ingredient1 != null && ingredient2 != null)
|
||||
&& (liquid1 == null || liquid2 == null))
|
||||
return false;
|
||||
|
||||
if(ingredient1 != null) {
|
||||
|
||||
if(ingredient2 == null)
|
||||
return ingredient1.isLiquidEqual(liquid1) || ingredient1.isLiquidEqual(liquid2);
|
||||
else
|
||||
return (ingredient1.isLiquidEqual(liquid1) && ingredient2.isLiquidEqual(liquid2))
|
||||
|| (ingredient2.isLiquidEqual(liquid1) && ingredient1.isLiquidEqual(liquid2));
|
||||
|
||||
} else if(ingredient2 != null)
|
||||
return ingredient2.isLiquidEqual(liquid1) || ingredient2.isLiquidEqual(liquid2);
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
package buildcraft.api.tools;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface IToolPipette {
|
||||
|
||||
/**
|
||||
* @param pipette ItemStack of the pipette.
|
||||
* @return Capacity of the pipette.
|
||||
*/
|
||||
int getCapacity(ItemStack pipette);
|
||||
/**
|
||||
* @param pipette
|
||||
* @return true if the pipette can pipette.
|
||||
*/
|
||||
boolean canPipette(ItemStack pipette);
|
||||
/**
|
||||
* Fills the pipette with the given liquid stack.
|
||||
* @param pipette
|
||||
* @param liquid
|
||||
* @param doFill
|
||||
* @return Amount of liquid used in filling the pipette.
|
||||
*/
|
||||
int fill(ItemStack pipette, LiquidStack liquid, boolean doFill);
|
||||
/**
|
||||
* Drains liquid from the pipette
|
||||
* @param pipette
|
||||
* @param maxDrain
|
||||
* @param doDrain
|
||||
* @return Liquid stack representing the liquid and amount drained from the pipette.
|
||||
*/
|
||||
LiquidStack drain(ItemStack pipette, int maxDrain, boolean doDrain);
|
||||
}
|
||||
package buildcraft.api.tools;
|
||||
|
||||
import buildcraft.api.liquids.LiquidStack;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface IToolPipette {
|
||||
|
||||
/**
|
||||
* @param pipette ItemStack of the pipette.
|
||||
* @return Capacity of the pipette.
|
||||
*/
|
||||
int getCapacity(ItemStack pipette);
|
||||
/**
|
||||
* @param pipette
|
||||
* @return true if the pipette can pipette.
|
||||
*/
|
||||
boolean canPipette(ItemStack pipette);
|
||||
/**
|
||||
* Fills the pipette with the given liquid stack.
|
||||
* @param pipette
|
||||
* @param liquid
|
||||
* @param doFill
|
||||
* @return Amount of liquid used in filling the pipette.
|
||||
*/
|
||||
int fill(ItemStack pipette, LiquidStack liquid, boolean doFill);
|
||||
/**
|
||||
* Drains liquid from the pipette
|
||||
* @param pipette
|
||||
* @param maxDrain
|
||||
* @param doDrain
|
||||
* @return Liquid stack representing the liquid and amount drained from the pipette.
|
||||
*/
|
||||
LiquidStack drain(ItemStack pipette, int maxDrain, boolean doDrain);
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
package buildcraft.api.tools;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
|
||||
/***
|
||||
* Implement this interface on subclasses of Item to have that item work as a
|
||||
* wrench for buildcraft
|
||||
*/
|
||||
public interface IToolWrench {
|
||||
|
||||
/***
|
||||
* Called to ensure that the wrench can be used. To get the ItemStack that
|
||||
* is used, check player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates for the block being wrenched
|
||||
*
|
||||
* @return true if wrenching is allowed, false if not
|
||||
*/
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z);
|
||||
|
||||
/***
|
||||
* Callback after the wrench has been used. This can be used to decrease
|
||||
* durability or for other purposes. To get the ItemStack that was used,
|
||||
* check player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates of the block being wrenched
|
||||
*/
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z);
|
||||
}
|
||||
package buildcraft.api.tools;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
|
||||
/***
|
||||
* Implement this interface on subclasses of Item to have that item work as a
|
||||
* wrench for buildcraft
|
||||
*/
|
||||
public interface IToolWrench {
|
||||
|
||||
/***
|
||||
* Called to ensure that the wrench can be used. To get the ItemStack that
|
||||
* is used, check player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates for the block being wrenched
|
||||
*
|
||||
* @return true if wrenching is allowed, false if not
|
||||
*/
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z);
|
||||
|
||||
/***
|
||||
* Callback after the wrench has been used. This can be used to decrease
|
||||
* durability or for other purposes. To get the ItemStack that was used,
|
||||
* check player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates of the block being wrenched
|
||||
*/
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z);
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2012
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface IPassiveItemContribution {
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2012
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public interface IPassiveItemContribution {
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
}
|
||||
@@ -1,45 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IPipe {
|
||||
|
||||
enum DrawingState {
|
||||
DrawingPipe, DrawingRedWire, DrawingBlueWire, DrawingGreenWire, DrawingYellowWire, DrawingGate
|
||||
}
|
||||
|
||||
enum WireColor {
|
||||
Red, Blue, Green, Yellow;
|
||||
|
||||
public WireColor reverse() {
|
||||
switch (this) {
|
||||
case Red:
|
||||
return Yellow;
|
||||
case Blue:
|
||||
return Green;
|
||||
case Green:
|
||||
return Blue;
|
||||
default:
|
||||
return Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWired(WireColor color);
|
||||
|
||||
public boolean hasInterface();
|
||||
|
||||
public TileEntity getContainer();
|
||||
|
||||
public boolean isWireConnectedTo(TileEntity tile, WireColor color);
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public interface IPipe {
|
||||
|
||||
enum DrawingState {
|
||||
DrawingPipe, DrawingRedWire, DrawingBlueWire, DrawingGreenWire, DrawingYellowWire, DrawingGate
|
||||
}
|
||||
|
||||
enum WireColor {
|
||||
Red, Blue, Green, Yellow;
|
||||
|
||||
public WireColor reverse() {
|
||||
switch (this) {
|
||||
case Red:
|
||||
return Yellow;
|
||||
case Blue:
|
||||
return Green;
|
||||
case Green:
|
||||
return Blue;
|
||||
default:
|
||||
return Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWired(WireColor color);
|
||||
|
||||
public boolean hasInterface();
|
||||
|
||||
public TileEntity getContainer();
|
||||
|
||||
public boolean isWireConnectedTo(TileEntity tile, WireColor color);
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface IPipeConnection {
|
||||
|
||||
public boolean isPipeConnected(Orientations with);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
public interface IPipeConnection {
|
||||
|
||||
public boolean isPipeConnected(Orientations with);
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
/**
|
||||
* Interface used to put objects into pipes, implemented by pipe tile entities.
|
||||
*/
|
||||
public interface IPipeEntry {
|
||||
|
||||
void entityEntering(ItemStack payload, Orientations orientation);
|
||||
void entityEntering(IPipedItem item, Orientations orientation);
|
||||
|
||||
boolean acceptItems();
|
||||
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import buildcraft.api.core.Orientations;
|
||||
|
||||
/**
|
||||
* Interface used to put objects into pipes, implemented by pipe tile entities.
|
||||
*/
|
||||
public interface IPipeEntry {
|
||||
|
||||
void entityEntering(ItemStack payload, Orientations orientation);
|
||||
void entityEntering(IPipedItem item, Orientations orientation);
|
||||
|
||||
boolean acceptItems();
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
public interface IPipeTile {
|
||||
|
||||
IPipe getPipe();
|
||||
|
||||
boolean isInitialized();
|
||||
}
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* 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.transport;
|
||||
|
||||
public interface IPipeTile {
|
||||
|
||||
IPipe getPipe();
|
||||
|
||||
boolean isInitialized();
|
||||
}
|
||||
@@ -1,100 +1,104 @@
|
||||
package buildcraft.api.transport;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface IPipedItem {
|
||||
|
||||
public abstract void remove();
|
||||
|
||||
/* GETTING & SETTING */
|
||||
public abstract void setWorld(World world);
|
||||
|
||||
public abstract Position getPosition();
|
||||
|
||||
public abstract void setPosition(double x, double y, double z);
|
||||
|
||||
/**
|
||||
* @return the speed
|
||||
*/
|
||||
public abstract float getSpeed();
|
||||
|
||||
/**
|
||||
* @param speed the speed to set
|
||||
*/
|
||||
public abstract void setSpeed(float speed);
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public abstract ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* @param item the item to set
|
||||
*/
|
||||
public abstract void setItemStack(ItemStack item);
|
||||
|
||||
/**
|
||||
* @return the container
|
||||
*/
|
||||
public abstract TileEntity getContainer();
|
||||
|
||||
/**
|
||||
* @param container the container to set
|
||||
*/
|
||||
public abstract void setContainer(TileEntity container);
|
||||
|
||||
/**
|
||||
* @return the synchroTracker
|
||||
*/
|
||||
public abstract SafeTimeTracker getSynchroTracker();
|
||||
|
||||
/**
|
||||
* @param synchroTracker the synchroTracker to set
|
||||
*/
|
||||
public abstract void setSynchroTracker(SafeTimeTracker synchroTracker);
|
||||
|
||||
/**
|
||||
* @return the deterministicRandomization
|
||||
*/
|
||||
public abstract int getDeterministicRandomization();
|
||||
|
||||
/**
|
||||
* @param deterministicRandomization the deterministicRandomization to set
|
||||
*/
|
||||
public abstract void setDeterministicRandomization(int deterministicRandomization);
|
||||
|
||||
/**
|
||||
* @return the entityId
|
||||
*/
|
||||
public abstract int getEntityId();
|
||||
|
||||
/**
|
||||
* @param entityId the entityId to set
|
||||
*/
|
||||
public abstract void setEntityId(int entityId);
|
||||
|
||||
/* SAVING & LOADING */
|
||||
public abstract void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public abstract EntityItem toEntityItem(Orientations dir);
|
||||
|
||||
public abstract float getEntityBrightness(float f);
|
||||
|
||||
public abstract boolean isCorrupted();
|
||||
|
||||
public abstract void addContribution(String key, IPassiveItemContribution contribution);
|
||||
|
||||
public abstract IPassiveItemContribution getContribution(String key);
|
||||
|
||||
public abstract boolean hasContributions();
|
||||
|
||||
package buildcraft.api.transport;
|
||||
|
||||
import buildcraft.api.core.Orientations;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface IPipedItem {
|
||||
|
||||
public abstract void remove();
|
||||
|
||||
/* GETTING & SETTING */
|
||||
public abstract void setWorld(World world);
|
||||
|
||||
public abstract Position getPosition();
|
||||
|
||||
public abstract void setPosition(double x, double y, double z);
|
||||
|
||||
/**
|
||||
* @return the speed
|
||||
*/
|
||||
public abstract float getSpeed();
|
||||
|
||||
/**
|
||||
* @param speed the speed to set
|
||||
*/
|
||||
public abstract void setSpeed(float speed);
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public abstract ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* @param item the item to set
|
||||
*/
|
||||
public abstract void setItemStack(ItemStack item);
|
||||
|
||||
/**
|
||||
* @return the container
|
||||
*/
|
||||
public abstract TileEntity getContainer();
|
||||
|
||||
/**
|
||||
* @param container the container to set
|
||||
*/
|
||||
public abstract void setContainer(TileEntity container);
|
||||
|
||||
/**
|
||||
* @return the synchroTracker
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract SafeTimeTracker getSynchroTracker();
|
||||
|
||||
/**
|
||||
* @param synchroTracker the synchroTracker to set
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void setSynchroTracker(SafeTimeTracker synchroTracker);
|
||||
|
||||
/**
|
||||
* @return the deterministicRandomization
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract int getDeterministicRandomization();
|
||||
|
||||
/**
|
||||
* @param deterministicRandomization the deterministicRandomization to set
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void setDeterministicRandomization(int deterministicRandomization);
|
||||
|
||||
/**
|
||||
* @return the entityId
|
||||
*/
|
||||
public abstract int getEntityId();
|
||||
|
||||
/**
|
||||
* @param entityId the entityId to set
|
||||
*/
|
||||
public abstract void setEntityId(int entityId);
|
||||
|
||||
/* SAVING & LOADING */
|
||||
public abstract void readFromNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound nbttagcompound);
|
||||
|
||||
public abstract EntityItem toEntityItem(Orientations dir);
|
||||
|
||||
public abstract float getEntityBrightness(float f);
|
||||
|
||||
public abstract boolean isCorrupted();
|
||||
|
||||
public abstract void addContribution(String key, IPassiveItemContribution contribution);
|
||||
|
||||
public abstract IPassiveItemContribution getContribution(String key);
|
||||
|
||||
public abstract boolean hasContributions();
|
||||
|
||||
}
|
||||
@@ -1,45 +1,48 @@
|
||||
package buildcraft.api.transport;
|
||||
|
||||
import java.util.TreeMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Side;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public abstract class PipeManager {
|
||||
|
||||
private static TreeMap<Integer, IPipedItem> allServerEntities = new TreeMap<Integer, IPipedItem>();
|
||||
private static TreeMap<Integer, IPipedItem> allClientEntities = new TreeMap<Integer, IPipedItem>();
|
||||
|
||||
public static List<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
|
||||
|
||||
public static void registerExtractionHandler(IExtractionHandler handler) {
|
||||
extractionHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static boolean canExtractItems(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractItems(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractLiquids(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TreeMap<Integer, IPipedItem> getAllEntities(){
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
return allClientEntities;
|
||||
}
|
||||
return allServerEntities;
|
||||
}
|
||||
}
|
||||
package buildcraft.api.transport;
|
||||
|
||||
import java.util.TreeMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Side;
|
||||
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public abstract class PipeManager {
|
||||
|
||||
@Deprecated
|
||||
private static TreeMap<Integer, IPipedItem> allServerEntities = new TreeMap<Integer, IPipedItem>();
|
||||
@Deprecated
|
||||
private static TreeMap<Integer, IPipedItem> allClientEntities = new TreeMap<Integer, IPipedItem>();
|
||||
|
||||
public static List<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
|
||||
|
||||
public static void registerExtractionHandler(IExtractionHandler handler) {
|
||||
extractionHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static boolean canExtractItems(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractItems(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k) {
|
||||
for(IExtractionHandler handler : extractionHandlers)
|
||||
if(!handler.canExtractLiquids(pipe, world, i, j, k))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static TreeMap<Integer, IPipedItem> getAllEntities(){
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
return allClientEntities;
|
||||
}
|
||||
return allServerEntities;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import obsidian.api.IEnergizedItem;
|
||||
|
||||
import universalelectricity.UniversalElectricity;
|
||||
import universalelectricity.electricity.ElectricInfo;
|
||||
import universalelectricity.implement.IItemElectric;
|
||||
|
||||
import ic2.api.IElectricItem;
|
||||
@@ -116,7 +117,7 @@ public class ItemEnergized extends ItemObsidian implements IEnergizedItem, IItem
|
||||
return energyToUse;
|
||||
}
|
||||
|
||||
public double getWattHours(Object... data)
|
||||
public double getJoules(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
@@ -126,17 +127,17 @@ public class ItemEnergized extends ItemObsidian implements IEnergizedItem, IItem
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setWattHours(double wattHours, Object... data)
|
||||
public void setJoules(double joules, Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)data[0];
|
||||
|
||||
setEnergy(itemstack, (int)(wattHours*UniversalElectricity.Wh_IC2_RATIO));
|
||||
setEnergy(itemstack, (int)(joules*UniversalElectricity.TO_IC2_RATIO));
|
||||
}
|
||||
}
|
||||
|
||||
public double getMaxWattHours()
|
||||
public double getMaxJoules()
|
||||
{
|
||||
return maxEnergy*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
@@ -146,16 +147,16 @@ public class ItemEnergized extends ItemObsidian implements IEnergizedItem, IItem
|
||||
return 20;
|
||||
}
|
||||
|
||||
public double onReceiveElectricity(double wattHourReceive, ItemStack itemStack)
|
||||
public double onReceive(double amps, double voltage, ItemStack itemStack)
|
||||
{
|
||||
int rejects = (int)Math.max((getEnergy(itemStack) + wattHourReceive*UniversalElectricity.Wh_IC2_RATIO) - getMaxEnergy(), 0);
|
||||
setEnergy(itemStack, (int)(getEnergy(itemStack) + wattHourReceive*UniversalElectricity.Wh_IC2_RATIO - rejects));
|
||||
int rejects = (int)Math.max((getEnergy(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)*UniversalElectricity.TO_IC2_RATIO) - getMaxEnergy(), 0);
|
||||
setEnergy(itemStack, (int)(getEnergy(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)*UniversalElectricity.TO_IC2_RATIO - rejects));
|
||||
return rejects*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
|
||||
public double onUseElectricity(double wattHourRequest, ItemStack itemStack)
|
||||
public double onUse(double joulesNeeded, ItemStack itemStack)
|
||||
{
|
||||
int energyRequest = (int)Math.min(getEnergy(itemStack), wattHourRequest*UniversalElectricity.Wh_IC2_RATIO);
|
||||
int energyRequest = (int)Math.min(getEnergy(itemStack), joulesNeeded*UniversalElectricity.TO_IC2_RATIO);
|
||||
setEnergy(itemStack, getEnergy(itemStack) - energyRequest);
|
||||
return energyRequest*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
@@ -169,14 +170,4 @@ public class ItemEnergized extends ItemObsidian implements IEnergizedItem, IItem
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public double getTransferRate()
|
||||
{
|
||||
return transferRate*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
|
||||
public boolean canCharge()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import obsidian.api.IEnergizedItem;
|
||||
|
||||
import universalelectricity.UniversalElectricity;
|
||||
import universalelectricity.electricity.ElectricInfo;
|
||||
import universalelectricity.implement.IItemElectric;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
@@ -112,24 +113,20 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
||||
}
|
||||
else if(inventory[3].getItem() instanceof IItemElectric)
|
||||
{
|
||||
int received = 0;
|
||||
int energyNeeded = currentMaxEnergy - energyStored;
|
||||
IItemElectric item = (IItemElectric)inventory[3].getItem();
|
||||
if((item.getTransferRate()*UniversalElectricity.Wh_IC2_RATIO) <= energyNeeded)
|
||||
{
|
||||
received = (int)(item.onUseElectricity(item.getTransferRate(), inventory[3])*UniversalElectricity.Wh_IC2_RATIO);
|
||||
}
|
||||
else if(item.getTransferRate() > energyNeeded)
|
||||
{
|
||||
item.setWattHours((item.getWattHours(inventory[3]) - (energyNeeded*UniversalElectricity.IC2_RATIO)), inventory[3]);
|
||||
}
|
||||
IItemElectric electricItem = (IItemElectric)inventory[3].getItem();
|
||||
|
||||
if (electricItem.canProduceElectricity())
|
||||
{
|
||||
double receivedElectricity = electricItem.onUse(Math.min(electricItem.getMaxJoules()*0.01, ElectricInfo.getWattHours(200)), inventory[3]);
|
||||
energyStored += ElectricInfo.getWatts(receivedElectricity)*UniversalElectricity.TO_IC2_RATIO;
|
||||
}
|
||||
}
|
||||
else if(inventory[3].getItem() instanceof IElectricItem)
|
||||
{
|
||||
IElectricItem item = (IElectricItem)inventory[3].getItem();
|
||||
if(item.canProvideEnergy())
|
||||
{
|
||||
int gain = ElectricItem.discharge(inventory[3], energyStored, 3, false, false);
|
||||
int gain = ElectricItem.discharge(inventory[3], currentMaxEnergy - energyStored, 3, false, false);
|
||||
setEnergy(energyStored + gain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import obsidian.api.IEnergizedItem;
|
||||
|
||||
import universalelectricity.UniversalElectricity;
|
||||
import universalelectricity.electricity.ElectricInfo;
|
||||
import universalelectricity.implement.IItemElectric;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
@@ -91,24 +92,20 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
||||
}
|
||||
else if(inventory[1].getItem() instanceof IItemElectric)
|
||||
{
|
||||
int received = 0;
|
||||
int energyNeeded = currentMaxEnergy - energyStored;
|
||||
IItemElectric item = (IItemElectric)inventory[1].getItem();
|
||||
if((item.getTransferRate()*UniversalElectricity.Wh_IC2_RATIO) <= energyNeeded)
|
||||
{
|
||||
received = (int)(item.onUseElectricity(item.getTransferRate(), inventory[1])*UniversalElectricity.Wh_IC2_RATIO);
|
||||
}
|
||||
else if(item.getTransferRate() > energyNeeded)
|
||||
{
|
||||
item.setWattHours((item.getWattHours(inventory[1]) - (energyNeeded*UniversalElectricity.IC2_RATIO)), inventory[1]);
|
||||
}
|
||||
IItemElectric electricItem = (IItemElectric)inventory[1].getItem();
|
||||
|
||||
if (electricItem.canProduceElectricity())
|
||||
{
|
||||
double receivedElectricity = electricItem.onUse(Math.min(electricItem.getMaxJoules()*0.01, ElectricInfo.getWattHours(200)), inventory[3]);
|
||||
energyStored += ElectricInfo.getWatts(receivedElectricity)*UniversalElectricity.TO_IC2_RATIO;
|
||||
}
|
||||
}
|
||||
else if(inventory[1].getItem() instanceof IElectricItem)
|
||||
{
|
||||
IElectricItem item = (IElectricItem)inventory[1].getItem();
|
||||
if(item.canProvideEnergy())
|
||||
{
|
||||
int gain = ElectricItem.discharge(inventory[1], energyStored, 3, false, false);
|
||||
int gain = ElectricItem.discharge(inventory[1], currentMaxEnergy - energyStored, 3, false, false);
|
||||
setEnergy(energyStored + gain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import universalelectricity.electricity.ElectricInfo;
|
||||
import universalelectricity.electricity.ElectricityManager;
|
||||
import universalelectricity.implement.IConductor;
|
||||
import universalelectricity.implement.IElectricityReceiver;
|
||||
import universalelectricity.implement.IElectricityStorage;
|
||||
import universalelectricity.implement.IItemElectric;
|
||||
import universalelectricity.implement.IJouleStorage;
|
||||
import universalelectricity.network.ConnectionHandler;
|
||||
import universalelectricity.network.ConnectionHandler.ConnectionType;
|
||||
import universalelectricity.network.ISimpleConnectionHandler;
|
||||
@@ -44,7 +44,7 @@ import net.minecraft.src.*;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
|
||||
public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, ITileNetwork, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IElectricityStorage, IElectricityReceiver, IPeripheral
|
||||
public class TileEntityPowerUnit extends TileEntityDisableable implements IInventory, ISidedInventory, ITileNetwork, IWrenchable, IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IJouleStorage, IElectricityReceiver, IPeripheral
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
|
||||
@@ -106,6 +106,7 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
if(packetTick % 100 == 0)
|
||||
{
|
||||
PacketHandler.sendPowerUnitPacketWithRange(this, 50);
|
||||
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
packetTick++;
|
||||
}
|
||||
@@ -136,9 +137,10 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
}
|
||||
else if(inventory[0].getItem() instanceof IItemElectric)
|
||||
{
|
||||
IItemElectric item = (IItemElectric)inventory[0].getItem();
|
||||
int rejects = (int)(item.onReceiveElectricity(item.getTransferRate(), inventory[0])*UniversalElectricity.Wh_IC2_RATIO);
|
||||
setEnergy(energyStored - ((int)(item.getTransferRate()*UniversalElectricity.Wh_IC2_RATIO) - rejects));
|
||||
IItemElectric electricItem = (IItemElectric) inventory[0].getItem();
|
||||
double ampsToGive = Math.min(ElectricInfo.getAmps(electricItem.getMaxJoules() * 0.005, getVoltage()), energyStored*UniversalElectricity.IC2_RATIO);
|
||||
double joules = electricItem.onReceive(ampsToGive, getVoltage(), inventory[0]);
|
||||
setJoules(joules - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - joules));
|
||||
}
|
||||
else if(inventory[0].getItem() instanceof IElectricItem)
|
||||
{
|
||||
@@ -157,9 +159,13 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
}
|
||||
else if(inventory[1].getItem() instanceof IItemElectric)
|
||||
{
|
||||
IItemElectric item = (IItemElectric)inventory[1].getItem();
|
||||
int received = (int)(item.onUseElectricity(item.getTransferRate(), inventory[1])*UniversalElectricity.Wh_IC2_RATIO);
|
||||
setEnergy(energyStored + received);
|
||||
IItemElectric electricItem = (IItemElectric)inventory[1].getItem();
|
||||
|
||||
if (electricItem.canProduceElectricity())
|
||||
{
|
||||
double joulesReceived = electricItem.onUse(electricItem.getMaxJoules()*0.01, inventory[1]);
|
||||
setEnergy(energyStored + (int)(joulesReceived*UniversalElectricity.TO_IC2_RATIO));
|
||||
}
|
||||
}
|
||||
else if(inventory[1].getItem() instanceof IElectricItem)
|
||||
{
|
||||
@@ -207,13 +213,15 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
|
||||
if(connector != null && connector instanceof TileEntityConductor)
|
||||
{
|
||||
double wattsNeeded = ElectricityManager.instance.getElectricityRequired(((IConductor)connector).getConnectionID());
|
||||
double transferAmps = Math.max(Math.min(Math.min(ElectricInfo.getAmps(wattsNeeded, getVoltage()), ElectricInfo.getAmpsFromWattHours(energyStored*UniversalElectricity.IC2_RATIO, getVoltage())), 15), 0);
|
||||
ElectricityManager.instance.produceElectricity(this, (IConductor)connector, transferAmps, getVoltage());
|
||||
setEnergy(energyStored - (int)(ElectricInfo.getWattHours(transferAmps, getVoltage())*UniversalElectricity.Wh_IC2_RATIO));
|
||||
double joulesNeeded = ElectricityManager.instance.getElectricityRequired(((IConductor) connector).getConnectionID());
|
||||
double transferAmps = Math.max(Math.min(Math.min(ElectricInfo.getAmps(joulesNeeded, getVoltage()), ElectricInfo.getAmps(energyStored*UniversalElectricity.IC2_RATIO, getVoltage())), 80), 0);
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
ElectricityManager.instance.produceElectricity(this, (IConductor) connector, transferAmps, getVoltage());
|
||||
}
|
||||
setEnergy(energyStored - (int)(ElectricInfo.getJoules(transferAmps, getVoltage())*UniversalElectricity.TO_IC2_RATIO));
|
||||
}
|
||||
}
|
||||
worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public void setEnergy(int energy)
|
||||
@@ -467,17 +475,17 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
return output;
|
||||
}
|
||||
|
||||
public double getWattHours(Object... data)
|
||||
public double getJoules(Object... data)
|
||||
{
|
||||
return energyStored*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
|
||||
public void setWattHours(double wattHours, Object... data)
|
||||
public void setJoules(double joules, Object... data)
|
||||
{
|
||||
setEnergy((int)(wattHours*UniversalElectricity.Wh_IC2_RATIO));
|
||||
setEnergy((int)(joules*UniversalElectricity.TO_IC2_RATIO));
|
||||
}
|
||||
|
||||
public double getMaxWattHours()
|
||||
public double getMaxJoules()
|
||||
{
|
||||
return maxEnergy*UniversalElectricity.IC2_RATIO;
|
||||
}
|
||||
@@ -528,7 +536,7 @@ public class TileEntityPowerUnit extends TileEntityDisableable implements IInven
|
||||
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
System.out.println("Received " + amps + " " + voltage);
|
||||
setEnergy(energyStored + (int)(ElectricInfo.getWattHours(amps, voltage)*UniversalElectricity.Wh_IC2_RATIO));
|
||||
setEnergy(energyStored + (int)(ElectricInfo.getWattHours(amps, voltage)*UniversalElectricity.TO_IC2_RATIO));
|
||||
}
|
||||
|
||||
public double wattRequest()
|
||||
|
||||
@@ -29,6 +29,7 @@ public class BasicComponents
|
||||
public static Block oilMoving;
|
||||
public static Block oilStill;
|
||||
public static Block blockMachine;
|
||||
public static Block blockMulti;
|
||||
|
||||
public static final int ITEM_ID_PREFIX = 13970;
|
||||
public static ItemElectric itemBattery;
|
||||
|
||||
@@ -13,10 +13,7 @@ public class Ticker implements ITickHandler
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
if(ElectricityManager.instance != null)
|
||||
{
|
||||
ElectricityManager.instance.tickStart(type, tickData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,7 +21,7 @@ public class Ticker implements ITickHandler
|
||||
{
|
||||
if(ElectricityManager.instance != null)
|
||||
{
|
||||
ElectricityManager.instance.tickEnd(type, tickData);
|
||||
ElectricityManager.instance.onTick(type, tickData);
|
||||
}
|
||||
|
||||
inGameTicks ++;
|
||||
@@ -38,7 +35,7 @@ public class Ticker implements ITickHandler
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.SERVER, TickType.CLIENT);
|
||||
return EnumSet.of(TickType.WORLD, TickType.WORLDLOAD, TickType.CLIENT, TickType.SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,21 +12,21 @@ public class UniversalElectricity
|
||||
{
|
||||
public static final int MAJOR_VERSION = 0;
|
||||
public static final int MINOR_VERSION = 9;
|
||||
public static final int REVISION_VERSION = 1;
|
||||
public static final int REVISION_VERSION = 3;
|
||||
|
||||
public static final String VERSION = MAJOR_VERSION+"."+MINOR_VERSION+"."+REVISION_VERSION;
|
||||
|
||||
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "UniversalElectricity/UniversalElectricity.cfg"));
|
||||
|
||||
//One IC2 EU is 0.012 Watt Hours. EU to Watt Hour
|
||||
public static final float IC2_RATIO = (float)UEConfig.getConfigData(CONFIGURATION, "IC2 to UE Conversion Ratio", (int)(0.0045f*100000))/(float)100000;
|
||||
//EU to Watts ratio
|
||||
public static final float IC2_RATIO = (float)UEConfig.getConfigData(CONFIGURATION, "IndustrialCraft Conversion Ratio", 7);
|
||||
|
||||
//One MJ is 13 Watt Hours. MJ to Watt Hour
|
||||
public static final float BC3_RATIO = (float)UEConfig.getConfigData(CONFIGURATION, "BC3 to UE Conversion Ratio", (int)(0.05f*100000))/(float)100000;;
|
||||
//MJ to Watts ratio.
|
||||
public static final float BC3_RATIO = (float)UEConfig.getConfigData(CONFIGURATION, "BuildCraft Conversion Ratio", 85);;
|
||||
|
||||
public static final float Wh_IC2_RATIO = 1/IC2_RATIO;
|
||||
public static final float TO_IC2_RATIO = 1/IC2_RATIO;
|
||||
|
||||
public static final float Wh_BC_RATIO = 1/BC3_RATIO;
|
||||
public static final float TO_BC_RATIO = 1/BC3_RATIO;
|
||||
|
||||
/**
|
||||
* Use this material for all your machine blocks. It can be breakable by hand.
|
||||
|
||||
@@ -16,7 +16,8 @@ public class ElectricInfo
|
||||
WATT("Watt", "W"),
|
||||
WATT_HOUR("Watt Hour", "Wh"),
|
||||
RESISTANCE("Ohm", "R"),
|
||||
CONDUCTANCE("Siemens", "S");
|
||||
CONDUCTANCE("Siemen", "S"),
|
||||
JOULES("Joule", "J");
|
||||
|
||||
public String name;
|
||||
public String symbol;
|
||||
@@ -69,6 +70,21 @@ public class ElectricInfo
|
||||
}
|
||||
}
|
||||
|
||||
public static double getJoules(double watts, double seconds)
|
||||
{
|
||||
return watts*seconds;
|
||||
}
|
||||
|
||||
public static double getJoules(double amps, double voltage, double seconds)
|
||||
{
|
||||
return amps*voltage*seconds;
|
||||
}
|
||||
|
||||
public static double getWattsFromJoules(double joules, double seconds)
|
||||
{
|
||||
return joules/seconds;
|
||||
}
|
||||
|
||||
public static double getAmps(double watts, double voltage)
|
||||
{
|
||||
return watts/voltage;
|
||||
|
||||
@@ -12,14 +12,12 @@ import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.Ticker;
|
||||
import universalelectricity.implement.IConductor;
|
||||
import universalelectricity.implement.IElectricityReceiver;
|
||||
import universalelectricity.prefab.TileEntityConductor;
|
||||
import universalelectricity.prefab.Vector3;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
* This class is used to manage electricity transferring and flow. It is also used to call updates on UE tile entities.
|
||||
*
|
||||
* Electricity Manager is made for each world so it doesn't conflict with electricity devices in different dimensions.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@@ -62,7 +60,7 @@ public class ElectricityManager
|
||||
* @param conductor - The conductor tile entity
|
||||
* @return - The ID of the connection line that is assigned to this conductor
|
||||
*/
|
||||
public void registerConductor(TileEntityConductor newConductor)
|
||||
public void registerConductor(IConductor newConductor)
|
||||
{
|
||||
cleanUpConnections();
|
||||
this.electricityNetworks.add(new ElectricityNetwork(getMaxConnectionID(), newConductor));
|
||||
@@ -149,15 +147,22 @@ public class ElectricityManager
|
||||
*/
|
||||
public void cleanUpConnections()
|
||||
{
|
||||
for (int i = 0; i < this.electricityNetworks.size(); i++)
|
||||
{
|
||||
this.electricityNetworks.get(i).cleanUpArray();
|
||||
|
||||
if (this.electricityNetworks.get(i).conductors.size() == 0)
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < this.electricityNetworks.size(); i++)
|
||||
{
|
||||
this.electricityNetworks.remove(i);
|
||||
this.electricityNetworks.get(i).cleanUpArray();
|
||||
|
||||
if (this.electricityNetworks.get(i).conductors.size() == 0)
|
||||
{
|
||||
this.electricityNetworks.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
FMLLog.severe("Failed to clean up wire connections!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,6 +172,12 @@ public class ElectricityManager
|
||||
public int getMaxConnectionID()
|
||||
{
|
||||
this.maxConnectionID ++;
|
||||
|
||||
if(this.maxConnectionID >= Integer.MAX_VALUE)
|
||||
{
|
||||
this.maxConnectionID = 0;
|
||||
}
|
||||
|
||||
return this.maxConnectionID;
|
||||
}
|
||||
|
||||
@@ -201,9 +212,9 @@ public class ElectricityManager
|
||||
{
|
||||
IElectricityReceiver receiver = (IElectricityReceiver)tileEntity;
|
||||
|
||||
if (Math.ceil(receiver.wattRequest()) > 0 && receiver.canReceiveFromSide(ForgeDirection.getOrientation(i).getOpposite()))
|
||||
if (this.getActualWattRequest(receiver) > 0 && receiver.canReceiveFromSide(ForgeDirection.getOrientation(i).getOpposite()))
|
||||
{
|
||||
double transferAmps = Math.max(0, Math.min(leftOverAmps, Math.min(amps / allElectricUnitsInLine.size(), ElectricInfo.getAmps(Math.ceil(receiver.wattRequest()), receiver.getVoltage()) )));
|
||||
double transferAmps = Math.max(0, Math.min(leftOverAmps, Math.min(amps / allElectricUnitsInLine.size(), ElectricInfo.getAmps(this.getActualWattRequest(receiver), receiver.getVoltage()))));
|
||||
leftOverAmps -= transferAmps;
|
||||
|
||||
//Calculate electricity loss
|
||||
@@ -220,10 +231,42 @@ public class ElectricityManager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual watt request of an electric receiver accounting all current electricity packets qued up for it.
|
||||
* @return - The amount of watts requested.
|
||||
*/
|
||||
public double getActualWattRequest(IElectricityReceiver receiver)
|
||||
{
|
||||
double wattsRequest = receiver.wattRequest();
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < electricityTransferQueue.size(); i ++)
|
||||
{
|
||||
if(electricityTransferQueue.get(i) != null)
|
||||
{
|
||||
if(electricityTransferQueue.get(i).isValid())
|
||||
{
|
||||
if(electricityTransferQueue.get(i).receiver == receiver)
|
||||
{
|
||||
wattsRequest -= electricityTransferQueue.get(i).amps*electricityTransferQueue.get(i).voltage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
FMLLog.severe("Failed to get watt request!");
|
||||
}
|
||||
|
||||
return Math.max(Math.min(wattsRequest, receiver.wattRequest()), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current connection line needs electricity
|
||||
* @return - The amount of watts this connection line needs
|
||||
* @return - The amount of joules this connection line needs
|
||||
*/
|
||||
public double getElectricityRequired(int ID)
|
||||
{
|
||||
@@ -246,7 +289,39 @@ public class ElectricityManager
|
||||
|
||||
if (electricUnit.canReceiveFromSide(ForgeDirection.getOrientation(i).getOpposite()))
|
||||
{
|
||||
need += Math.ceil(electricUnit.wattRequest());
|
||||
need += electricUnit.wattRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return need;
|
||||
}
|
||||
|
||||
public double getActualElectricityRequired(int ID)
|
||||
{
|
||||
ElectricityNetwork connection = this.getConnectionByID(ID);
|
||||
double need = 0;
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
for (IConductor conductor : connection.conductors)
|
||||
{
|
||||
for (byte i = 0; i < conductor.getConnectedBlocks().length; i++)
|
||||
{
|
||||
TileEntity tileEntity = conductor.getConnectedBlocks()[i];
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof IElectricityReceiver)
|
||||
{
|
||||
IElectricityReceiver electricUnit = (IElectricityReceiver)tileEntity;
|
||||
|
||||
if (electricUnit.canReceiveFromSide(ForgeDirection.getOrientation(i).getOpposite()))
|
||||
{
|
||||
need += this.getActualWattRequest(electricUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,62 +373,62 @@ public class ElectricityManager
|
||||
}
|
||||
}
|
||||
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
public void onTick(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
try
|
||||
if((type.contains(TickType.CLIENT) || type.contains(TickType.WORLD)) && !type.contains(TickType.WORLDLOAD))
|
||||
{
|
||||
HashMap conductorAmpData = new HashMap<ElectricityNetwork, Double>();
|
||||
|
||||
for (int i = 0; i < electricityTransferQueue.size(); i ++)
|
||||
{
|
||||
if(electricityTransferQueue.get(i) != null)
|
||||
{
|
||||
if(electricityTransferQueue.get(i).isValid())
|
||||
{
|
||||
double amps = electricityTransferQueue.get(i).amps;
|
||||
|
||||
if(conductorAmpData.containsKey(electricityTransferQueue.get(i).network))
|
||||
{
|
||||
amps += (Double)conductorAmpData.get(electricityTransferQueue.get(i).network);
|
||||
}
|
||||
|
||||
conductorAmpData.put(electricityTransferQueue.get(i).network, amps);
|
||||
electricityTransferQueue.get(i).receiver.onReceive(electricityTransferQueue.get(i).sender, electricityTransferQueue.get(i).amps, electricityTransferQueue.get(i).voltage, electricityTransferQueue.get(i).side);
|
||||
}
|
||||
}
|
||||
|
||||
electricityTransferQueue.remove(i);
|
||||
}
|
||||
|
||||
Iterator it = conductorAmpData.entrySet().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry pairs = (Map.Entry)it.next();
|
||||
|
||||
if(pairs.getKey() != null && pairs.getValue() != null)
|
||||
try
|
||||
{
|
||||
HashMap conductorAmpData = new HashMap<ElectricityNetwork, Double>();
|
||||
|
||||
for (int i = 0; i < electricityTransferQueue.size(); i ++)
|
||||
{
|
||||
if(pairs.getKey() instanceof ElectricityNetwork && pairs.getValue() instanceof Double)
|
||||
if(electricityTransferQueue.get(i) != null)
|
||||
{
|
||||
if(((Double)pairs.getValue()) > ((ElectricityNetwork)pairs.getKey()).getLowestAmpConductor())
|
||||
{
|
||||
((ElectricityNetwork)pairs.getKey()).meltDown();
|
||||
}
|
||||
if(electricityTransferQueue.get(i).isValid())
|
||||
{
|
||||
double amps = electricityTransferQueue.get(i).amps;
|
||||
|
||||
if(conductorAmpData.containsKey(electricityTransferQueue.get(i).network))
|
||||
{
|
||||
amps += (Double)conductorAmpData.get(electricityTransferQueue.get(i).network);
|
||||
}
|
||||
|
||||
conductorAmpData.put(electricityTransferQueue.get(i).network, amps);
|
||||
electricityTransferQueue.get(i).receiver.onReceive(electricityTransferQueue.get(i).sender, electricityTransferQueue.get(i).amps, electricityTransferQueue.get(i).voltage, electricityTransferQueue.get(i).side);
|
||||
}
|
||||
}
|
||||
|
||||
electricityTransferQueue.remove(i);
|
||||
}
|
||||
|
||||
it.remove();
|
||||
}
|
||||
|
||||
Iterator it = conductorAmpData.entrySet().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry pairs = (Map.Entry)it.next();
|
||||
|
||||
if(pairs.getKey() != null && pairs.getValue() != null)
|
||||
{
|
||||
if(pairs.getKey() instanceof ElectricityNetwork && pairs.getValue() instanceof Double)
|
||||
{
|
||||
if(((Double)pairs.getValue()) > ((ElectricityNetwork)pairs.getKey()).getLowestAmpConductor())
|
||||
{
|
||||
((ElectricityNetwork)pairs.getKey()).meltDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.err.println("Failed to transfer electricity to receivers.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.err.println("Failed to transfer electricity to receivers.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
if(Ticker.inGameTicks == 0)
|
||||
{
|
||||
this.refreshConductors();
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface IConductor extends IConnector
|
||||
public void reset();
|
||||
|
||||
public World getWorld();
|
||||
|
||||
public void updateConnection(TileEntity tileEntity, ForgeDirection side);
|
||||
|
||||
public void updateConnectionWithoutSplit(TileEntity connectorFromSide, ForgeDirection orientation);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
|
||||
/**
|
||||
* The IMachine interface is an interface that must be applied to all tile entities that can input or output electricity.
|
||||
* The IElectricityReceiver interface is an interface that must be applied to all tile entities that can input or output electricity.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@@ -23,17 +23,13 @@ public interface IElectricityReceiver extends IDisableable, IConnector, IVoltage
|
||||
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side);
|
||||
|
||||
/**
|
||||
* How many watts does this electrical unit need per tick?
|
||||
* Recommend for you to return the max electricity storage of this machine (if there is one).
|
||||
*
|
||||
* Set this to 0 if your electric unit can not receive electricity.
|
||||
* How many watts does this electrical unit need this tick?
|
||||
* Recommended for you to return the max electricity storage of this machine (if there is one).
|
||||
*/
|
||||
public double wattRequest();
|
||||
|
||||
/**
|
||||
* Can this unit receive electricity from this specific side
|
||||
* @param side. 0-5 byte
|
||||
* @return - True if so.
|
||||
* Can this unit receive electricity from this specific side?
|
||||
*/
|
||||
public boolean canReceiveFromSide(ForgeDirection side);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package universalelectricity.implement;
|
||||
|
||||
/**
|
||||
* This interface is to be applied to all tile entities which stores electricity
|
||||
* within them.
|
||||
* @author Calclavia
|
||||
*/
|
||||
public interface IElectricityStorage
|
||||
{
|
||||
/**
|
||||
* Returns the amount of watt hours this unit has stored.
|
||||
*/
|
||||
public double getWattHours(Object... data);
|
||||
|
||||
/**
|
||||
* Sets the amount of watt hours this unit has stored.
|
||||
*/
|
||||
public void setWattHours(double wattHours, Object... data);
|
||||
|
||||
/**
|
||||
* Gets the maximum amount of watt hours this unit can store.
|
||||
*/
|
||||
public double getMaxWattHours();
|
||||
}
|
||||
@@ -2,15 +2,28 @@ package universalelectricity.implement;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface IItemElectric extends IElectricityStorage, IVoltage
|
||||
public interface IItemElectric extends IJouleStorage, IVoltage
|
||||
{
|
||||
public double onReceiveElectricity(double wattHourReceive, ItemStack itemStack);
|
||||
/**
|
||||
* Called when this item receives electricity.
|
||||
*/
|
||||
public double onReceive(double amps, double voltage, ItemStack itemStack);
|
||||
|
||||
public double onUseElectricity(double wattHourRequest, ItemStack itemStack);
|
||||
/**
|
||||
* Called when something requests electricity from this item.
|
||||
* @return - The amount of given joules
|
||||
*/
|
||||
public double onUse(double joulesNeeded, ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
|
||||
*/
|
||||
public boolean canReceiveElectricity();
|
||||
|
||||
public boolean canProduceElectricity();
|
||||
|
||||
public double getTransferRate();
|
||||
/**
|
||||
* Can this item give out electricity when placed in an tile entity? Electric items like batteries
|
||||
* should be able to produce electricity (if they are rechargeable).
|
||||
* @return - True or False.
|
||||
*/
|
||||
public boolean canProduceElectricity();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package universalelectricity.implement;
|
||||
|
||||
/**
|
||||
* This interface is to be applied to all tile entities which stores energy within them.
|
||||
* @author Calclavia
|
||||
*/
|
||||
public interface IJouleStorage
|
||||
{
|
||||
/**
|
||||
* Returns the amount of joules this unit has stored.
|
||||
*/
|
||||
public double getJoules(Object... data);
|
||||
|
||||
/**
|
||||
* Sets the amount of joules this unit has stored.
|
||||
*/
|
||||
public void setJoules(double wattHours, Object... data);
|
||||
|
||||
/**
|
||||
* Gets the maximum amount of joules this unit can store.
|
||||
*/
|
||||
public double getMaxJoules();
|
||||
}
|
||||
@@ -3,8 +3,7 @@ package universalelectricity.implement;
|
||||
public interface IVoltage
|
||||
{
|
||||
/**
|
||||
* Gets the voltage of the electricity consumer. Used in a conductor to find the potential difference.
|
||||
* If the voltage is too high, things might explode.
|
||||
* Gets the voltage of this object.
|
||||
* @return The amount of volts. E.g 120v or 240v
|
||||
*/
|
||||
public double getVoltage();
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.NetLoginHandler;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet1Login;
|
||||
import universalelectricity.electricity.ElectricityManager;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.UEConfig;
|
||||
import universalelectricity.UniversalElectricity;
|
||||
|
||||
/**
|
||||
@@ -82,10 +82,7 @@ public abstract class OreGenBase
|
||||
//Checks the config file and see if Universal Electricity should generate this ore
|
||||
private static boolean shouldGenerateOre(String oreName)
|
||||
{
|
||||
UniversalElectricity.CONFIGURATION.load();
|
||||
boolean shouldGenerate = Boolean.parseBoolean(UniversalElectricity.CONFIGURATION.getOrCreateBooleanProperty("Generate_" + oreName.replace(" ", "_"), Configuration.CATEGORY_GENERAL, true).value);
|
||||
UniversalElectricity.CONFIGURATION.save();
|
||||
return shouldGenerate;
|
||||
return UEConfig.getConfigData(UniversalElectricity.CONFIGURATION, "Generate " + oreName, true);
|
||||
}
|
||||
|
||||
public abstract void generate(World world, Random random, int varX, int varZ);
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class AdvancedTile extends TileEntity
|
||||
|
||||
if(this.ticks >= Long.MAX_VALUE)
|
||||
{
|
||||
this.ticks = 0;
|
||||
this.ticks = 1;
|
||||
}
|
||||
|
||||
this.ticks ++;
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.implement.IConductor;
|
||||
|
||||
public abstract class BlockConductor extends BlockContainer
|
||||
{
|
||||
@@ -40,11 +41,15 @@ public abstract class BlockConductor extends BlockContainer
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
TileEntityConductor conductorTileEntity = (TileEntityConductor)tileEntity;
|
||||
conductorTileEntity.updateConnection(Vector3.getConnectorFromSide(world, new Vector3(x, y, z), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
|
||||
}
|
||||
if(tileEntity instanceof IConductor)
|
||||
{
|
||||
IConductor conductorTileEntity = (IConductor)tileEntity;
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
conductorTileEntity.updateConnection(Vector3.getConnectorFromSide(world, new Vector3(x, y, z), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,15 +77,16 @@ public abstract class BlockMachine extends BlockContainer
|
||||
{
|
||||
if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IToolWrench)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||
((IToolWrench)par5EntityPlayer.inventory.getCurrentItem().getItem()).wrenchUsed(par5EntityPlayer, x, y, z);
|
||||
|
||||
if(par5EntityPlayer.isSneaking())
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||
return this.onSneakUseWrench(par1World, x, y, z, par5EntityPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
|
||||
return this.onUseWrench(par1World, x, y, z, par5EntityPlayer);
|
||||
return this.onUseWrench(par1World, x, y, z, par5EntityPlayer);
|
||||
}
|
||||
}
|
||||
else if (par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof IItemElectric)
|
||||
|
||||
@@ -15,8 +15,7 @@ import universalelectricity.electricity.ElectricInfo.ElectricUnit;
|
||||
import universalelectricity.implement.IItemElectric;
|
||||
|
||||
/**
|
||||
* REQUIRED
|
||||
* Extend from this class if your item requires electricity or to be charged.
|
||||
* Extend from this class if your item requires electricity or to be charged. Optionally, you can implement IItemElectric instead.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@@ -26,7 +25,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
{
|
||||
super(id);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage((int)this.getMaxWattHours());
|
||||
this.setMaxDamage((int)this.getMaxJoules());
|
||||
this.setNoRepair();
|
||||
this.setCreativeTab(tabs);
|
||||
}
|
||||
@@ -44,13 +43,13 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
public void addInformation(ItemStack par1ItemStack, List par2List)
|
||||
{
|
||||
String color = "";
|
||||
double watts = this.getWattHours(par1ItemStack);
|
||||
double joules = this.getJoules(par1ItemStack);
|
||||
|
||||
if (watts <= this.getMaxWattHours() / 3)
|
||||
if (joules <= this.getMaxJoules() / 3)
|
||||
{
|
||||
color = "\u00a74";
|
||||
}
|
||||
else if (watts > this.getMaxWattHours() * 2 / 3)
|
||||
else if (joules > this.getMaxJoules() * 2 / 3)
|
||||
{
|
||||
color = "\u00a72";
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
color = "\u00a76";
|
||||
}
|
||||
|
||||
par2List.add(color + ElectricInfo.getDisplay(ElectricInfo.getWattHours(watts), ElectricUnit.WATT_HOUR) + " - " + Math.round((watts / this.getMaxWattHours()) * 100) + "%");
|
||||
par2List.add(color + ElectricInfo.getDisplay(joules, ElectricUnit.JOULES) + " - " + Math.round((joules / this.getMaxJoules()) * 100) + "%");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +69,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
{
|
||||
//Makes sure the damage is set correctly for this electric item!
|
||||
ItemElectric item = ((ItemElectric)par1ItemStack.getItem());
|
||||
item.setWattHours(item.getWattHours(par1ItemStack), par1ItemStack);
|
||||
item.setJoules(item.getJoules(par1ItemStack), par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,45 +82,27 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
par1ItemStack = this.getUnchargedItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item is being "recharged" or receiving electricity.
|
||||
* @param wattHourReceive - The amount of watt hours this item is receiving.
|
||||
* @param itemStack - The ItemStack of this item
|
||||
* @return Return the rejected electricity from this item
|
||||
*/
|
||||
public double onReceiveElectricity(double wattHourReceive, ItemStack itemStack)
|
||||
@Override
|
||||
public double onReceive(double amps, double voltage, ItemStack itemStack)
|
||||
{
|
||||
double rejectedElectricity = Math.max((this.getWattHours(itemStack) + wattHourReceive) - this.getMaxWattHours(), 0);
|
||||
this.setWattHours(this.getWattHours(itemStack) + wattHourReceive - rejectedElectricity, itemStack);
|
||||
double rejectedElectricity = Math.max((this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - this.getMaxJoules(), 0);
|
||||
this.setJoules(this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1) - rejectedElectricity, itemStack);
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item's electricity is being used.
|
||||
* @param wattHourRequest - The amount of electricity requested from this item
|
||||
* @param itemStack - The ItemStack of this item
|
||||
* @return The electricity that is given to the requester
|
||||
*/
|
||||
public double onUseElectricity(double wattHourRequest, ItemStack itemStack)
|
||||
@Override
|
||||
public double onUse(double joulesNeeded, ItemStack itemStack)
|
||||
{
|
||||
double electricityToUse = Math.min(this.getWattHours(itemStack), wattHourRequest);
|
||||
this.setWattHours(this.getWattHours(itemStack) - electricityToUse, itemStack);
|
||||
double electricityToUse = Math.min(this.getJoules(itemStack), joulesNeeded);
|
||||
this.setJoules(this.getJoules(itemStack) - electricityToUse, itemStack);
|
||||
return electricityToUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
|
||||
*/
|
||||
public boolean canReceiveElectricity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this item give out electricity when placed in an tile entity? Electric items like batteries
|
||||
* should be able to produce electricity (if they are rechargable).
|
||||
* @return - True or False.
|
||||
*/
|
||||
public boolean canProduceElectricity()
|
||||
{
|
||||
return false;
|
||||
@@ -133,7 +114,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
* @param wattHours - The amount of electricity in joules
|
||||
*/
|
||||
@Override
|
||||
public void setWattHours(double wattHours, Object... data)
|
||||
public void setJoules(double wattHours, Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
@@ -145,9 +126,9 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(wattHours, this.getMaxWattHours()), 0);
|
||||
double electricityStored = Math.max(Math.min(wattHours, this.getMaxJoules()), 0);
|
||||
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
|
||||
itemStack.setItemDamage((int)(getMaxWattHours() - electricityStored));
|
||||
itemStack.setItemDamage((int)(getMaxJoules() - electricityStored));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +137,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
* @return - The amount of electricity stored in watts
|
||||
*/
|
||||
@Override
|
||||
public double getWattHours(Object... data)
|
||||
public double getJoules(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
@@ -172,25 +153,13 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
}else{
|
||||
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
|
||||
}
|
||||
itemStack.setItemDamage((int)(getMaxWattHours() - electricityStored));
|
||||
itemStack.setItemDamage((int)(getMaxJoules() - electricityStored));
|
||||
return electricityStored;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called to get the maximum transfer rate this electric item can receive per tick
|
||||
* @return - The amount of electricity maximum capacity
|
||||
*/
|
||||
public abstract double getTransferRate();
|
||||
|
||||
/**
|
||||
* Gets the voltage of this item
|
||||
* @return The Voltage of this item
|
||||
*/
|
||||
public abstract double getVoltage();
|
||||
|
||||
/**
|
||||
* Returns an uncharged version of the electric item. Use this if you want
|
||||
* the crafting recipe to use a charged version of the electric item
|
||||
@@ -200,7 +169,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
public ItemStack getUnchargedItemStack()
|
||||
{
|
||||
ItemStack chargedItem = new ItemStack(this);
|
||||
chargedItem.setItemDamage((int) this.getMaxWattHours());
|
||||
chargedItem.setItemDamage((int) this.getMaxJoules());
|
||||
return chargedItem;
|
||||
}
|
||||
|
||||
@@ -209,11 +178,11 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
||||
{
|
||||
//Add an uncharged version of the electric item
|
||||
ItemStack unchargedItem = new ItemStack(this, 1);
|
||||
unchargedItem.setItemDamage((int) this.getMaxWattHours());
|
||||
unchargedItem.setItemDamage((int) this.getMaxJoules());
|
||||
par3List.add(unchargedItem);
|
||||
//Add an electric item to the creative list that is fully charged
|
||||
ItemStack chargedItem = new ItemStack(this, 1);
|
||||
this.setWattHours(((IItemElectric)chargedItem.getItem()).getMaxWattHours(), chargedItem);
|
||||
this.setJoules(((IItemElectric)chargedItem.getItem()).getMaxJoules(), chargedItem);
|
||||
par3List.add(chargedItem);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import universalelectricity.electricity.ElectricityManager;
|
||||
import universalelectricity.implement.IConductor;
|
||||
import universalelectricity.implement.IConnector;
|
||||
import universalelectricity.network.IPacketReceiver;
|
||||
import universalelectricity.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
@@ -63,6 +62,7 @@ public abstract class TileEntityConductor extends AdvancedTile implements ICondu
|
||||
* @param tileEntity - Must be either a producer, consumer or a conductor
|
||||
* @param side - side in which the connection is coming from
|
||||
*/
|
||||
@Override
|
||||
public void updateConnection(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if(tileEntity != null)
|
||||
|
||||
Reference in new issue
Block a user