mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 12:59:41 +00:00
Update BC to a maven dependency
This commit is contained in:
1 parent
e860089535
commit
a32824a434
228 files changed
+8
-8690
No files matched your search
@@ -1,122 +0,0 @@
|
||||
package buildcraft.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
import buildcraft.api.core.BCDebugging;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
/** Stores all of BuildCraft's blocks, from all of its modules. If any of them have been disabled by the user (or it the
|
||||
* module is not installed) then they will be null. This is the equivalent of {@link Blocks} */
|
||||
public class BCBlocks {
|
||||
private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.blocks");
|
||||
|
||||
// BC Core
|
||||
public static final Block CORE_DECORATED;
|
||||
public static final Block CORE_ENGINE;
|
||||
public static final Block CORE_MARKER_VOLUME;
|
||||
public static final Block CORE_MARKER_PATH;
|
||||
|
||||
// BC Builders
|
||||
|
||||
// BC Energy
|
||||
|
||||
// BC Factory
|
||||
public static final Block FACTORY_TANK;
|
||||
public static final Block FACTORY_PUMP;
|
||||
public static final Block FACTORY_CHUTE;
|
||||
public static final Block FACTORY_FLOOD_GATE;
|
||||
public static final Block FACTORY_MINING_WELL;
|
||||
public static final Block FACTORY_AUTOWORKBENCH_ITEM;
|
||||
public static final Block FACTORY_DISTILLER;
|
||||
public static final Block FACTORY_HEAT_EXCHANGE_START;
|
||||
public static final Block FACTORY_HEAT_EXCHANGE_MIDDLE;
|
||||
public static final Block FACTORY_HEAT_EXCHANGE_END;
|
||||
|
||||
// BC Robotics
|
||||
|
||||
// BC Silicon
|
||||
public static final Block SILICON_LASER;
|
||||
public static final Block SILICON_TABLE_ASSEMBLY;
|
||||
public static final Block SILICON_TABLE_INTEGRATION;
|
||||
public static final Block SILICON_TABLE_ADV_CRAFT;
|
||||
public static final Block SILICON_TABLE_CHARGING;
|
||||
public static final Block SILICON_TABLE_PROGRAMMING;
|
||||
|
||||
// BC Transport
|
||||
|
||||
// Set of items scanned
|
||||
private static final Set<String> SCANNED = DEBUG ? new HashSet<>() : null;
|
||||
|
||||
static {
|
||||
if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) {
|
||||
throw new RuntimeException("Accessed BC blocks too early! You can only use them from init onwards!");
|
||||
}
|
||||
String core = "core";
|
||||
CORE_DECORATED = getRegisteredBlock(core, "decorated");
|
||||
CORE_ENGINE = getRegisteredBlock(core, "engine");
|
||||
CORE_MARKER_VOLUME = getRegisteredBlock(core, "marker_volume");
|
||||
CORE_MARKER_PATH = getRegisteredBlock(core, "marker_path");
|
||||
|
||||
String energy = "energy";
|
||||
|
||||
String factory = "factory";
|
||||
FACTORY_TANK = getRegisteredBlock(factory, "tank");
|
||||
FACTORY_PUMP = getRegisteredBlock(factory, "pump");
|
||||
FACTORY_CHUTE = getRegisteredBlock(factory, "chute");
|
||||
FACTORY_FLOOD_GATE = getRegisteredBlock(factory, "flood_gate");
|
||||
FACTORY_MINING_WELL = getRegisteredBlock(factory, "mining_well");
|
||||
FACTORY_AUTOWORKBENCH_ITEM = getRegisteredBlock(factory, "autoworkbench_item");
|
||||
FACTORY_DISTILLER = getRegisteredBlock(factory, "distiller");
|
||||
FACTORY_HEAT_EXCHANGE_START = getRegisteredBlock(factory, "heat_exchange_start");
|
||||
FACTORY_HEAT_EXCHANGE_MIDDLE = getRegisteredBlock(factory, "heat_exchange_middle");
|
||||
FACTORY_HEAT_EXCHANGE_END = getRegisteredBlock(factory, "heat_exchange_end");
|
||||
|
||||
String silicon = "silicon";
|
||||
SILICON_LASER = getRegisteredBlock(silicon, "laser");
|
||||
SILICON_TABLE_ASSEMBLY = getRegisteredBlock(silicon, "assembly_table");
|
||||
SILICON_TABLE_INTEGRATION = getRegisteredBlock(silicon, "integration_table");
|
||||
SILICON_TABLE_ADV_CRAFT = getRegisteredBlock(silicon, "advanced_crafting_table");
|
||||
SILICON_TABLE_CHARGING = getRegisteredBlock(silicon, "charging_table");
|
||||
SILICON_TABLE_PROGRAMMING = getRegisteredBlock(silicon, "programming_table");
|
||||
|
||||
if (DEBUG) {
|
||||
for (Block block : Block.REGISTRY) {
|
||||
ResourceLocation id = block.getRegistryName();
|
||||
if (id.getResourceDomain().startsWith("buildcraft")) {
|
||||
if (!SCANNED.contains(id.toString())) {
|
||||
BCLog.logger.warn("[api.blocks] Found a block " + id.toString() + " that was not registered with the API! Is this a bug?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Block getRegisteredBlock(String module, String regName) {
|
||||
String modid = "buildcraft" + module;
|
||||
Block block = Block.REGISTRY.getObject(new ResourceLocation(modid, regName));
|
||||
|
||||
if (block != Blocks.AIR) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.blocks] Found the block " + regName + " from the module " + module);
|
||||
SCANNED.add(modid + ":" + regName);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
if (DEBUG) {
|
||||
if (Loader.isModLoaded(modid)) {
|
||||
BCLog.logger.info("[api.blocks] Did not find the block " + regName + " despite the appropriate mod being loaded (" + modid + ")");
|
||||
} else {
|
||||
BCLog.logger.info("[api.blocks] Did not find the block " + regName + " probably because the mod is not loaded (" + modid + ")");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
package buildcraft.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
import buildcraft.api.core.BCDebugging;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
/** Stores all of BuildCraft's items, from all of its modules. If any of them have been disabled by the user (or it the
|
||||
* module is not installed) then they will be null. This is the equivalent of {@link Items} */
|
||||
public class BCItems {
|
||||
private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.items");
|
||||
|
||||
// The (optional) items in BC LIB, and has other rules for when they are enabled.
|
||||
public static final Item LIB_GUIDE;
|
||||
public static final Item LIB_DEBUGGER;
|
||||
|
||||
// BC Core
|
||||
public static final Item CORE_WRENCH;
|
||||
public static final Item CORE_DIAMOND_SHARD;
|
||||
public static final Item CORE_LIST;
|
||||
public static final Item CORE_MAP_LOCATION;
|
||||
public static final Item CORE_PAINTBRUSH;
|
||||
public static final Item CORE_GEAR_WOOD;
|
||||
public static final Item CORE_GEAR_STONE;
|
||||
public static final Item CORE_GEAR_IRON;
|
||||
public static final Item CORE_GEAR_GOLD;
|
||||
public static final Item CORE_GEAR_DIAMOND;
|
||||
public static final Item CORE_MARKER_CONNECTOR;
|
||||
public static final Item CORE_GOGGLES;
|
||||
|
||||
// BC Builders
|
||||
public static final Item BUILDERS_SINGLE_SCHEMATIC;
|
||||
public static final Item BUILDERS_SNAPSHOT;
|
||||
|
||||
// BC Energy
|
||||
public static final Item ENERGY_GLOB_OF_OIL;
|
||||
|
||||
// BC Factory
|
||||
public static final Item FACTORY_PLASTIC_SHEET;
|
||||
|
||||
// BC Robotics
|
||||
public static final Item ROBOTICS_REDSTONE_BOARD;
|
||||
public static final Item ROBOTICS_ROBOT;
|
||||
public static final Item ROBOTICS_ROBOT_GOGGLES;
|
||||
public static final Item ROBOTICS_PLUGGABLE_ROBOT_STATION;
|
||||
|
||||
// BC Silicon
|
||||
public static final Item SILICON_REDSTONE_CHIPSET;
|
||||
|
||||
// BC Transport
|
||||
public static final Item TRANSPORT_WATERPROOF;
|
||||
public static final Item TRANSPORT_GATE_COPIER;
|
||||
public static final Item TRANSPORT_PLUGGABLE_GATE;
|
||||
public static final Item TRANSPORT_PLUGGABLE_WIRE;
|
||||
public static final Item TRANSPORT_PLUGGABLE_BLOCKER;
|
||||
public static final Item TRANSPORT_PLUGGABLE_LENS;
|
||||
public static final Item TRANSPORT_PLUGGABLE_POWER_ADAPTOR;
|
||||
public static final Item TRANSPORT_PLUGGABLE_FACADE;
|
||||
|
||||
public static final Item TRANSPORT_PIPE_WOOD_ITEM;
|
||||
public static final Item TRANSPORT_PIPE_WOOD_FLUID;
|
||||
public static final Item TRANSPORT_PIPE_WOOD_POWER;
|
||||
|
||||
// ... a few more needed...
|
||||
|
||||
public static final Item TRANSPORT_PIPE_DIAMOND_ITEM;
|
||||
|
||||
// Set of items scanned
|
||||
private static final Set<String> SCANNED = DEBUG ? new HashSet<>() : null;
|
||||
|
||||
static {
|
||||
if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) {
|
||||
throw new RuntimeException("Accessed BC items too early! You can only use them from init onwards!");
|
||||
}
|
||||
final String lib = "lib";
|
||||
LIB_GUIDE = getRegisteredItem(lib, "guide");
|
||||
LIB_DEBUGGER = getRegisteredItem(lib, "debugger");
|
||||
|
||||
final String core = "core";
|
||||
CORE_WRENCH = getRegisteredItem(core, "wrench");
|
||||
CORE_DIAMOND_SHARD = getRegisteredItem(core, "diamond_shard");
|
||||
CORE_LIST = getRegisteredItem(core, "list");
|
||||
CORE_MAP_LOCATION = getRegisteredItem(core, "map_location");
|
||||
CORE_PAINTBRUSH = getRegisteredItem(core, "paintbrush");
|
||||
CORE_GEAR_WOOD = getRegisteredItem(core, "gear_wood");
|
||||
CORE_GEAR_STONE = getRegisteredItem(core, "gear_stone");
|
||||
CORE_GEAR_IRON = getRegisteredItem(core, "gear_iron");
|
||||
CORE_GEAR_GOLD = getRegisteredItem(core, "gear_gold");
|
||||
CORE_GEAR_DIAMOND = getRegisteredItem(core, "gear_diamond");
|
||||
CORE_MARKER_CONNECTOR = getRegisteredItem(core, "marker_connector");
|
||||
CORE_GOGGLES = getRegisteredItem(core, "goggles");
|
||||
|
||||
final String builders = "builders";
|
||||
BUILDERS_SINGLE_SCHEMATIC = getRegisteredItem(builders, "single_schematic");
|
||||
BUILDERS_SNAPSHOT = getRegisteredItem(builders, "snapshot");
|
||||
|
||||
final String energy = "energy";
|
||||
ENERGY_GLOB_OF_OIL = getRegisteredItem(energy, "glob_oil");
|
||||
|
||||
final String factory = "factory";
|
||||
FACTORY_PLASTIC_SHEET = getRegisteredItem(factory, "plastic_sheet");
|
||||
|
||||
final String robotics = "robotics";
|
||||
ROBOTICS_REDSTONE_BOARD = getRegisteredItem(robotics, "redstone_board");
|
||||
ROBOTICS_ROBOT = getRegisteredItem(robotics, "robot");
|
||||
ROBOTICS_PLUGGABLE_ROBOT_STATION = getRegisteredItem(robotics, "robot_station");
|
||||
ROBOTICS_ROBOT_GOGGLES = getRegisteredItem(robotics, "robot_goggles");
|
||||
|
||||
final String silicon = "silicon";
|
||||
SILICON_REDSTONE_CHIPSET = getRegisteredItem(silicon, "redstone_chipset");
|
||||
|
||||
final String transport = "transport";
|
||||
TRANSPORT_WATERPROOF = getRegisteredItem(transport, "waterproof");
|
||||
TRANSPORT_GATE_COPIER = getRegisteredItem(transport, "gate_copier");
|
||||
TRANSPORT_PLUGGABLE_GATE = getRegisteredItem(transport, "plug_gate");
|
||||
TRANSPORT_PLUGGABLE_WIRE = getRegisteredItem(transport, "plug_wire");
|
||||
TRANSPORT_PLUGGABLE_BLOCKER = getRegisteredItem(transport, "plug_blocker");
|
||||
TRANSPORT_PLUGGABLE_LENS = getRegisteredItem(transport, "plug_lens");
|
||||
TRANSPORT_PLUGGABLE_FACADE = getRegisteredItem(transport, "plug_facade");
|
||||
TRANSPORT_PLUGGABLE_POWER_ADAPTOR = getRegisteredItem(transport, "plug_power_adapter");
|
||||
TRANSPORT_PIPE_WOOD_ITEM = getRegisteredItem(transport, "pipe_wood_item");
|
||||
TRANSPORT_PIPE_WOOD_FLUID = getRegisteredItem(transport, "pipe_wood_fluid");
|
||||
TRANSPORT_PIPE_WOOD_POWER = getRegisteredItem(transport, "pipe_wood_power");
|
||||
|
||||
TRANSPORT_PIPE_DIAMOND_ITEM = getRegisteredItem(transport, "pipe_diamond_item");
|
||||
|
||||
if (DEBUG) {
|
||||
for (Item item : Item.REGISTRY) {
|
||||
ResourceLocation id = item.getRegistryName();
|
||||
if (id.getResourceDomain().startsWith("buildcraft")) {
|
||||
if (!SCANNED.contains(id.toString())) {
|
||||
BCLog.logger.warn("[api.items] Found an item " + id.toString() + " that was not registered with the API! Is this a bug?");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Item getRegisteredItem(String module, String regName) {
|
||||
String modid = "buildcraft" + module;
|
||||
Item item = Item.REGISTRY.getObject(new ResourceLocation(modid, regName));
|
||||
if (item != null) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.items] Found the item " + regName + " from the module " + module);
|
||||
SCANNED.add(modid + ":" + regName);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
if (DEBUG) {
|
||||
if (Loader.isModLoaded(modid)) {
|
||||
BCLog.logger.info("[api.items] Did not find the item " + regName + " despite the appropriate mod being loaded (" + modid + ")");
|
||||
} else {
|
||||
BCLog.logger.info("[api.items] Did not find the item " + regName + " probably because the mod is not loaded (" + modid + ")");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package buildcraft.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
public enum BCModules {
|
||||
LIB,
|
||||
// Base module for all BC.
|
||||
CORE,
|
||||
// Potentially optional modules for adding more BC functionality
|
||||
BUILDERS,
|
||||
ENERGY,
|
||||
FACTORY,
|
||||
ROBOTICS,
|
||||
SILICON,
|
||||
TRANSPORT,
|
||||
// Optional module for compatibility with other mods
|
||||
COMPAT;
|
||||
|
||||
public static final BCModules[] VALUES = values();
|
||||
|
||||
private static final String MODID_START = "buildcraft";
|
||||
private final String modid, part;
|
||||
|
||||
BCModules() {
|
||||
part = name().toLowerCase(Locale.ROOT);
|
||||
this.modid = MODID_START + part;
|
||||
}
|
||||
|
||||
public static void fmlPreInit() {}
|
||||
|
||||
public static boolean isBcMod(String modid) {
|
||||
if (!modid.startsWith(MODID_START)) return false;
|
||||
String post = modid.substring(MODID_START.length());
|
||||
for (BCModules module : VALUES) {
|
||||
if (post.equals(module.part)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return Loader.isModLoaded(modid);
|
||||
}
|
||||
|
||||
public String getModId() {
|
||||
return modid;
|
||||
}
|
||||
|
||||
static {
|
||||
if (!Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) {
|
||||
throw new RuntimeException("Accessed BC modules too early! You can only use them from construction onwards!");
|
||||
}
|
||||
for (BCModules module : values()) {
|
||||
if (module.isLoaded()) {
|
||||
BCLog.logger.info("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is loaded!");
|
||||
} else {
|
||||
BCLog.logger.warn("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is NOT loaded!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.core.BCDebugging;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
/** Provides a simple way to paint a single block, iterating through all {@link ICustomPaintHandler}'s that are
|
||||
* registered for the block. */
|
||||
public enum CustomPaintHelper {
|
||||
INSTANCE;
|
||||
|
||||
/* If you want to test your class-based rotation registration then add the system property
|
||||
* "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */
|
||||
private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.painting");
|
||||
|
||||
private final Map<Block, List<ICustomPaintHandler>> handlers = Maps.newIdentityHashMap();
|
||||
private final List<ICustomPaintHandler> allHandlers = Lists.newArrayList();
|
||||
|
||||
/** Registers a handler that will be called LAST for ALL blocks, if all other paint handlers have returned PASS or
|
||||
* none are registered for that block. */
|
||||
public void registerHandlerForAll(ICustomPaintHandler handler) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.painting] Adding a paint handler for ALL blocks (" + handler.getClass() + ")");
|
||||
}
|
||||
allHandlers.add(handler);
|
||||
}
|
||||
|
||||
/** Register's a paint handler for every class of a given block. */
|
||||
public void registerHandlerForAll(Class<? extends Block> blockClass, ICustomPaintHandler handler) {
|
||||
for (Block block : Block.REGISTRY) {
|
||||
Class<? extends Block> foundClass = block.getClass();
|
||||
if (blockClass.isAssignableFrom(foundClass)) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.painting] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass);
|
||||
}
|
||||
registerHandlerInternal(block, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerHandler(Block block, ICustomPaintHandler handler) {
|
||||
if (registerHandlerInternal(block, handler)) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.painting] Setting a paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")");
|
||||
}
|
||||
} else if (DEBUG) {
|
||||
BCLog.logger.info("[api.painting] Adding another paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerHandlerInternal(Block block, ICustomPaintHandler handler) {
|
||||
if (!handlers.containsKey(block)) {
|
||||
List<ICustomPaintHandler> forBlock = Lists.newArrayList();
|
||||
forBlock.add(handler);
|
||||
handlers.put(block, forBlock);
|
||||
return true;
|
||||
} else {
|
||||
handlers.get(block).add(handler);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Attempts to paint a block at the given position. Basically iterates through all registered paint handlers. */
|
||||
public EnumActionResult attemptPaintBlock(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paint) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof ICustomPaintHandler) {
|
||||
return ((ICustomPaintHandler) block).attemptPaint(world, pos, state, hitPos, hitSide, paint);
|
||||
}
|
||||
List<ICustomPaintHandler> custom = handlers.get(block);
|
||||
if (custom == null || custom.isEmpty()) {
|
||||
return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint);
|
||||
}
|
||||
for (ICustomPaintHandler handler : custom) {
|
||||
EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint);
|
||||
if (result != EnumActionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint);
|
||||
}
|
||||
|
||||
private EnumActionResult defaultAttemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, EnumFacing hitSide, @Nullable EnumDyeColor paint) {
|
||||
for (ICustomPaintHandler handler : allHandlers) {
|
||||
EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint);
|
||||
if (result != EnumActionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (paint == null) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
Block b = state.getBlock();
|
||||
if (b.recolorBlock(world, pos, hitSide, paint)) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.core.BCDebugging;
|
||||
import buildcraft.api.core.BCLog;
|
||||
|
||||
public enum CustomRotationHelper {
|
||||
INSTANCE;
|
||||
|
||||
/* If you want to test your class-based rotation registration then add the system property
|
||||
* "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */
|
||||
private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.rotation");
|
||||
|
||||
private final Map<Block, List<ICustomRotationHandler>> handlers = Maps.newIdentityHashMap();
|
||||
|
||||
public void registerHandlerForAll(Class<? extends Block> blockClass, ICustomRotationHandler handler) {
|
||||
for (Block block : Block.REGISTRY) {
|
||||
Class<? extends Block> foundClass = block.getClass();
|
||||
if (blockClass.isAssignableFrom(foundClass)) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.rotation] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass);
|
||||
}
|
||||
registerHandlerInternal(block, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerHandler(Block block, ICustomRotationHandler handler) {
|
||||
if (registerHandlerInternal(block, handler)) {
|
||||
if (DEBUG) {
|
||||
BCLog.logger.info("[api.rotation] Setting a rotation handler for block " + block.getRegistryName());
|
||||
}
|
||||
} else if (DEBUG) {
|
||||
BCLog.logger.info("[api.rotation] Adding another rotation handler for block " + block.getRegistryName());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerHandlerInternal(Block block, ICustomRotationHandler handler) {
|
||||
if (!handlers.containsKey(block)) {
|
||||
List<ICustomRotationHandler> forBlock = Lists.newArrayList();
|
||||
forBlock.add(handler);
|
||||
handlers.put(block, forBlock);
|
||||
return true;
|
||||
} else {
|
||||
handlers.get(block).add(handler);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public EnumActionResult attemptRotateBlock(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof ICustomRotationHandler) {
|
||||
return ((ICustomRotationHandler) block).attemptRotation(world, pos, state, sideWrenched);
|
||||
}
|
||||
if (!handlers.containsKey(block)) return EnumActionResult.PASS;
|
||||
for (ICustomRotationHandler handler : handlers.get(block)) {
|
||||
EnumActionResult result = handler.attemptRotation(world, pos, state, sideWrenched);
|
||||
if (result != EnumActionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Provides a way to paint blocks from any position. You can either implement this on a block, or register an instance
|
||||
* for a block with {@link CustomPaintHelper} */
|
||||
public interface ICustomPaintHandler {
|
||||
/** Attempts to paint the given block. This can also only paint a specific part of the block (as the hit position is
|
||||
* given).
|
||||
*
|
||||
* @param world The world that the block is contained within.
|
||||
* @param pos The position of the block.
|
||||
* @param state The current state of the block.
|
||||
* @param hitPos The absolute hit position of the paintbrush, relative the world's origin.
|
||||
* @param hitSide The side of the block that was hit.
|
||||
* @param paintColour The paint colour to attempt to paint with, null if the paint should be cleared (so if this was
|
||||
* a stained glass block, and null was passed, this would set it to a normal, clear, non-stained glass
|
||||
* block.
|
||||
* @return The result of attempting to paint. SUCCESS means that you changed the block from before to a new value,
|
||||
* FAIL means you COULD have handled the block, but it was already painted to that colour, or PASS if you
|
||||
* have no idea how to handle the block in question. */
|
||||
EnumActionResult attemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paintColour);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICustomRotationHandler {
|
||||
EnumActionResult attemptRotation(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blocks")
|
||||
package buildcraft.api.blocks;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
public interface IRedstoneBoard<T> {
|
||||
|
||||
void updateBoard(T container);
|
||||
|
||||
RedstoneBoardNBT<?> getNBTHandler();
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public abstract class RedstoneBoardNBT<T> {
|
||||
|
||||
private static Random rand = new Random();
|
||||
|
||||
public abstract String getID();
|
||||
|
||||
public abstract void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean advanced);
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract IRedstoneBoard<T> create(NBTTagCompound nbt, T object);
|
||||
|
||||
public abstract String getItemModelLocation();
|
||||
|
||||
public void createBoard(NBTTagCompound nbt) {
|
||||
nbt.setString("id", getID());
|
||||
}
|
||||
|
||||
public int getParameterNumber(NBTTagCompound nbt) {
|
||||
if (!nbt.hasKey("parameters")) {
|
||||
return 0;
|
||||
} else {
|
||||
return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount();
|
||||
}
|
||||
}
|
||||
|
||||
public float nextFloat(int difficulty) {
|
||||
return 1F - (float) Math.pow(rand.nextFloat(), 1F / difficulty);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class RedstoneBoardRegistry {
|
||||
|
||||
public static RedstoneBoardRegistry instance;
|
||||
|
||||
/** Register a redstone board type.
|
||||
*
|
||||
* @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information.
|
||||
* @param microJoules MJ price of the board, in micro MJ. */
|
||||
public abstract void registerBoardType(RedstoneBoardNBT<?> redstoneBoardNBT, long microJoules);
|
||||
|
||||
public abstract void setEmptyRobotBoard(RedstoneBoardRobotNBT redstoneBoardNBT);
|
||||
|
||||
public abstract RedstoneBoardRobotNBT getEmptyRobotBoard();
|
||||
|
||||
public abstract RedstoneBoardNBT<?> getRedstoneBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract RedstoneBoardNBT<?> getRedstoneBoard(String id);
|
||||
|
||||
public abstract Collection<RedstoneBoardNBT<?>> getAllBoardNBTs();
|
||||
|
||||
public abstract long getPowerCost(RedstoneBoardNBT<?> board);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RedstoneBoardRobot extends AIRobot implements IRedstoneBoard<EntityRobotBase> {
|
||||
|
||||
public RedstoneBoardRobot(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract RedstoneBoardRobotNBT getNBTHandler();
|
||||
|
||||
@Override
|
||||
public final void updateBoard(EntityRobotBase container) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLoadFromNBT() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT<EntityRobotBase> {
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return create(robot);
|
||||
}
|
||||
|
||||
public abstract RedstoneBoardRobot create(EntityRobotBase robot);
|
||||
|
||||
public abstract ResourceLocation getRobotTexture();
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|boards")
|
||||
package buildcraft.api.boards;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,112 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Provides a way to quickly enable or disable certain debug conditions via VM arguments or whether the client/server
|
||||
* is in a dev environment */
|
||||
public class BCDebugging {
|
||||
public enum DebugStatus {
|
||||
NONE,
|
||||
ENABLE,
|
||||
LOGGING_ONLY,
|
||||
ALL
|
||||
}
|
||||
|
||||
enum DebugLevel {
|
||||
LOG,
|
||||
COMPLEX;
|
||||
|
||||
final String name = name().toLowerCase(Locale.ROOT);
|
||||
boolean isAllOn;
|
||||
}
|
||||
|
||||
private static final DebugStatus DEBUG_STATUS;
|
||||
|
||||
static {
|
||||
// Basically we enable debugging for the dev-environment, and disable everything for normal players.
|
||||
// However if you provide VM arguments then the behaviour changes somewhat:
|
||||
// (VM argument is "-Dbuildcraft.debug=...")
|
||||
// - "enable" Enables debugging even if you are not in a dev environment
|
||||
// - "disable" Disables ALL debugging (and doesn't output any messages even in the dev environment)
|
||||
// - "log" Major debug options are turned on. Registry setup + API usage etc
|
||||
// - "all" All possible debug options are turned on. Lots of spam. Not recommended.
|
||||
|
||||
String value = System.getProperty("buildcraft.debug");
|
||||
if ("enable".equals(value)) DEBUG_STATUS = DebugStatus.ENABLE;
|
||||
else if ("all".equals(value)) DEBUG_STATUS = DebugStatus.ALL;
|
||||
else if ("disable".equals(value)) {
|
||||
// let people disable the messages if they are in a dev environment but don't want messages.
|
||||
DEBUG_STATUS = DebugStatus.NONE;
|
||||
} else if ("log".equals(value)) {
|
||||
// Some debugging options are more than just logging, so we will differentiate between them
|
||||
DEBUG_STATUS = DebugStatus.LOGGING_ONLY;
|
||||
} else if (World.class.getName().contains("World")) {
|
||||
// Dev environment
|
||||
DEBUG_STATUS = DebugStatus.ENABLE;
|
||||
} else {
|
||||
// Most likely a built jar - don't spam people with info they probably don't need
|
||||
DEBUG_STATUS = DebugStatus.NONE;
|
||||
}
|
||||
|
||||
if (DEBUG_STATUS == DebugStatus.ALL) {
|
||||
BCLog.logger.info("[debugger] Debugging automatically enabled for ALL of buildcraft. Prepare for log spam.");
|
||||
} else if (DEBUG_STATUS == DebugStatus.LOGGING_ONLY) {
|
||||
BCLog.logger.info("[debugger] Debugging automatically enabled for some non-spammy parts of buildcraft.");
|
||||
} else if (DEBUG_STATUS == DebugStatus.ENABLE) {
|
||||
BCLog.logger.info("[debugger] Debugging not automatically enabled for all of buildcraft. Logging all possible debug options.");
|
||||
BCLog.logger.info(" To enable it for only logging messages add \"-Dbuildcraft.debug=log\" to your launch VM arguments");
|
||||
BCLog.logger.info(" To enable it for ALL debugging \"-Dbuildcraft.debug=all\" to your launch VM arguments");
|
||||
BCLog.logger.info(" To remove this message and all future ones add \"-Dbuildcraft.debug=disable\" to your launch VM arguments");
|
||||
}
|
||||
|
||||
DebugLevel.COMPLEX.isAllOn = DEBUG_STATUS == DebugStatus.ALL;
|
||||
DebugLevel.LOG.isAllOn = DEBUG_STATUS == DebugStatus.ALL || DEBUG_STATUS == DebugStatus.LOGGING_ONLY;
|
||||
}
|
||||
|
||||
public static boolean shouldDebugComplex(String string) {
|
||||
return shouldDebug(string, DebugLevel.COMPLEX);
|
||||
}
|
||||
|
||||
public static boolean shouldDebugLog(String string) {
|
||||
return shouldDebug(string, DebugLevel.LOG);
|
||||
}
|
||||
|
||||
private static boolean shouldDebug(String option, DebugLevel type) {
|
||||
String prop = getProp(option);
|
||||
String actual = System.getProperty(prop);
|
||||
if ("false".equals(actual)) {
|
||||
BCLog.logger.info("[debugger] Debugging manually disabled for \"" + option + "\" (" + type + ").");
|
||||
return false;
|
||||
} else if ("true".equals(actual)) {
|
||||
BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ").");
|
||||
return true;
|
||||
}
|
||||
if (type.isAllOn) {
|
||||
BCLog.logger.info("[debugger] Debugging automatically enabled for \"" + option + "\" (" + type + ").");
|
||||
return true;
|
||||
}
|
||||
if ("complex".equals(actual) || type.name.equals(actual)) {
|
||||
BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ").");
|
||||
return true;
|
||||
} else {
|
||||
StringBuilder log = new StringBuilder();
|
||||
log.append("[debugger] To enable debugging for ");
|
||||
log.append(option);
|
||||
log.append(" add the option \"-D");
|
||||
log.append(prop);
|
||||
log.append("=true\" to your launch config as a VM argument (").append(type).append(").");
|
||||
BCLog.logger.info(log);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getProp(String string) {
|
||||
return "buildcraft." + string + ".debug";
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class BCLog {
|
||||
public static final Logger logger = LogManager.getLogger("BuildCraft");
|
||||
|
||||
/** Deactivate constructor */
|
||||
private BCLog() {}
|
||||
|
||||
@Deprecated
|
||||
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
|
||||
logErrorAPI(error, classFile);
|
||||
}
|
||||
|
||||
public static void logErrorAPI(Throwable error, Class<?> classFile) {
|
||||
StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: ");
|
||||
msg.append(error);
|
||||
StackTraceElement[] stackTrace = error.getStackTrace();
|
||||
if (stackTrace.length > 0) {
|
||||
msg.append(", ").append(stackTrace[0]);
|
||||
}
|
||||
|
||||
logger.log(Level.ERROR, msg.toString());
|
||||
|
||||
if (classFile != null) {
|
||||
msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain()
|
||||
.getCodeSource().getLocation());
|
||||
logger.log(Level.ERROR, msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getVersion() {
|
||||
return BuildCraftAPI.getVersion();
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
public final class BuildCraftAPI {
|
||||
public static IFakePlayerProvider fakePlayerProvider;
|
||||
|
||||
public static final Set<Block> softBlocks = Sets.newHashSet();
|
||||
public static final HashMap<String, IWorldProperty> worldProperties = Maps.newHashMap();
|
||||
|
||||
/** Deactivate constructor */
|
||||
private BuildCraftAPI() {}
|
||||
|
||||
public static String getVersion() {
|
||||
ModContainer container = Loader.instance().getIndexedModList().get("buildcraftlib");
|
||||
if (container != null) {
|
||||
return container.getDisplayVersion();
|
||||
}
|
||||
return "UNKNOWN VERSION";
|
||||
}
|
||||
|
||||
public static IWorldProperty getWorldProperty(String name) {
|
||||
return worldProperties.get(name);
|
||||
}
|
||||
|
||||
public static void registerWorldProperty(String name, IWorldProperty property) {
|
||||
if (worldProperties.containsKey(name)) {
|
||||
BCLog.logger.warn("The WorldProperty key '" + name + "' is being overridden with " + property.getClass().getSimpleName() + "!");
|
||||
}
|
||||
worldProperties.put(name, property);
|
||||
}
|
||||
|
||||
public static boolean isSoftBlock(World world, BlockPos pos) {
|
||||
return worldProperties.get("soft").get(world, pos);
|
||||
}
|
||||
|
||||
public static ResourceLocation nameToResourceLocation(String name) {
|
||||
if (name.indexOf(':') > 0) return new ResourceLocation(name);
|
||||
ModContainer modContainer = Loader.instance().activeModContainer();
|
||||
if (modContainer == null) {
|
||||
throw new IllegalStateException("Illegal recipe name " + name + ". Provide domain id to register it correctly.");
|
||||
}
|
||||
return new ResourceLocation(modContainer.getModId(), name);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
||||
public class CapabilitiesHelper {
|
||||
public static <T> void registerCapability(Class<T> clazz) {
|
||||
CapabilityManager.INSTANCE.register(clazz, new VoidStorage<>(), () -> {
|
||||
throw new IllegalStateException("You must create your own instances!");
|
||||
});
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T> Capability<T> ensureRegistration(Capability<T> cap, Class<T> clazz) {
|
||||
if (cap == null) {
|
||||
throw new Error("Capability registration failed for " + clazz);
|
||||
}
|
||||
return cap;
|
||||
}
|
||||
|
||||
public static class VoidStorage<T> implements Capability.IStorage<T> {
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<T> capability, T instance, EnumFacing side) {
|
||||
throw new IllegalStateException("You must create your own instances!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<T> capability, T instance, EnumFacing side, NBTBase nbt) {
|
||||
throw new IllegalStateException("You must create your own instances!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/** Use minecraft's EnumDyeColor in as many places as possible. */
|
||||
@Deprecated
|
||||
public enum EnumColor implements IStringSerializable {
|
||||
|
||||
BLACK,
|
||||
RED,
|
||||
GREEN,
|
||||
BROWN,
|
||||
BLUE,
|
||||
PURPLE,
|
||||
CYAN,
|
||||
LIGHT_GRAY,
|
||||
GRAY,
|
||||
PINK,
|
||||
LIME,
|
||||
YELLOW,
|
||||
LIGHT_BLUE,
|
||||
MAGENTA,
|
||||
ORANGE,
|
||||
WHITE;
|
||||
|
||||
public static final EnumColor[] VALUES = values();
|
||||
public static final String[] DYES = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray",
|
||||
"dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
|
||||
public static final String[] NAMES = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow",
|
||||
"LightBlue", "Magenta", "Orange", "White" };
|
||||
public static final int[] DARK_HEX = { 0x2D2D2D, 0xA33835, 0x394C1E, 0x5C3A24, 0x3441A2, 0x843FBF, 0x36809E, 0x888888, 0x444444, 0xE585A0,
|
||||
0x3FAA36, 0xCFC231, 0x7F9AD1, 0xFF64FF, 0xFF6A00, 0xFFFFFF };
|
||||
public static final int[] LIGHT_HEX = { 0x181414, 0xBE2B27, 0x007F0E, 0x89502D, 0x253193, 0x7e34bf, 0x299799, 0xa0a7a7, 0x7A7A7A, 0xD97199,
|
||||
0x39D52E, 0xFFD91C, 0x66AAFF, 0xD943C6, 0xEA7835, 0xe4e4e4 };
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static ResourceLocation iconSheet;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static TextureAtlasSprite[] brushSprites;
|
||||
|
||||
public int getDarkHex() {
|
||||
return DARK_HEX[ordinal()];
|
||||
}
|
||||
|
||||
public int getLightHex() {
|
||||
return LIGHT_HEX[ordinal()];
|
||||
}
|
||||
|
||||
public static EnumColor fromId(int id) {
|
||||
if (id < 0 || id >= VALUES.length) {
|
||||
return WHITE;
|
||||
}
|
||||
return VALUES[id];
|
||||
}
|
||||
|
||||
public static EnumColor fromDye(String dyeTag) {
|
||||
for (int id = 0; id < DYES.length; id++) {
|
||||
if (DYES[id].equals(dyeTag)) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnumColor fromName(String name) {
|
||||
for (int id = 0; id < NAMES.length; id++) {
|
||||
if (NAMES[id].equals(name)) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EnumColor getRand() {
|
||||
return VALUES[new Random().nextInt(VALUES.length)];
|
||||
}
|
||||
|
||||
public EnumColor getNext() {
|
||||
EnumColor next = VALUES[(ordinal() + 1) % VALUES.length];
|
||||
return next;
|
||||
}
|
||||
|
||||
public EnumColor getPrevious() {
|
||||
EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length];
|
||||
return previous;
|
||||
}
|
||||
|
||||
public EnumColor inverse() {
|
||||
return EnumColor.VALUES[15 - ordinal()];
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getBasicTag() {
|
||||
return name().replace("_", ".").toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAMES[ordinal()];
|
||||
}
|
||||
|
||||
public String getLocalizedName() {
|
||||
return I18n.translateToLocal(getTag());
|
||||
}
|
||||
|
||||
public String getDye() {
|
||||
return DYES[ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = name().replace("_", " ");
|
||||
String[] words = s.split(" ");
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String word : words) {
|
||||
b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" ");
|
||||
}
|
||||
return b.toString().trim();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerSprites(TextureAtlasSprite[] sprites) {
|
||||
brushSprites = sprites;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite() {
|
||||
return brushSprites[ordinal()];
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 SpaceToad and the BuildCraft team
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
|
||||
package buildcraft.api.core;
|
||||
|
||||
public enum EnumHandlerPriority implements Comparable<EnumHandlerPriority> {
|
||||
HIGHEST,
|
||||
HIGH,
|
||||
NORMAL,
|
||||
LOW,
|
||||
LOWEST;
|
||||
|
||||
public static final EnumHandlerPriority[] VALUES = values();
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumPipePart implements IStringSerializable {
|
||||
DOWN(EnumFacing.DOWN),
|
||||
UP(EnumFacing.UP),
|
||||
NORTH(EnumFacing.NORTH),
|
||||
SOUTH(EnumFacing.SOUTH),
|
||||
WEST(EnumFacing.WEST),
|
||||
EAST(EnumFacing.EAST),
|
||||
/** CENTER, UNKNOWN and ALL are all valid uses of this. */
|
||||
CENTER(null);
|
||||
|
||||
public static final EnumPipePart[] VALUES = values();
|
||||
public static final EnumPipePart[] FACES;
|
||||
public static final EnumPipePart[] HORIZONTALS;
|
||||
|
||||
private static final Map<EnumFacing, EnumPipePart> facingMap = Maps.newEnumMap(EnumFacing.class);
|
||||
private static final Map<String, EnumPipePart> nameMap = Maps.newHashMap();
|
||||
private static final int MAX_VALUES = values().length;
|
||||
|
||||
public final EnumFacing face;
|
||||
|
||||
static {
|
||||
for (EnumPipePart part : values()) {
|
||||
nameMap.put(part.name(), part);
|
||||
if (part.face != null) facingMap.put(part.face, part);
|
||||
}
|
||||
FACES = fromFacingArray(EnumFacing.VALUES);
|
||||
HORIZONTALS = fromFacingArray(EnumFacing.HORIZONTALS);
|
||||
}
|
||||
|
||||
private static EnumPipePart[] fromFacingArray(EnumFacing... faces) {
|
||||
EnumPipePart[] arr = new EnumPipePart[faces.length];
|
||||
for (int i = 0; i < faces.length; i++) {
|
||||
arr[i] = fromFacing(faces[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static int ordinal(EnumFacing face) {
|
||||
return face == null ? 6 : face.ordinal();
|
||||
}
|
||||
|
||||
public static EnumPipePart fromFacing(EnumFacing face) {
|
||||
if (face == null) {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
return facingMap.get(face);
|
||||
}
|
||||
|
||||
public static EnumPipePart[] validFaces() {
|
||||
return FACES;
|
||||
}
|
||||
|
||||
public static EnumPipePart fromMeta(int meta) {
|
||||
if (meta < 0 || meta >= MAX_VALUES) {
|
||||
return EnumPipePart.CENTER;
|
||||
}
|
||||
return VALUES[meta];
|
||||
}
|
||||
|
||||
EnumPipePart(EnumFacing face) {
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
if (face == null) return 6;
|
||||
return face.getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public EnumPipePart next() {
|
||||
switch (this) {
|
||||
case DOWN:
|
||||
return EAST;
|
||||
case EAST:
|
||||
return NORTH;
|
||||
case NORTH:
|
||||
return SOUTH;
|
||||
case SOUTH:
|
||||
return UP;
|
||||
case UP:
|
||||
return WEST;
|
||||
case WEST:
|
||||
return DOWN;
|
||||
default:
|
||||
return DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public EnumPipePart opposite() {
|
||||
if (this == CENTER) {
|
||||
return CENTER;
|
||||
}
|
||||
return fromFacing(face.getOpposite());
|
||||
}
|
||||
|
||||
public static EnumPipePart readFromNBT(NBTBase base) {
|
||||
if (base == null) {
|
||||
return CENTER;
|
||||
}
|
||||
if (base instanceof NBTTagString) {
|
||||
NBTTagString nbtString = (NBTTagString) base;
|
||||
String string = nbtString.getString();
|
||||
return nameMap.getOrDefault(string, CENTER);
|
||||
} else {
|
||||
byte ord = ((NBTPrimitive) base).getByte();
|
||||
if (ord < 0 || ord > 6) {
|
||||
return CENTER;
|
||||
}
|
||||
return values()[ord];
|
||||
}
|
||||
}
|
||||
|
||||
public NBTBase writeToNBT() {
|
||||
return new NBTTagString(name());
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/** To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers. */
|
||||
public interface IAreaProvider {
|
||||
BlockPos min();
|
||||
|
||||
BlockPos max();
|
||||
|
||||
/** Remove from the world all objects used to define the area. */
|
||||
void removeFromWorld();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IBox extends IZone {
|
||||
IBox expand(int amount);
|
||||
|
||||
IBox contract(int amount);
|
||||
|
||||
BlockPos min();
|
||||
|
||||
BlockPos max();
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
public interface IEngineType {
|
||||
String getItemModelLocation();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
* <p>
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
package buildcraft.api.core;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
public interface IFakePlayerProvider {
|
||||
/**
|
||||
* Returns the generic buildcraft fake player. Note that you shouldn't use this anymore, as you should store the
|
||||
* UUID of the real player who created the block or entity that calls this.
|
||||
*/
|
||||
@Deprecated
|
||||
FakePlayer getBuildCraftPlayer(WorldServer world);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param profile The owner's profile.
|
||||
* @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this
|
||||
* player is left around as it holds a reference to the world object.
|
||||
*/
|
||||
FakePlayer getFakePlayer(WorldServer world, GameProfile profile);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param profile The owner's profile.
|
||||
* @param pos
|
||||
* @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this
|
||||
* player is left around as it holds a reference to the world object.
|
||||
*/
|
||||
FakePlayer getFakePlayer(WorldServer world, GameProfile profile, BlockPos pos);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
* <p/>
|
||||
* 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.fluids.FluidStack;
|
||||
|
||||
public interface IFluidFilter {
|
||||
|
||||
boolean matches(FluidStack fluid);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
/** A version of {@link IFluidHandler} that can drain a fluid that a fluid filter accepts. */
|
||||
public interface IFluidHandlerAdv extends IFluidHandler {
|
||||
/** Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler.
|
||||
*
|
||||
* @param filter A filter to filter the possible fluids that can be extracted.
|
||||
* @param maxDrain The maximum amount of fluid to drain
|
||||
* @param doDrain If false, drain will only be simulated.
|
||||
* @return FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained. */
|
||||
@Nullable
|
||||
FluidStack drain(IFluidFilter filter, int maxDrain, boolean doDrain);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IInvSlot {
|
||||
/** Returns the slot number of the underlying Inventory.
|
||||
*
|
||||
* @return the slot number */
|
||||
int getIndex();
|
||||
|
||||
boolean canPutStackInSlot(ItemStack stack);
|
||||
|
||||
boolean canTakeStackFromSlot(ItemStack stack);
|
||||
|
||||
boolean isItemValidForSlot(ItemStack stack);
|
||||
|
||||
ItemStack decreaseStackInSlot(int amount);
|
||||
|
||||
ItemStack getStackInSlot();
|
||||
|
||||
void setStackInSlot(ItemStack stack);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import buildcraft.api.items.IMapLocation.MapLocationType;
|
||||
|
||||
/** To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers. */
|
||||
public interface IPathProvider {
|
||||
/** @return The completed path. This should loop back onto itself (The last position is the same as the first
|
||||
* position) if you are {@link MapLocationType#PATH_REPEATING} */
|
||||
List<BlockPos> getPath();
|
||||
|
||||
/** Remove from the world all objects used to define the path. */
|
||||
void removeFromWorld();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package buildcraft.api.core;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
/** Defines an entity or tile that is owned by a specific player. */
|
||||
public interface IPlayerOwned {
|
||||
GameProfile getOwner();
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
* <p/>
|
||||
* 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 javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/** This interface provides a convenient means of dealing with entire classes of items without having to specify each
|
||||
* item individually. */
|
||||
public interface IStackFilter {
|
||||
|
||||
/** Check to see if a given stack matches this filter.
|
||||
*
|
||||
* @param stack The stack to test. stack.isEmpty will always return false.
|
||||
* @return True if it does match, false otherwise. */
|
||||
boolean matches(@Nonnull ItemStack stack);
|
||||
|
||||
/**
|
||||
* Returns example stack to match this filter
|
||||
*/
|
||||
default NonNullList<ItemStack> getExamples() {
|
||||
return NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IWorldProperty {
|
||||
boolean get(World world, BlockPos pos);
|
||||
|
||||
void clear();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public interface IZone {
|
||||
/** Returns the smallest possible distance that the index would have to be changed by in order for
|
||||
* {@link #contains(Vec3d)} to return true. If the position is already inside then this will return 0 */
|
||||
double distanceTo(BlockPos index);
|
||||
|
||||
/** Returns {@link #distanceTo(BlockPos)} but squared. Usually this will be quicker to calculate. */
|
||||
double distanceToSquared(BlockPos index);
|
||||
|
||||
/** Returns true if the point is enclosed by this zone, such that none of the coordinates lie outside the range
|
||||
* specified by this zone. */
|
||||
boolean contains(Vec3d point);
|
||||
|
||||
/** Gets a random position that {@link #contains(Vec3d)} will return true. */
|
||||
BlockPos getRandomBlockPos(Random rand);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 SpaceToad and the BuildCraft team
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
|
||||
* distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/
|
||||
*/
|
||||
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Indicates that we failed to load from NBT or some other file.
|
||||
*/
|
||||
public class InvalidInputDataException extends IOException {
|
||||
public InvalidInputDataException() {
|
||||
}
|
||||
|
||||
public InvalidInputDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidInputDataException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InvalidInputDataException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class JavaTools {
|
||||
private JavaTools() {
|
||||
|
||||
}
|
||||
|
||||
public static <T> T[] concat(T[] first, T[] second) {
|
||||
T[] result = Arrays.copyOf(first, first.length + second.length);
|
||||
System.arraycopy(second, 0, result, first.length, second.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int[] concat(int[] first, int[] second) {
|
||||
int[] result = Arrays.copyOf(first, first.length + second.length);
|
||||
System.arraycopy(second, 0, result, first.length, second.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float[] concat(float[] first, float[] second) {
|
||||
float[] result = Arrays.copyOf(first, first.length + second.length);
|
||||
System.arraycopy(second, 0, result, first.length, second.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String surroundWithQuotes(String stringToSurroundWithQuotes) {
|
||||
return String.format("\"%s\"", stringToSurroundWithQuotes);
|
||||
}
|
||||
|
||||
public static String stripSurroundingQuotes(String stringToStripQuotes) {
|
||||
return stringToStripQuotes.replaceAll("^\"|\"$", "");
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Provides a way of tracking time in the world, without requiring manual ticking. */
|
||||
public class SafeTimeTracker {
|
||||
|
||||
private long lastMark = Long.MIN_VALUE;
|
||||
private long duration = -1;
|
||||
private long randomRange = 0;
|
||||
private long lastRandomDelay = 0;
|
||||
private long internalDelay = 1;
|
||||
|
||||
/** Only use this if the delay time changes (say, if you use this to determine when a refining should be complete */
|
||||
public SafeTimeTracker() {
|
||||
|
||||
}
|
||||
|
||||
public SafeTimeTracker(long delay) {
|
||||
internalDelay = delay;
|
||||
}
|
||||
|
||||
/** In many situations, it is a bad idea to have all objects of the same kind to be waiting for the exact same
|
||||
* amount of time, as that can lead to some situation where they're all synchronized and got to work all at the same
|
||||
* time. When created with a random range, the mark that is set when reaching the expect delay will be added with a
|
||||
* random number between [0, range[, meaning that the event will take between 0 and range more tick to run. */
|
||||
public SafeTimeTracker(long delay, long random) {
|
||||
internalDelay = delay;
|
||||
randomRange = random;
|
||||
}
|
||||
|
||||
/** Return true if the internal delay has passed since last time marked was called successfully. */
|
||||
public boolean markTimeIfDelay(World world) {
|
||||
return markTimeIfDelay(world, internalDelay);
|
||||
}
|
||||
|
||||
/** 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.getTotalWorldTime();
|
||||
|
||||
if (currentTime < lastMark) {
|
||||
lastMark = currentTime;
|
||||
return false;
|
||||
} else if (lastMark + delay + lastRandomDelay <= currentTime) {
|
||||
duration = currentTime - lastMark;
|
||||
lastMark = currentTime;
|
||||
lastRandomDelay = (int) (Math.random() * randomRange);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public long durationOfLastDelay() {
|
||||
return duration > 0 ? duration : 0;
|
||||
}
|
||||
|
||||
public void markTime(World world) {
|
||||
lastMark = world.getTotalWorldTime();
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/** This class is used whenever stacks needs to be stored as keys. */
|
||||
public final class StackKey {
|
||||
public final ItemStack stack;
|
||||
public final FluidStack fluidStack;
|
||||
|
||||
public StackKey(FluidStack fluidStack) {
|
||||
this(null, fluidStack);
|
||||
}
|
||||
|
||||
public StackKey(ItemStack stack) {
|
||||
this(stack, null);
|
||||
}
|
||||
|
||||
public StackKey(ItemStack stack, FluidStack fluidStack) {
|
||||
this.stack = stack;
|
||||
this.fluidStack = fluidStack;
|
||||
}
|
||||
|
||||
public static StackKey stack(Item item, int amount, int damage) {
|
||||
return new StackKey(new ItemStack(item, amount, damage));
|
||||
}
|
||||
|
||||
public static StackKey stack(Block block, int amount, int damage) {
|
||||
return new StackKey(new ItemStack(block, amount, damage));
|
||||
}
|
||||
|
||||
public static StackKey stack(Item item) {
|
||||
return new StackKey(new ItemStack(item, 1, 0));
|
||||
}
|
||||
|
||||
public static StackKey stack(Block block) {
|
||||
return new StackKey(new ItemStack(block, 1, 0));
|
||||
}
|
||||
|
||||
public static StackKey stack(ItemStack itemStack) {
|
||||
return new StackKey(itemStack);
|
||||
}
|
||||
|
||||
public static StackKey fluid(Fluid fluid, int amount) {
|
||||
return new StackKey(new FluidStack(fluid, amount));
|
||||
}
|
||||
|
||||
public static StackKey fluid(Fluid fluid) {
|
||||
return new StackKey(new FluidStack(fluid, 1000));
|
||||
}
|
||||
|
||||
public static StackKey fluid(FluidStack fluidStack) {
|
||||
return new StackKey(fluidStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || o.getClass() != StackKey.class) {
|
||||
return false;
|
||||
}
|
||||
StackKey k = (StackKey) o;
|
||||
if ((stack == null ^ k.stack == null) || (fluidStack == null ^ k.fluidStack == null)) {
|
||||
return false;
|
||||
}
|
||||
if (stack != null) {
|
||||
if (stack.getItem() != k.stack.getItem() || stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() || !objectsEqual(
|
||||
stack.getTagCompound(), k.stack.getTagCompound())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (fluidStack != null) {
|
||||
if (!fluidStack.isFluidEqual(k.fluidStack) || fluidStack.amount != k.fluidStack.amount) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 7;
|
||||
if (stack != null) {
|
||||
result = 31 * result + stack.getItem().hashCode();
|
||||
result = 31 * result + stack.getItemDamage();
|
||||
result = 31 * result + objectHashCode(stack.getTagCompound());
|
||||
}
|
||||
result = 31 * result + 7;
|
||||
if (fluidStack != null) {
|
||||
result = 31 * result + fluidStack.getFluid().getName().hashCode();
|
||||
result = 31 * result + fluidStack.amount;
|
||||
result = 31 * result + objectHashCode(fluidStack.tag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean objectsEqual(Object o1, Object o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return true;
|
||||
} else if (o1 == null || o2 == null) {
|
||||
return false;
|
||||
} else {
|
||||
return o1.equals(o2);
|
||||
}
|
||||
}
|
||||
|
||||
private int objectHashCode(Object o) {
|
||||
return o != null ? o.hashCode() : 0;
|
||||
}
|
||||
|
||||
public StackKey copy() {
|
||||
return new StackKey(stack != null ? stack.copy() : null, fluidStack != null ? fluidStack.copy() : null);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.2", owner = "buildcraftlib", provides = "BuildCraftAPI|core")
|
||||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,86 +0,0 @@
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class CropManager {
|
||||
private static List<ICropHandler> handlers = new ArrayList<>();
|
||||
private static ICropHandler defaultHandler;
|
||||
|
||||
private CropManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void registerHandler(ICropHandler cropHandler) {
|
||||
handlers.add(cropHandler);
|
||||
}
|
||||
|
||||
public static void setDefaultHandler(ICropHandler cropHandler) {
|
||||
defaultHandler = cropHandler;
|
||||
}
|
||||
|
||||
public static ICropHandler getDefaultHandler() {
|
||||
return defaultHandler;
|
||||
}
|
||||
|
||||
public static boolean isSeed(ItemStack stack) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isSeed(stack);
|
||||
}
|
||||
|
||||
public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos);
|
||||
}
|
||||
|
||||
/** Attempts to plant the crop given by the seed into the world. Also checks to make sure that
|
||||
* {@link ICropHandler#isSeed(ItemStack)} is true, and
|
||||
* {@link ICropHandler#canSustainPlant(World, ItemStack, BlockPos)} is true for the position. */
|
||||
public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos) && cropHandler.plantCrop(world, player, seed, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos)) {
|
||||
return defaultHandler.plantCrop(world, player, seed, pos);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos) {
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isMature(blockAccess, state, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return defaultHandler.isMature(blockAccess, state, pos);
|
||||
}
|
||||
|
||||
public static boolean harvestCrop(World world, BlockPos pos, NonNullList<ItemStack> drops) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
for (ICropHandler cropHandler : handlers) {
|
||||
if (cropHandler.isMature(world, state, pos)) {
|
||||
return cropHandler.harvestCrop(world, pos, drops);
|
||||
}
|
||||
}
|
||||
return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICropHandler {
|
||||
|
||||
/** Check if an item is a seed.
|
||||
*
|
||||
* @param stack
|
||||
* @return true if the item can be planted. */
|
||||
boolean isSeed(ItemStack stack);
|
||||
|
||||
/** Check if the item can be planted. You can assume canSustainPlant() will only be called if isSeed() returned
|
||||
* true.
|
||||
*
|
||||
* @param world
|
||||
* @param seed
|
||||
* @param pos
|
||||
* @return true if the item can be planted at pos. */
|
||||
boolean canSustainPlant(World world, ItemStack seed, BlockPos pos);
|
||||
|
||||
/** Plant the item in the block. You can assume plantCrop() will only be called if canSustainPlant() returned true.
|
||||
*
|
||||
* @param world
|
||||
* @param player
|
||||
* @param seed
|
||||
* @param pos
|
||||
* @return true if the item was planted at pos. */
|
||||
boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos);
|
||||
|
||||
/** Check if a crop is mature and can be harvested.
|
||||
*
|
||||
* @param blockAccess
|
||||
* @param state
|
||||
* @param pos
|
||||
* @return true if the block at pos is mature and can be harvested. */
|
||||
boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos);
|
||||
|
||||
/** Harvest the crop. You can assume harvestCrop() will only be called if isMature() returned true.
|
||||
*
|
||||
* @param world
|
||||
* @param pos
|
||||
* @param drops a list to return the harvest's drops.
|
||||
* @return true if the block was successfully harvested. */
|
||||
boolean harvestCrop(World world, BlockPos pos, NonNullList<ItemStack> drops);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|Core", provides = "BuildCraftAPI|crops")
|
||||
package buildcraft.api.crops;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,50 +0,0 @@
|
||||
package buildcraft.api.data;
|
||||
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class NbtSquishConstants {
|
||||
/** Default written NBT Tag type- this is provided by
|
||||
* {@link CompressedStreamTools#write(NBTTagCompound, java.io.DataOutput)} and
|
||||
* {@link CompressedStreamTools#read(java.io.DataInput, net.minecraft.nbt.NBTSizeTracker)}.
|
||||
*
|
||||
* Generally more suited to smaller NBT tags, and it writes fairly quickly. Can quickly use up a lot of space for
|
||||
* larger/more complex tags so it is recommended that you also pass it through a GZIP compressor to take up a much
|
||||
* smaller space. */
|
||||
public static final int VANILLA = 0;
|
||||
public static final int VANILLA_COMPRESSED = 1;
|
||||
/** Buildcraft provided NBT compressor - puts every tag type into a dictionary and then refers to the dictionary for
|
||||
* every tag which is written out. Can get much better space usage than {@link #VANILLA}, but at the cost of
|
||||
* time. */
|
||||
public static final int BUILDCRAFT_V1 = 2;
|
||||
public static final int BUILDCRAFT_V1_COMPRESSED = 3;
|
||||
|
||||
public static final int BUILDCRAFT_MAGIC_1 = 0xbc;
|
||||
public static final int BUILDCRAFT_MAGIC_2 = 0xa1;
|
||||
/** The magic identifier for this type of file. First byte is BC, second is A1. */
|
||||
public static final int BUILDCRAFT_MAGIC = (BUILDCRAFT_MAGIC_1 << 8) | BUILDCRAFT_MAGIC_2;
|
||||
|
||||
// GZIP uses the opposite byte order to us, so swap it around for us
|
||||
public static final int GZIP_MAGIC_1 = GZIPInputStream.GZIP_MAGIC & 0xff;
|
||||
public static final int GZIP_MAGIC_2 = GZIPInputStream.GZIP_MAGIC >> 8;
|
||||
public static final int GZIP_MAGIC = (GZIP_MAGIC_1 << 8) | GZIP_MAGIC_2;
|
||||
|
||||
// The flags used by BUILDCRAFT_V1 to check the existence of each dictionary
|
||||
public static final int FLAG_HAS_BYTES = 1 << 0;
|
||||
public static final int FLAG_HAS_SHORTS = 1 << 1;
|
||||
public static final int FLAG_HAS_INTS = 1 << 2;
|
||||
public static final int FLAG_HAS_LONGS = 1 << 3;
|
||||
public static final int FLAG_HAS_FLOATS = 1 << 4;
|
||||
public static final int FLAG_HAS_DOUBLES = 1 << 5;
|
||||
public static final int FLAG_HAS_BYTE_ARRAYS = 1 << 6;
|
||||
public static final int FLAG_HAS_INT_ARRAYS = 1 << 7;
|
||||
public static final int FLAG_HAS_STRINGS = 1 << 8;
|
||||
public static final int FLAG_HAS_COMPLEX = 1 << 9;
|
||||
|
||||
// Complex types
|
||||
public static final int COMPLEX_COMPOUND = 0;
|
||||
public static final int COMPLEX_LIST = 1;
|
||||
public static final int COMPLEX_LIST_PACKED = 2;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumDecoratedBlock implements IStringSerializable {
|
||||
DESTROY(0),
|
||||
BLUEPRINT(10),
|
||||
TEMPLATE(10),
|
||||
PAPER(10),
|
||||
LEATHER(10),
|
||||
LASER_BACK(0);
|
||||
|
||||
public static final EnumDecoratedBlock[] VALUES = values();
|
||||
|
||||
public final int lightValue;
|
||||
|
||||
EnumDecoratedBlock(int lightValue) {
|
||||
this.lightValue = lightValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public static EnumDecoratedBlock fromMeta(int meta) {
|
||||
if (meta < 0 || meta >= VALUES.length) {
|
||||
return EnumDecoratedBlock.DESTROY;
|
||||
}
|
||||
return VALUES[meta];
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import buildcraft.api.core.IEngineType;
|
||||
|
||||
public enum EnumEngineType implements IStringSerializable, IEngineType {
|
||||
WOOD("core", "wood"),
|
||||
STONE("energy", "stone"),
|
||||
IRON("energy", "iron"),
|
||||
CREATIVE("energy", "creative");
|
||||
|
||||
public final String unlocalizedTag;
|
||||
public final String resourceLocation;
|
||||
|
||||
public static final EnumEngineType[] VALUES = values();
|
||||
|
||||
EnumEngineType(String mod, String loc) {
|
||||
unlocalizedTag = loc;
|
||||
resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemModelLocation() {
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return unlocalizedTag;
|
||||
}
|
||||
|
||||
public static EnumEngineType fromMeta(int meta) {
|
||||
if (meta < 0 || meta >= VALUES.length) {
|
||||
meta = 0;
|
||||
}
|
||||
return VALUES[meta];
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumFillerPattern implements IStringSerializable {
|
||||
NONE,
|
||||
BOX,
|
||||
CLEAR,
|
||||
CYLINDER,
|
||||
FILL,
|
||||
FLATTEN,
|
||||
FRAME,
|
||||
HORIZON,
|
||||
PYRAMID,
|
||||
STAIRS;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumLaserTableType implements IStringSerializable {
|
||||
ASSEMBLY_TABLE,
|
||||
ADVANCED_CRAFTING_TABLE,
|
||||
INTEGRATION_TABLE,
|
||||
CHARGING_TABLE,
|
||||
PROGRAMMING_TABLE;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import buildcraft.api.properties.BuildCraftProperties;
|
||||
|
||||
public enum EnumMachineState implements IStringSerializable {
|
||||
OFF,
|
||||
ON,
|
||||
DONE;
|
||||
|
||||
public static EnumMachineState getType(IBlockState state) {
|
||||
return state.getValue(BuildCraftProperties.MACHINE_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumOptionalSnapshotType implements IStringSerializable {
|
||||
NONE(null),
|
||||
TEMPLATE(EnumSnapshotType.TEMPLATE),
|
||||
BLUEPRINT(EnumSnapshotType.BLUEPRINT);
|
||||
|
||||
public final EnumSnapshotType type;
|
||||
|
||||
EnumOptionalSnapshotType(EnumSnapshotType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static EnumOptionalSnapshotType fromNullable(EnumSnapshotType type) {
|
||||
if (type == null) {
|
||||
return NONE;
|
||||
}
|
||||
switch (type) {
|
||||
case TEMPLATE:
|
||||
return TEMPLATE;
|
||||
case BLUEPRINT:
|
||||
return BLUEPRINT;
|
||||
default:
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumPowerStage implements IStringSerializable {
|
||||
BLUE,
|
||||
GREEN,
|
||||
YELLOW,
|
||||
RED,
|
||||
OVERHEAT,
|
||||
BLACK;
|
||||
|
||||
public static final EnumPowerStage[] VALUES = values();
|
||||
|
||||
private final String modelName = name().toLowerCase(Locale.ROOT);
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getModelName();
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import buildcraft.api.BCItems;
|
||||
|
||||
public enum EnumRedstoneChipset implements IStringSerializable {
|
||||
RED,
|
||||
IRON,
|
||||
GOLD,
|
||||
QUARTZ,
|
||||
DIAMOND;
|
||||
|
||||
private final String name = name().toLowerCase(Locale.ROOT);
|
||||
|
||||
public ItemStack getStack(int stackSize) {
|
||||
Item chipset = BCItems.SILICON_REDSTONE_CHIPSET;
|
||||
if (chipset == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return new ItemStack(chipset, stackSize, ordinal());
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return getStack(1);
|
||||
}
|
||||
|
||||
public static EnumRedstoneChipset fromStack(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return RED;
|
||||
}
|
||||
return fromOrdinal(stack.getMetadata());
|
||||
}
|
||||
|
||||
public static EnumRedstoneChipset fromOrdinal(int ordinal) {
|
||||
if (ordinal < 0 || ordinal >= values().length) {
|
||||
return RED;
|
||||
}
|
||||
return values()[ordinal];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
public enum EnumSnapshotType {
|
||||
TEMPLATE(9),
|
||||
BLUEPRINT(3);
|
||||
|
||||
public final int maxPerTick;
|
||||
|
||||
EnumSnapshotType(int maxPerTick) {
|
||||
this.maxPerTick = maxPerTick;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import buildcraft.api.properties.BuildCraftProperties;
|
||||
|
||||
public enum EnumSpring implements IStringSerializable {
|
||||
WATER(5, -1, Blocks.WATER.getDefaultState()),
|
||||
OIL(6000, 8, null); // Set in BuildCraftEnergy
|
||||
|
||||
public static final EnumSpring[] VALUES = values();
|
||||
|
||||
public final int tickRate, chance;
|
||||
public IBlockState liquidBlock;
|
||||
public boolean canGen = true;
|
||||
public Supplier<TileEntity> tileConstructor;
|
||||
|
||||
private final String lowerCaseName = name().toLowerCase(Locale.ROOT);
|
||||
|
||||
EnumSpring(int tickRate, int chance, IBlockState liquidBlock) {
|
||||
this.tickRate = tickRate;
|
||||
this.chance = chance;
|
||||
this.liquidBlock = liquidBlock;
|
||||
}
|
||||
|
||||
public static EnumSpring fromState(IBlockState state) {
|
||||
return state.getValue(BuildCraftProperties.SPRING_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return lowerCaseName;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|enums")
|
||||
package buildcraft.api.enums;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,22 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class BlockInteractionEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final IBlockState state;
|
||||
|
||||
public BlockInteractionEvent(EntityPlayer player, IBlockState state) {
|
||||
this.player = player;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class BlockPlacedDownEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final IBlockState state;
|
||||
public final BlockPos pos;
|
||||
|
||||
public BlockPlacedDownEvent(EntityPlayer player, BlockPos pos, IBlockState state) {
|
||||
this.player = player;
|
||||
this.state = state;
|
||||
this.pos = pos;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class PipePlacedEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
public Item pipeType;
|
||||
public BlockPos pos;
|
||||
|
||||
public PipePlacedEvent(EntityPlayer player, Item pipeType, BlockPos pos) {
|
||||
this.player = player;
|
||||
this.pipeType = pipeType;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
|
||||
public abstract class RobotEvent extends Event {
|
||||
public final EntityRobotBase robot;
|
||||
|
||||
public RobotEvent(EntityRobotBase robot) {
|
||||
this.robot = robot;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Place extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
|
||||
public Place(EntityRobotBase robot, EntityPlayer player) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Interact extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack item;
|
||||
|
||||
public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
this.item = item;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Dismantle extends RobotEvent {
|
||||
public final EntityPlayer player;
|
||||
|
||||
public Dismantle(EntityRobotBase robot, EntityPlayer player) {
|
||||
super(robot);
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class RobotPlacementEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
public String robotProgram;
|
||||
|
||||
public RobotPlacementEvent(EntityPlayer player, String robotProgram) {
|
||||
this.player = player;
|
||||
this.robotProgram = robotProgram;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|events")
|
||||
package buildcraft.api.events;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,35 +0,0 @@
|
||||
package buildcraft.api.facades;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
public final class FacadeAPI {
|
||||
public static final String IMC_MOD_TARGET = "buildcrafttransport";
|
||||
public static final String IMC_FACADE_DISABLE = "facade_disable_block";
|
||||
public static final String IMC_FACADE_CUSTOM = "facade_custom_map_block_item";
|
||||
public static final String NBT_CUSTOM_BLOCK_REG_KEY = "block_registry_name";
|
||||
public static final String NBT_CUSTOM_BLOCK_META = "block_meta";
|
||||
public static final String NBT_CUSTOM_ITEM_STACK = "item_stack";
|
||||
|
||||
public static IFacadeItem facadeItem;
|
||||
|
||||
private FacadeAPI() {
|
||||
|
||||
}
|
||||
|
||||
public static void disableBlock(Block block) {
|
||||
FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_DISABLE, block.getRegistryName());
|
||||
}
|
||||
|
||||
public static void mapStateToStack(IBlockState state, ItemStack stack) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString(NBT_CUSTOM_BLOCK_REG_KEY, state.getBlock().getRegistryName().toString());
|
||||
nbt.setInteger(NBT_CUSTOM_BLOCK_META, state.getBlock().getMetaFromState(state));
|
||||
nbt.setTag(NBT_CUSTOM_ITEM_STACK, stack.serializeNBT());
|
||||
FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, nbt);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.facades;
|
||||
|
||||
public enum FacadeType {
|
||||
Basic,
|
||||
Phased;
|
||||
|
||||
public static FacadeType fromOrdinal(int ordinal) {
|
||||
return ordinal == 1 ? Phased : Basic;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.facades;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFacadeItem {
|
||||
FacadeType getFacadeType(@Nonnull ItemStack facade);
|
||||
|
||||
@Nonnull
|
||||
ItemStack getFacadeForBlock(IBlockState state);
|
||||
|
||||
IBlockState[] getBlockStatesForFacade(@Nonnull ItemStack facade);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|facades")
|
||||
package buildcraft.api.facades;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
public final class FillerManager {
|
||||
|
||||
public static IFillerRegistry registry;
|
||||
|
||||
/** Deactivate constructor */
|
||||
private FillerManager() {}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import buildcraft.api.statements.IStatement;
|
||||
|
||||
/** A type of statement that is used for filler patterns. */
|
||||
public interface IFillerPattern extends IStatement {
|
||||
// Object getBlockOverlay();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IFillerRegistry {
|
||||
void addPattern(IFillerPattern pattern);
|
||||
|
||||
IFillerPattern getPattern(String patternName);
|
||||
|
||||
IFillerPattern getNextPattern(IFillerPattern currentPattern);
|
||||
|
||||
IFillerPattern getPreviousPattern(IFillerPattern currentPattern);
|
||||
|
||||
Collection<IFillerPattern> getPatterns();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "4.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|filler")
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
public final class BuildcraftFuelRegistry {
|
||||
public static IFuelManager fuel;
|
||||
public static ICoolantManager coolant;
|
||||
|
||||
private BuildcraftFuelRegistry() {}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface ICoolant {
|
||||
boolean matchesFluid(FluidStack fluid);
|
||||
|
||||
/** @param fluid
|
||||
* @param heat
|
||||
* @return 0 if the input fluid provides no cooling, or a value greater than 0 if it does. */
|
||||
float getDegreesCoolingPerMB(FluidStack fluid, float heat);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface ICoolantManager {
|
||||
ICoolant addCoolant(ICoolant coolant);
|
||||
|
||||
ICoolant addCoolant(FluidStack fluid, float degreesCoolingPerMb);
|
||||
|
||||
default ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMb) {
|
||||
return addCoolant(new FluidStack(fluid, 1), degreesCoolingPerMb);
|
||||
}
|
||||
|
||||
ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant);
|
||||
|
||||
ISolidCoolant addSolidCoolant(ItemStack solid, FluidStack fluid, float multiplier);
|
||||
|
||||
Collection<ICoolant> getCoolants();
|
||||
|
||||
Collection<ISolidCoolant> getSolidCoolants();
|
||||
|
||||
ICoolant getCoolant(FluidStack fluid);
|
||||
|
||||
float getDegreesPerMb(FluidStack fluid, float heat);
|
||||
|
||||
ISolidCoolant getSolidCoolant(ItemStack solid);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFuel {
|
||||
/** @return The input fluid. The {@link FluidStack#amount} is ignored. */
|
||||
FluidStack getFluid();
|
||||
|
||||
/** @return The number of ticks that a single bucket (1000mb) of this fuel will burn for. */
|
||||
int getTotalBurningTime();
|
||||
|
||||
/** @return The amount (in micro mj) of power that this fuel will give off in 1 tick. */
|
||||
long getPowerPerCycle();
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFuelManager {
|
||||
<F extends IFuel> F addFuel(F fuel);
|
||||
|
||||
IFuel addFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime);
|
||||
|
||||
default IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime) {
|
||||
return addFuel(new FluidStack(fluid, 1), powerPerCycle, totalBurningTime);
|
||||
}
|
||||
|
||||
/** @param residue The residue fluidstack, per bucket of the original fuel. */
|
||||
IDirtyFuel addDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue);
|
||||
|
||||
/** @param residue The residue fluidstack, per bucket of the original fuel. */
|
||||
default IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) {
|
||||
return addDirtyFuel(new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue);
|
||||
}
|
||||
|
||||
Collection<IFuel> getFuels();
|
||||
|
||||
IFuel getFuel(FluidStack fluid);
|
||||
|
||||
interface IDirtyFuel extends IFuel {
|
||||
/** @return The residue fluidstack, per bucket of original fuel. */
|
||||
FluidStack getResidue();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface ISolidCoolant {
|
||||
FluidStack getFluidFromSolidCoolant(ItemStack stack);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels")
|
||||
package buildcraft.api.fuels;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,28 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import buildcraft.api.statements.IStatement;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import buildcraft.api.statements.StatementSlot;
|
||||
import buildcraft.api.statements.containers.ISidedStatementContainer;
|
||||
import buildcraft.api.transport.pipe.IPipeHolder;
|
||||
|
||||
public interface IGate extends ISidedStatementContainer {
|
||||
|
||||
IPipeHolder getPipeHolder();
|
||||
|
||||
List<IStatement> getTriggers();
|
||||
|
||||
List<IStatement> getActions();
|
||||
|
||||
List<StatementSlot> getActiveActions();
|
||||
|
||||
List<IStatementParameter> getTriggerParameters(int slot);
|
||||
|
||||
List<IStatementParameter> getActionParameters(int slot);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,72 +0,0 @@
|
||||
package buildcraft.api.inventory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import buildcraft.api.core.IStackFilter;
|
||||
|
||||
/** A simple way to define something that deals with item insertion and extraction, without caring about slots. */
|
||||
public interface IItemTransactor {
|
||||
/** @param stack The stack to insert. Must not be null!
|
||||
* @param allOrNone If true then either the entire stack will be used or none of it.
|
||||
* @param simulate If true then the in-world state of this will not be changed.
|
||||
* @return The overflow stack. Will be {@link ItemStack#EMPTY} if all of it was accepted. */
|
||||
@Nonnull
|
||||
ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate);
|
||||
|
||||
/** Similar to {@link #insert(ItemStack, boolean, boolean)} but probably be more efficient at inserting lots of
|
||||
* items.
|
||||
*
|
||||
* @param stacks The stacks to insert. Must not be null!
|
||||
* @param simulate If true then the in-world state of this will not be changed.
|
||||
* @return The overflow stacks. Will be an empty list if all of it was accepted. */
|
||||
default NonNullList<ItemStack> insert(NonNullList<ItemStack> stacks, boolean simulate) {
|
||||
NonNullList<ItemStack> leftOver = NonNullList.create();
|
||||
for (ItemStack stack : stacks) {
|
||||
ItemStack leftOverStack = insert(stack, false, simulate);
|
||||
if (!leftOverStack.isEmpty()) {
|
||||
leftOver.add(leftOverStack);
|
||||
}
|
||||
}
|
||||
return leftOver;
|
||||
}
|
||||
|
||||
/** Extracts a number of items that match the given filter
|
||||
*
|
||||
* @param filter The filter that MUST be met by the extracted stack. Null means no filter - it can be any item.
|
||||
* @param min The minimum number of items to extract, or 0 if not enough items can be extracted
|
||||
* @param max The maximum number of items to extract.
|
||||
* @param simulate If true then the in-world state of this will not be changed.
|
||||
* @return The stack that was extracted, or {@link ItemStack#EMPTY} if it could not be. */
|
||||
@Nonnull
|
||||
ItemStack extract(@Nullable IStackFilter filter, int min, int max, boolean simulate);
|
||||
|
||||
default boolean canFullyAccept(@Nonnull ItemStack stack) {
|
||||
return insert(stack, true, true).isEmpty();
|
||||
}
|
||||
|
||||
default boolean canPartiallyAccept(@Nonnull ItemStack stack) {
|
||||
return insert(stack, false, true).getCount() < stack.getCount();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface IItemInsertable extends IItemTransactor {
|
||||
@Nonnull
|
||||
@Override
|
||||
default ItemStack extract(IStackFilter filter, int min, int max, boolean simulate) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface IItemExtractable extends IItemTransactor {
|
||||
@Nonnull
|
||||
@Override
|
||||
default ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package buildcraft.api.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IItemCustomPipeRender {
|
||||
float getPipeRenderScale(ItemStack stack);
|
||||
|
||||
/** @return False to use the default renderer, true otherwise. */
|
||||
@SideOnly(Side.CLIENT)
|
||||
boolean renderItemInPipe(ItemStack stack, double x, double y, double z);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package buildcraft.api.items;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IList extends INamedItem {
|
||||
boolean matches(@Nonnull ItemStack stackList, @Nonnull ItemStack item);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package buildcraft.api.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.api.core.IZone;
|
||||
|
||||
/** Created by asie on 2/28/15. */
|
||||
public interface IMapLocation extends INamedItem {
|
||||
enum MapLocationType {
|
||||
CLEAN,
|
||||
SPOT,
|
||||
AREA,
|
||||
PATH,
|
||||
ZONE,
|
||||
/** Like PATH but repeats around in a loop. */
|
||||
PATH_REPEATING;
|
||||
|
||||
public final int meta = ordinal();
|
||||
|
||||
public static MapLocationType getFromStack(@Nonnull ItemStack stack) {
|
||||
int dam = stack.getItemDamage();
|
||||
if (dam < 0 || dam >= values().length) {
|
||||
return MapLocationType.CLEAN;
|
||||
}
|
||||
return values()[dam];
|
||||
}
|
||||
|
||||
public void setToStack(@Nonnull ItemStack stack) {
|
||||
stack.setItemDamage(meta);
|
||||
}
|
||||
}
|
||||
|
||||
/** This function can be used for SPOT types.
|
||||
*
|
||||
* @param stack
|
||||
* @return The point representing the map location. */
|
||||
BlockPos getPoint(@Nonnull ItemStack stack);
|
||||
|
||||
/** This function can be used for SPOT and AREA types.
|
||||
*
|
||||
* @param stack
|
||||
* @return The box representing the map location. */
|
||||
IBox getBox(@Nonnull ItemStack stack);
|
||||
|
||||
/** This function can be used for SPOT, AREA and ZONE types. The PATH type needs to be handled separately.
|
||||
*
|
||||
* @param stack
|
||||
* @return An IZone representing the map location - also an instance of IBox for SPOT and AREA types. */
|
||||
IZone getZone(@Nonnull ItemStack stack);
|
||||
|
||||
/** This function can be used for SPOT and PATH types.
|
||||
*
|
||||
* @param stack
|
||||
* @return A list of BlockPoses representing the path the Map Location stores. */
|
||||
List<BlockPos> getPath(@Nonnull ItemStack stack);
|
||||
|
||||
/** This function can be used for SPOT types only.
|
||||
*
|
||||
* @param stack
|
||||
* @return The side of the spot. */
|
||||
EnumFacing getPointSide(@Nonnull ItemStack stack);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package buildcraft.api.items;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface INamedItem {
|
||||
String getName(@Nonnull ItemStack stack);
|
||||
|
||||
boolean setName(@Nonnull ItemStack stack, String name);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|items")
|
||||
package buildcraft.api.items;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,18 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface ILibraryTypeHandler {
|
||||
boolean isHandler(ItemStack stack, boolean store);
|
||||
|
||||
String getFileExtension();
|
||||
|
||||
int getTextColor();
|
||||
|
||||
String getName(ItemStack stack);
|
||||
|
||||
ItemStack load(ItemStack stack, NBTTagCompound compound);
|
||||
|
||||
boolean store(ItemStack stack, NBTTagCompound compound);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Deprecated
|
||||
public final class LibraryAPI {
|
||||
private static final Set<LibraryTypeHandler> handlers = new HashSet<>();
|
||||
|
||||
private LibraryAPI() {
|
||||
|
||||
}
|
||||
|
||||
public static Set<LibraryTypeHandler> getHandlerSet() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static void registerHandler(LibraryTypeHandler handler) {
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
public static LibraryTypeHandler getHandlerFor(String extension) {
|
||||
for (LibraryTypeHandler h : handlers) {
|
||||
if (h.isInputExtension(extension)) {
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Deprecated
|
||||
public abstract class LibraryTypeHandler {
|
||||
public enum HandlerType {
|
||||
LOAD,
|
||||
STORE
|
||||
}
|
||||
|
||||
private final String extension;
|
||||
|
||||
public LibraryTypeHandler(String extension) {
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
public abstract boolean isHandler(ItemStack stack, HandlerType type);
|
||||
|
||||
public boolean isInputExtension(String ext) {
|
||||
return extension.equals(ext);
|
||||
}
|
||||
|
||||
public String getOutputExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public abstract int getTextColor();
|
||||
|
||||
public abstract String getName(ItemStack stack);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class LibraryTypeHandlerByteArray extends LibraryTypeHandler {
|
||||
public LibraryTypeHandlerByteArray(String extension) {
|
||||
super(extension);
|
||||
}
|
||||
|
||||
public abstract ItemStack load(ItemStack stack, byte[] data);
|
||||
|
||||
public abstract byte[] store(ItemStack stack);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class LibraryTypeHandlerNBT extends LibraryTypeHandler {
|
||||
public LibraryTypeHandlerNBT(String extension) {
|
||||
super(extension);
|
||||
}
|
||||
|
||||
public abstract ItemStack load(ItemStack stack, NBTTagCompound nbt);
|
||||
|
||||
public abstract boolean store(ItemStack stack, NBTTagCompound nbt);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|library")
|
||||
package buildcraft.api.library;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,28 +0,0 @@
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public abstract class ListMatchHandler {
|
||||
public enum Type {
|
||||
TYPE,
|
||||
MATERIAL,
|
||||
CLASS
|
||||
}
|
||||
|
||||
public abstract boolean matches(Type type, @Nonnull ItemStack stack, @Nonnull ItemStack target, boolean precise);
|
||||
|
||||
public abstract boolean isValidSource(Type type, @Nonnull ItemStack stack);
|
||||
|
||||
/** Get custom client examples.
|
||||
*
|
||||
* @param type
|
||||
* @param stack
|
||||
* @return A List (even empty!) if the examples satisfy this handler, null if iteration and .matches should be used
|
||||
* instead. */
|
||||
public NonNullList<ItemStack> getClientExamples(Type type, @Nonnull ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public final class ListRegistry {
|
||||
public static final List<Class<? extends Item>> itemClassAsType = new ArrayList<>();
|
||||
private static final List<ListMatchHandler> handlers = new ArrayList<>();
|
||||
|
||||
private ListRegistry() {
|
||||
|
||||
}
|
||||
|
||||
public static void registerHandler(ListMatchHandler h) {
|
||||
if (h != null) {
|
||||
handlers.add(h);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ListMatchHandler> getHandlers() {
|
||||
return Collections.unmodifiableList(handlers);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|lists")
|
||||
package buildcraft.api.lists;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
@@ -1,27 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** This interface should be defined by any Tile which wants to receive power from BuildCraft lasers.
|
||||
*
|
||||
* The respective Block MUST implement ILaserTargetBlock! */
|
||||
public interface ILaserTarget {
|
||||
|
||||
/** Returns The amount of power this target currently needs.
|
||||
*
|
||||
* @return The amount of power required, or 0 if no power is required. */
|
||||
long getRequiredLaserPower();
|
||||
|
||||
/** Transfers power from the laser to the target.
|
||||
*
|
||||
* @param microJoules The number of micro Minecraft Joules to accept
|
||||
* @return The excess power. If the input is less than or equal to {@link #getRequiredLaserPower()} then this will return 0. */
|
||||
long receiveLaserPower(long microJoules);
|
||||
|
||||
/** Return true if the Tile Entity object is no longer a valid target. For example, if its been invalidated.
|
||||
*
|
||||
* @return true if no longer a valid target object */
|
||||
boolean isInvalidTarget();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which
|
||||
* should be located as "LICENSE.API" in the BuildCraft source code distribution. */
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** This is a marker interface for laser targets. Implement it on your Block.
|
||||
*
|
||||
* It is used by BuildCraft Lasers for optimization purposes. */
|
||||
public interface ILaserTargetBlock {
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/** Signifies that this should visibly connect to other Mj handling entities/tiles. This should NEVER be the tile
|
||||
* entity, but an encapsulated class that refers back to it. Use {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} to access
|
||||
* this. */
|
||||
public interface IMjConnector {
|
||||
/** Checks to see if this connector can connect to the other connector. By default this should check that the other
|
||||
* connector is the same power system.
|
||||
*
|
||||
* @param other
|
||||
* @return */
|
||||
boolean canConnect(@Nonnull IMjConnector other);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Various effects for showing power loss visibly, and for large amounts of power, causes some damage to nearby
|
||||
* entities. */
|
||||
public interface IMjEffectManager {
|
||||
void createPowerLossEffect(World world, Vec3d center, long microJoulesLost);
|
||||
|
||||
void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost);
|
||||
|
||||
void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** Designates a machine that provides power passively- it does not attempt to manually output its power (like an
|
||||
* engine). Power can be extracted from this by powered wooden kinesis pipes, for example. */
|
||||
public interface IMjPassiveProvider extends IMjConnector {
|
||||
/** Attempts to extract power from this provider
|
||||
*
|
||||
* @param simulate
|
||||
* @return Either 0, min, max, or a value between min and max. */
|
||||
long extractPower(long min, long max, boolean simulate);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** Indicates an MJ consumer that has readable information. */
|
||||
public interface IMjReadable extends IMjConnector {
|
||||
long getStored();
|
||||
|
||||
long getCapacity();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** Designates a machine that can receive power. */
|
||||
public interface IMjReceiver extends IMjConnector {
|
||||
/** @return The number of microjoules that this receiver currently wants, and can accept. */
|
||||
long getPowerRequested();
|
||||
|
||||
/** Receives power. You are encouraged to either:
|
||||
* <ul>
|
||||
* <li>Use up all power immediately, or when you next tick.
|
||||
* <li>Store all power in something like an {@link MjBattery} for later usage.
|
||||
* <li>Refuse all power (if you have no more work to do or your {@link MjBattery} is full).
|
||||
* </ul>
|
||||
*
|
||||
* Note that callers are NOT expected to call {@link #canReceive()} before calling this - implementors should check
|
||||
* all of the conditions in {@link #canReceive()} before accepting power.
|
||||
*
|
||||
* @param microJoules The number of micro joules to add.
|
||||
* @param simulate If true then just pretend you received power- don't actually change any of your internal state.
|
||||
* @return The excess power. */
|
||||
long receivePower(long microJoules, boolean simulate);
|
||||
|
||||
/** Checks to see if {@link #receivePower(long, boolean)} *might* accept any power right now, ignoring the amount of
|
||||
* power contained right now (if any).
|
||||
*
|
||||
* @return True if this {@link IMjReceiver} can receive power right now. */
|
||||
default boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
/** Designates that a receiver can receive redstone power (cheap, free, small amounts) */
|
||||
public interface IMjRedstoneReceiver extends IMjReceiver {}
|
||||
@@ -1,119 +0,0 @@
|
||||
package buildcraft.api.mj;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
|
||||
import buildcraft.api.core.CapabilitiesHelper;
|
||||
|
||||
public class MjAPI {
|
||||
|
||||
// ################################
|
||||
//
|
||||
// Useful constants (Public API)
|
||||
//
|
||||
// ################################
|
||||
|
||||
/** A single minecraft joule, in micro joules (the power system base unit) */
|
||||
public static final long ONE_MINECRAFT_JOULE = 1 * 1000L * 1000L;
|
||||
/** The same as {@link #ONE_MINECRAFT_JOULE}, but a shorter field name */
|
||||
public static final long MJ = ONE_MINECRAFT_JOULE;
|
||||
|
||||
/** The decimal format used to display values of MJ to the player. Note that this */
|
||||
public static final DecimalFormat MJ_DISPLAY_FORMAT = new DecimalFormat("#,##0.##");
|
||||
|
||||
public static IMjEffectManager EFFECT_MANAGER = NullaryEffectManager.INSTANCE;
|
||||
|
||||
// ###############
|
||||
//
|
||||
// Helpful methods
|
||||
//
|
||||
// ###############
|
||||
|
||||
/** Formats a given MJ value to a player-oriented string. Note that this does not append "MJ" to the value. */
|
||||
public static String formatMj(long microMj) {
|
||||
return formatMjInternal(microMj / (double) MJ);
|
||||
}
|
||||
|
||||
private static String formatMjInternal(double val) {
|
||||
return MJ_DISPLAY_FORMAT.format(val);
|
||||
}
|
||||
|
||||
// ########################################
|
||||
//
|
||||
// Null based classes
|
||||
//
|
||||
// ########################################
|
||||
|
||||
public enum NullaryEffectManager implements IMjEffectManager {
|
||||
INSTANCE;
|
||||
@Override public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {}
|
||||
@Override public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {}
|
||||
@Override public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {}
|
||||
}
|
||||
// @formatter:on
|
||||
|
||||
// ###############
|
||||
//
|
||||
// Capabilities
|
||||
//
|
||||
// ###############
|
||||
|
||||
@Nonnull
|
||||
public static final Capability<IMjConnector> CAP_CONNECTOR;
|
||||
|
||||
@Nonnull
|
||||
public static final Capability<IMjReceiver> CAP_RECEIVER;
|
||||
|
||||
@Nonnull
|
||||
public static final Capability<IMjRedstoneReceiver> CAP_REDSTONE_RECEIVER;
|
||||
|
||||
@Nonnull
|
||||
public static final Capability<IMjReadable> CAP_READABLE;
|
||||
|
||||
@Nonnull
|
||||
public static final Capability<IMjPassiveProvider> CAP_PASSIVE_PROVIDER;
|
||||
|
||||
// ####################
|
||||
//
|
||||
// Internal API logic
|
||||
//
|
||||
// ###################
|
||||
|
||||
// Private fields for the registrations -- this allows us to make the actual fields @Nonnull as we check later
|
||||
@CapabilityInject(IMjConnector.class)
|
||||
private static final Capability<IMjConnector> CAP_CONNECTOR_FIRST = null;
|
||||
|
||||
@CapabilityInject(IMjReceiver.class)
|
||||
private static final Capability<IMjReceiver> CAP_RECEIVER_FIRST = null;
|
||||
|
||||
@CapabilityInject(IMjRedstoneReceiver.class)
|
||||
private static final Capability<IMjRedstoneReceiver> CAP_REDSTONE_RECEIVER_FIRST = null;
|
||||
|
||||
@CapabilityInject(IMjReadable.class)
|
||||
private static final Capability<IMjReadable> CAP_READABLE_FIRST = null;
|
||||
|
||||
@CapabilityInject(IMjPassiveProvider.class)
|
||||
private static final Capability<IMjPassiveProvider> CAP_PASSIVE_PROVIDER_FIRST = null;
|
||||
|
||||
static {
|
||||
CapabilitiesHelper.registerCapability(IMjConnector.class);
|
||||
CapabilitiesHelper.registerCapability(IMjReceiver.class);
|
||||
CapabilitiesHelper.registerCapability(IMjRedstoneReceiver.class);
|
||||
CapabilitiesHelper.registerCapability(IMjReadable.class);
|
||||
CapabilitiesHelper.registerCapability(IMjPassiveProvider.class);
|
||||
|
||||
CAP_CONNECTOR = CapabilitiesHelper.ensureRegistration(CAP_CONNECTOR_FIRST, IMjConnector.class);
|
||||
CAP_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_RECEIVER_FIRST, IMjReceiver.class);
|
||||
CAP_REDSTONE_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_REDSTONE_RECEIVER_FIRST, IMjRedstoneReceiver.class);
|
||||
CAP_READABLE = CapabilitiesHelper.ensureRegistration(CAP_READABLE_FIRST, IMjReadable.class);
|
||||
CAP_PASSIVE_PROVIDER = CapabilitiesHelper.ensureRegistration(CAP_PASSIVE_PROVIDER_FIRST, IMjPassiveProvider.class);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 228 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user