mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-24 04:50:30 -04:00
Include block drones are in when looking for items to suck in, to make that less awkward.
This commit is contained in:
parent
fafa9e42ae
commit
95e2feef65
@ -26,7 +26,6 @@ import net.minecraft.entity.item.EntityItem
|
|||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraft.util.AxisAlignedBB
|
|
||||||
import net.minecraft.util.MovingObjectPosition
|
import net.minecraft.util.MovingObjectPosition
|
||||||
import net.minecraft.util.Vec3
|
import net.minecraft.util.Vec3
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
|
@ -8,6 +8,7 @@ import li.cil.oc.api.machine.Context
|
|||||||
import li.cil.oc.api.network.Visibility
|
import li.cil.oc.api.network.Visibility
|
||||||
import li.cil.oc.api.prefab
|
import li.cil.oc.api.prefab
|
||||||
import li.cil.oc.common.entity
|
import li.cil.oc.common.entity
|
||||||
|
import li.cil.oc.util.BlockPosition
|
||||||
import li.cil.oc.util.ExtendedArguments._
|
import li.cil.oc.util.ExtendedArguments._
|
||||||
import li.cil.oc.util.InventoryUtils
|
import li.cil.oc.util.InventoryUtils
|
||||||
import net.minecraft.entity.item.EntityItem
|
import net.minecraft.entity.item.EntityItem
|
||||||
@ -45,6 +46,8 @@ class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with trait
|
|||||||
override protected def checkSideForAction(args: Arguments, n: Int) =
|
override protected def checkSideForAction(args: Arguments, n: Int) =
|
||||||
args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
|
args.checkSide(n, ForgeDirection.VALID_DIRECTIONS: _*)
|
||||||
|
|
||||||
|
override protected def suckableItems(side: ForgeDirection) = entitiesInBlock(BlockPosition(host)) ++ super.suckableItems(side)
|
||||||
|
|
||||||
override protected def onSuckCollect(entity: EntityItem) = {
|
override protected def onSuckCollect(entity: EntityItem) = {
|
||||||
world.playSoundAtEntity(host, "random.pop", 0.2f, ((world.rand.nextFloat - world.rand.nextFloat) * 0.7f + 1) * 2)
|
world.playSoundAtEntity(host, "random.pop", 0.2f, ((world.rand.nextFloat - world.rand.nextFloat) * 0.7f + 1) * 2)
|
||||||
InventoryUtils.insertIntoInventory(entity.getEntityItem, inventory, slots = Option(insertionSlots))
|
InventoryUtils.insertIntoInventory(entity.getEntityItem, inventory, slots = Option(insertionSlots))
|
||||||
@ -52,6 +55,8 @@ class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with trait
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
@Callback(doc = "function(dx:number, dy:number, dz:number) -- Change the target position by the specified offset.")
|
@Callback(doc = "function(dx:number, dy:number, dz:number) -- Change the target position by the specified offset.")
|
||||||
def move(context: Context, args: Arguments): Array[AnyRef] = {
|
def move(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val dx = args.checkDouble(0).toFloat
|
val dx = args.checkDouble(0).toFloat
|
||||||
@ -67,10 +72,15 @@ class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with trait
|
|||||||
def getOffset(context: Context, args: Arguments): Array[AnyRef] =
|
def getOffset(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
result(host.getDistance(host.targetX, host.targetY, host.targetZ))
|
result(host.getDistance(host.targetX, host.targetY, host.targetZ))
|
||||||
|
|
||||||
@Callback(doc = "function():number -- Get the current velocity.")
|
@Callback(doc = "function():number -- Get the current velocity in m/s.")
|
||||||
def getVelocity(context: Context, args: Arguments): Array[AnyRef] =
|
def getVelocity(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
result(math.sqrt(host.motionX * host.motionX + host.motionY * host.motionY + host.motionZ * host.motionZ) * 20) // per second
|
result(math.sqrt(host.motionX * host.motionX + host.motionY * host.motionY + host.motionZ * host.motionZ) * 20) // per second
|
||||||
|
|
||||||
|
@Callback(doc = "function():number -- Get the maximum velocity, in m/s.")
|
||||||
|
def getMaxVelocity(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
result(host.maxVelocity * 20) // per second
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = "function():number -- Get the currently set acceleration.")
|
@Callback(doc = "function():number -- Get the currently set acceleration.")
|
||||||
def getAcceleration(context: Context, args: Arguments): Array[AnyRef] = {
|
def getAcceleration(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
result(host.targetAcceleration * 20) // per second
|
result(host.targetAcceleration * 20) // per second
|
||||||
|
@ -11,6 +11,7 @@ import li.cil.oc.util.InventoryUtils
|
|||||||
import li.cil.oc.util.ResultWrapper.result
|
import li.cil.oc.util.ResultWrapper.result
|
||||||
import net.minecraft.entity.item.EntityItem
|
import net.minecraft.entity.item.EntityItem
|
||||||
import net.minecraft.item.ItemBlock
|
import net.minecraft.item.ItemBlock
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
|
||||||
trait InventoryWorldInterop extends InventoryAware with WorldAware with SideRestricted {
|
trait InventoryWorldInterop extends InventoryAware with WorldAware with SideRestricted {
|
||||||
@Callback
|
@Callback
|
||||||
@ -74,7 +75,7 @@ trait InventoryWorldInterop extends InventoryAware with WorldAware with SideRest
|
|||||||
result(true)
|
result(true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (entity <- entitiesOnSide[EntityItem](facing) if !entity.isDead && entity.delayBeforeCanPickup <= 0) {
|
for (entity <- suckableItems(facing) if !entity.isDead && entity.delayBeforeCanPickup <= 0) {
|
||||||
val stack = entity.getEntityItem
|
val stack = entity.getEntityItem
|
||||||
val size = stack.stackSize
|
val size = stack.stackSize
|
||||||
onSuckCollect(entity)
|
onSuckCollect(entity)
|
||||||
@ -87,5 +88,7 @@ trait InventoryWorldInterop extends InventoryAware with WorldAware with SideRest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected def suckableItems(side: ForgeDirection) = entitiesOnSide[EntityItem](side)
|
||||||
|
|
||||||
protected def onSuckCollect(entity: EntityItem): Unit = entity.onCollideWithPlayer(fakePlayer)
|
protected def onSuckCollect(entity: EntityItem): Unit = entity.onCollideWithPlayer(fakePlayer)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user