mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Merge pull request #2180 from Vexatos/fuzzy-compare
Added metadata-ignoring fuzzy option to robot.compare.
This commit is contained in:
commit
ffc65616c0
@ -72,16 +72,16 @@ end
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Inventory + World
|
-- Inventory + World
|
||||||
|
|
||||||
function robot.compare()
|
function robot.compare(fuzzy)
|
||||||
return component.robot.compare(sides.front)
|
return component.robot.compare(sides.front, fuzzy)
|
||||||
end
|
end
|
||||||
|
|
||||||
function robot.compareUp()
|
function robot.compareUp(fuzzy)
|
||||||
return component.robot.compare(sides.up)
|
return component.robot.compare(sides.up, fuzzy)
|
||||||
end
|
end
|
||||||
|
|
||||||
function robot.compareDown()
|
function robot.compareDown(fuzzy)
|
||||||
return component.robot.compare(sides.down)
|
return component.robot.compare(sides.down, fuzzy)
|
||||||
end
|
end
|
||||||
|
|
||||||
function robot.drop(count)
|
function robot.drop(count)
|
||||||
|
@ -13,7 +13,7 @@ import net.minecraft.item.ItemBlock
|
|||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
|
||||||
trait InventoryWorldControl extends InventoryAware with WorldAware with SideRestricted {
|
trait InventoryWorldControl extends InventoryAware with WorldAware with SideRestricted {
|
||||||
@Callback(doc = "function(side:number):boolean -- Compare the block on the specified side with the one in the selected slot. Returns true if equal.")
|
@Callback(doc = "function(side:number[, fuzzy:boolean=false]):boolean -- Compare the block on the specified side with the one in the selected slot. Returns true if equal.")
|
||||||
def compare(context: Context, args: Arguments): Array[AnyRef] = {
|
def compare(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val side = checkSideForAction(args, 0)
|
val side = checkSideForAction(args, 0)
|
||||||
stackInSlot(selectedSlot) match {
|
stackInSlot(selectedSlot) match {
|
||||||
@ -21,7 +21,7 @@ trait InventoryWorldControl extends InventoryAware with WorldAware with SideRest
|
|||||||
case Some(item: ItemBlock) =>
|
case Some(item: ItemBlock) =>
|
||||||
val blockPos = position.offset(side)
|
val blockPos = position.offset(side)
|
||||||
val idMatches = item.field_150939_a == world.getBlock(blockPos)
|
val idMatches = item.field_150939_a == world.getBlock(blockPos)
|
||||||
val subTypeMatches = !item.getHasSubtypes || item.getMetadata(stack.getItemDamage) == world.getBlockMetadata(blockPos)
|
val subTypeMatches = args.optBoolean(1, false) || !item.getHasSubtypes || item.getMetadata(stack.getItemDamage) == world.getBlockMetadata(blockPos)
|
||||||
return result(idMatches && subTypeMatches)
|
return result(idMatches && subTypeMatches)
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user