Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8

This commit is contained in:
Florian Nücke 2015-01-29 01:40:53 +01:00
commit d1f7899c4c
5 changed files with 41 additions and 1 deletions

View File

@ -1039,6 +1039,11 @@ opencomputers {
# an adapter has pretty much the same effect. # an adapter has pretty much the same effect.
enableTankDriver: false enableTankDriver: false
# Whether to enable the command block driver. Enabling this allows
# computers to set and execute commands via command blocks next to
# adapter blocks. The commands are run using OC's general fake player.
enableCommandBlockDriver: false
# Whether to allow the item stack converter to push NBT data in # Whether to allow the item stack converter to push NBT data in
# compressed format (GZIP'ed). This can be useful for pushing this # compressed format (GZIP'ed). This can be useful for pushing this
# data back to other callbacks. However, given a sophisticated # data back to other callbacks. However, given a sophisticated

View File

@ -298,6 +298,7 @@ class Settings(val config: Config) {
// integration.vanilla // integration.vanilla
val enableInventoryDriver = config.getBoolean("integration.vanilla.enableInventoryDriver") val enableInventoryDriver = config.getBoolean("integration.vanilla.enableInventoryDriver")
val enableTankDriver = config.getBoolean("integration.vanilla.enableTankDriver") val enableTankDriver = config.getBoolean("integration.vanilla.enableTankDriver")
val enableCommandBlockDriver = config.getBoolean("integration.vanilla.enableCommandBlockDriver")
val allowItemStackNBTTags = config.getBoolean("integration.vanilla.allowItemStackNBTTags") val allowItemStackNBTTags = config.getBoolean("integration.vanilla.allowItemStackNBTTags")
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //

View File

@ -11,6 +11,7 @@ import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockJukebox; import net.minecraft.block.BlockJukebox;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord; import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
@ -57,5 +58,22 @@ public final class DriverRecordPlayer extends DriverTileEntity implements Enviro
} }
return new Object[]{((ItemRecord) record.getItem()).getRecordNameLocal()}; return new Object[]{((ItemRecord) record.getItem()).getRecordNameLocal()};
} }
@Callback(doc = "function() -- Start playing the record currently in the jukebox.")
public Object[] play(final Context context, final Arguments args) {
final ItemStack record = tileEntity.func_145856_a();
if (record == null || !(record.getItem() instanceof ItemRecord)) {
return null;
}
tileEntity.getWorldObj().playAuxSFXAtEntity(null, 1005, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, Item.getIdFromItem(record.getItem()));
return new Object[]{true};
}
@Callback(doc = "function() -- Stop playing the record currently in the jukebox.")
public Object[] stop(final Context context, final Arguments args) {
tileEntity.getWorldObj().playAuxSFX(1005, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, 0);
tileEntity.getWorldObj().playRecord(null, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
return null;
}
} }
} }

View File

@ -11,7 +11,6 @@ object ModVanilla extends ModProxy {
def initialize() { def initialize() {
Driver.add(new DriverBeacon) Driver.add(new DriverBeacon)
Driver.add(new DriverBrewingStand) Driver.add(new DriverBrewingStand)
Driver.add(new DriverCommandBlock)
Driver.add(new DriverComparator) Driver.add(new DriverComparator)
Driver.add(new DriverFurnace) Driver.add(new DriverFurnace)
Driver.add(new DriverMobSpawner) Driver.add(new DriverMobSpawner)
@ -25,6 +24,9 @@ object ModVanilla extends ModProxy {
Driver.add(new DriverFluidHandler) Driver.add(new DriverFluidHandler)
Driver.add(new DriverFluidTank) Driver.add(new DriverFluidTank)
} }
if (Settings.get.enableCommandBlockDriver) {
Driver.add(new DriverCommandBlock)
}
Driver.add(ConverterFluidStack) Driver.add(ConverterFluidStack)
Driver.add(ConverterFluidTankInfo) Driver.add(ConverterFluidTankInfo)

View File

@ -424,6 +424,20 @@ object DebugCard {
} }
} }
@Callback(doc = """function(x:number, y:number, z:number, slot:number[, count:number]):number - Reduce the size of an item stack in the inventory at the specified location.""")
def removeItem(context: Context, args: Arguments): Array[AnyRef] = {
val position = BlockPosition(args.checkDouble(0), args.checkDouble(1), args.checkDouble(2), world)
InventoryUtils.inventoryAt(position) match {
case Some(inventory) =>
val slot = args.checkSlot(inventory, 3)
val count = args.optInteger(4, inventory.getInventoryStackLimit)
val removed = inventory.decrStackSize(slot, count)
if (removed == null) result(0)
else result(removed.stackSize)
case _ => result(null, "no inventory")
}
}
// ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- //
override def load(nbt: NBTTagCompound) { override def load(nbt: NBTTagCompound) {