Oh look, it's a booting computer.

This commit is contained in:
Florian Nücke 2017-03-31 21:40:47 +02:00
parent 5521526510
commit ad72f1e16c
219 changed files with 805 additions and 963 deletions

View File

@ -7,7 +7,7 @@ mod.group=li.cil.oc
mod.version=1.7.0
forestry.version=5.3.1.38
jei.version=4.2.7.240
jei.version=4.2.11.251
mcmp.version=2.0.0_17
tis3d.version=1.1.1.37

View File

@ -1,6 +1,5 @@
package li.cil.oc.api;
import li.cil.oc.api.driver.Block;
import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.InventoryProvider;
@ -10,8 +9,8 @@ import li.cil.oc.api.network.EnvironmentHost;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@ -36,25 +35,6 @@ import java.util.Set;
* @see Item
*/
public final class Driver {
/**
* Registers a new block driver.
* <p/>
* Whenever the neighboring blocks of an Adapter block change, it checks if
* there exists a driver for the changed block, and if it is configured to
* interface that block type connects it to the component network.
* <p/>
* This must be called in the init phase, <em>not</em> the pre- or post-init
* phases.
*
* @param driver the driver to register.
* @deprecated Use {@link SidedBlock} instead.
*/
@Deprecated // TODO Remove in OC 1.7
public static void add(final Block driver) {
if (API.driver != null)
API.driver.add(driver);
}
/**
* Registers a new side-aware block driver.
* <p/>
@ -138,30 +118,8 @@ public final class Driver {
* <p/>
* Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you should will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
*
* @param world the world containing the block.
* @param pos the position of the block.
* @return a driver for the block, or <tt>null</tt> if there is none.
* @deprecated Use {@link #driverFor(World, BlockPos, EnumFacing)},
* passing <tt>null</tt> if the side is to be ignored.
*/
@Deprecated // TODO Remove in OC 1.7
public static Block driverFor(World world, BlockPos pos) {
if (API.driver != null)
return API.driver.driverFor(world, pos);
return null;
}
/**
* Looks up a driver for the block at the specified position in the
* specified world.
* <p/>
* Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you should will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
* what will be returned here. In other words, you will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.SidedBlock)}.
*
* @param world the world containing the block.
* @param pos the position of the block.
@ -273,22 +231,6 @@ public final class Driver {
return null;
}
/**
* Get a list of all registered block drivers.
* <p/>
* This is intended to allow checking for particular drivers using more
* customized logic.
* <p/>
* The returned collection is read-only.
*
* @return the list of all registered block drivers.
*/
public static Collection<Block> blockDrivers() {
if (API.driver != null)
return API.driver.blockDrivers();
return null;
}
/**
* Get a list of all registered item drivers.
* <p/>

View File

@ -73,7 +73,7 @@ public final class Items {
public static ItemStack registerFloppy(String name, EnumDyeColor color, Callable<li.cil.oc.api.fs.FileSystem> factory) {
if (API.items != null)
return API.items.registerFloppy(name, color, factory);
return null;
return ItemStack.EMPTY;
}
/**
@ -104,7 +104,7 @@ public final class Items {
public static ItemStack registerFloppy(String name, EnumDyeColor color, Callable<li.cil.oc.api.fs.FileSystem> factory, boolean doRecipeCycling) {
if (API.items != null)
return API.items.registerFloppy(name, color, factory, doRecipeCycling);
return null;
return ItemStack.EMPTY;
}
/**
@ -126,7 +126,7 @@ public final class Items {
public static ItemStack registerEEPROM(String name, byte[] code, byte[] data, boolean readonly) {
if (API.items != null)
return API.items.registerEEPROM(name, code, data, readonly);
return null;
return ItemStack.EMPTY;
}
// ----------------------------------------------------------------------- //

View File

@ -1,6 +1,6 @@
package li.cil.oc.api.detail;
import li.cil.oc.api.driver.Block;
import jline.internal.Nullable;
import li.cil.oc.api.driver.Converter;
import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.InventoryProvider;
@ -10,8 +10,8 @@ import li.cil.oc.api.network.EnvironmentHost;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@ -19,22 +19,6 @@ import java.util.Collection;
import java.util.Set;
public interface DriverAPI {
/**
* Registers a new driver for a block component.
* <p/>
* Whenever the neighboring blocks of an Adapter block change, it checks if
* there exists a driver for the changed block, and if it is configured to
* interface that block type connects it to the component network.
* <p/>
* This must be called in the init phase, <em>not</em> the pre- or post-init
* phases.
*
* @param driver the driver for a block component.
* @deprecated Use {@link SidedBlock} instead.
*/
@Deprecated // TODO Remove in OC 1.7
void add(Block driver);
/**
* Registers a new side-aware block driver.
* <p/>
@ -104,31 +88,14 @@ public interface DriverAPI {
* Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you should will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
*
* @param world the world containing the block.
* @param pos the position of the block.
* @return a driver for the block, or <tt>null</tt> if there is none.
* @deprecated Use {@link #driverFor(World, BlockPos, EnumFacing)},
* passing <tt>null</tt> if the side is to be ignored.
*/
@Deprecated // TODO Remove in OC 1.7
Block driverFor(World world, BlockPos pos);
/**
* Looks up a driver for the block at the specified position in the
* specified world.
* <p/>
* Note that several drivers for a single block can exist. Because of this
* block drivers are always encapsulated in a 'compound' driver, which is
* what will be returned here. In other words, you should will <em>not</em>
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.Block)}.
* get actual instances of drivers registered via {@link #add(li.cil.oc.api.driver.SidedBlock)}.
*
* @param world the world containing the block.
* @param pos the position of the block.
* @param side the side of the block.
* @return a driver for the block, or <tt>null</tt> if there is none.
*/
@Nullable
SidedBlock driverFor(World world, BlockPos pos, EnumFacing side);
/**
@ -142,6 +109,7 @@ public interface DriverAPI {
* @param host the type that will host the environment created by returned driver.
* @return a driver for the item, or <tt>null</tt> if there is none.
*/
@Nullable
Item driverFor(ItemStack stack, Class<? extends EnvironmentHost> host);
/**
@ -157,6 +125,7 @@ public interface DriverAPI {
* @param stack the item stack to get a driver for.
* @return a driver for the item, or <tt>null</tt> if there is none.
*/
@Nullable
Item driverFor(ItemStack stack);
/**
@ -188,7 +157,8 @@ public interface DriverAPI {
/**
* @deprecated Use {@link #itemHandlerFor(ItemStack, EntityPlayer)} instead.
*/
@Deprecated // TODO Remove in OC 1.7
@Deprecated
// TODO Remove in OC 1.7
IInventory inventoryFor(ItemStack stack, EntityPlayer player);
/**
@ -207,18 +177,6 @@ public interface DriverAPI {
*/
IItemHandler itemHandlerFor(ItemStack stack, EntityPlayer player);
/**
* Get a list of all registered block drivers.
* <p/>
* This is intended to allow checking for particular drivers using more
* customized logic.
* <p/>
* The returned collection is read-only.
*
* @return the list of all registered block drivers.
*/
Collection<Block> blockDrivers();
/**
* Get a list of all registered item drivers.
* <p/>

View File

@ -1,5 +1,6 @@
package li.cil.oc.api.detail;
import jline.internal.Nullable;
import li.cil.oc.api.FileSystem;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
@ -19,6 +20,7 @@ public interface ItemAPI {
* @return the descriptor for the item with the specified name, or
* <tt>null</tt> if there is no such item.
*/
@Nullable
ItemInfo get(String name);
/**
@ -29,6 +31,7 @@ public interface ItemAPI {
* @return the descriptor for the specified item stack, or <tt>null</tt>
* if the stack is not a valid OpenComputers item or block.
*/
@Nullable
ItemInfo get(ItemStack stack);
/**

View File

@ -1,55 +0,0 @@
package li.cil.oc.api.prefab;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
/**
* If you wish to create a block component for a third-party block, i.e. a block
* for which you do not control the tile entity, such as vanilla blocks, you
* will need a block driver.
* <p/>
* This prefab allows creating a driver that works for a specified list of item
* stacks (to support different blocks with the same id but different metadata
* values).
* <p/>
* You still have to provide the implementation for creating its environment, if
* any.
*
* @see li.cil.oc.api.network.ManagedEnvironment
* @deprecated Use {@link DriverSidedBlock} instead.
*/
@Deprecated // TODO Remove in OC 1.7
@SuppressWarnings("UnusedDeclaration")
public abstract class DriverBlock implements li.cil.oc.api.driver.Block {
protected final ItemStack[] blocks;
protected DriverBlock(final ItemStack... blocks) {
this.blocks = blocks.clone();
}
@Override
public boolean worksWith(final World world, final BlockPos pos) {
final IBlockState state = world.getBlockState(pos);
final Block block = state.getBlock();
return worksWith(block, block.getMetaFromState(state));
}
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
for (ItemStack stack : blocks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
final ItemBlock item = (ItemBlock) stack.getItem();
final Block supportedBlock = item.getBlock();
final int supportedMetadata = item.getMetadata(stack.getItemDamage());
if (referenceBlock == supportedBlock && (referenceMetadata == supportedMetadata || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
return true;
}
}
}
return false;
}
}

View File

@ -28,9 +28,9 @@ public abstract class DriverItem implements li.cil.oc.api.driver.Item {
@Override
public boolean worksWith(final ItemStack stack) {
if (stack != null) {
if (!stack.isEmpty()) {
for (ItemStack item : items) {
if (item != null && item.isItemEqual(stack)) {
if (!item.isEmpty() && item.isItemEqual(stack)) {
return true;
}
}

View File

@ -43,7 +43,7 @@ public abstract class DriverSidedBlock implements li.cil.oc.api.driver.SidedBloc
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
for (ItemStack stack : blocks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock) {
final ItemBlock item = (ItemBlock) stack.getItem();
final Block supportedBlock = item.getBlock();
final int supportedMetadata = item.getMetadata(stack.getItemDamage());

Some files were not shown because too many files have changed in this diff Show More