mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Merge remote-tracking branch 'origin/master-MC1.7.10' into master-MC1.7.10
This commit is contained in:
commit
afff699dff
@ -21,7 +21,7 @@ local function get(pasteId, filename)
|
||||
end
|
||||
|
||||
io.write("Downloading from pastebin.com... ")
|
||||
local url = "http://pastebin.com/raw.php?i=" .. pasteId
|
||||
local url = "http://pastebin.com/raw/" .. pasteId
|
||||
local result, response = pcall(internet.request, url)
|
||||
if result then
|
||||
io.write("success.\n")
|
||||
|
@ -15,7 +15,8 @@ function loadfile(filename, mode, env)
|
||||
end
|
||||
table.insert(buffer, data)
|
||||
end
|
||||
buffer = table.concat(buffer):gsub("^#![^\n]+", "") -- remove shebang if any
|
||||
buffer[1] = (buffer[1] or ""):gsub("^#![^\n]+", "") -- remove shebang if any
|
||||
buffer = table.concat(buffer)
|
||||
return load(buffer, "=" .. filename, mode, env)
|
||||
end
|
||||
|
||||
|
@ -390,7 +390,13 @@ function term.drawText(value, wrap, window)
|
||||
local function scroll(_sy,_y)
|
||||
return _sy + term.internal.scroll(window,_y-h), math.min(_y,h)
|
||||
end
|
||||
local uptime = computer.uptime
|
||||
local last_sleep = uptime()
|
||||
while index <= vlen do
|
||||
if uptime() - last_sleep > 4 then
|
||||
os.sleep(0)
|
||||
last_sleep = uptime()
|
||||
end
|
||||
local si,ei = value:find("[\t\r\n\a]", index)
|
||||
si = si or vlen+1
|
||||
if index==si then
|
||||
@ -401,7 +407,7 @@ function term.drawText(value, wrap, window)
|
||||
x,y=1,y+1
|
||||
sy,y = scroll(sy,y)
|
||||
elseif delim=="\a" and not beeped then
|
||||
require("computer").beep()
|
||||
computer.beep()
|
||||
beeped = true
|
||||
end
|
||||
cr_last = delim == "\r"
|
||||
|
@ -583,6 +583,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
||||
}
|
||||
|
||||
override def writeEntityToNBT(nbt: NBTTagCompound) {
|
||||
if (worldObj.isRemote) return
|
||||
components.saveComponents()
|
||||
info.storedEnergy = control.node.localBuffer.toInt
|
||||
nbt.setNewCompoundTag("info", info.save)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package li.cil.oc.server.component.traits
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.machine.Arguments
|
||||
import li.cil.oc.api.machine.Callback
|
||||
@ -10,7 +11,9 @@ import li.cil.oc.util.InventoryUtils
|
||||
import li.cil.oc.util.ResultWrapper.result
|
||||
import net.minecraft.entity.item.EntityItem
|
||||
import net.minecraft.item.ItemBlock
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent
|
||||
|
||||
trait InventoryWorldControl extends InventoryAware with WorldAware with SideRestricted {
|
||||
@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.")
|
||||
@ -54,8 +57,15 @@ trait InventoryWorldControl extends InventoryAware with WorldAware with SideRest
|
||||
case _ =>
|
||||
// No inventory to drop into, drop into the world.
|
||||
val dropped = inventory.decrStackSize(selectedSlot, count)
|
||||
val validator = (item: EntityItem) => {
|
||||
val event = new ItemTossEvent(item, fakePlayer)
|
||||
val canceled = MinecraftForge.EVENT_BUS.post(event)
|
||||
val denied = event.hasResult && event.getResult == Result.DENY
|
||||
!canceled && !denied
|
||||
}
|
||||
if (dropped != null && dropped.stackSize > 0) {
|
||||
InventoryUtils.spawnStackInWorld(position, dropped, Some(facing))
|
||||
if (InventoryUtils.spawnStackInWorld(position, dropped, Some(facing), Some(validator)) == null)
|
||||
fakePlayer.inventory.addItemStackToInventory(dropped)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,14 +227,14 @@ object InventoryUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts an item stack from an inventory.
|
||||
* <p/>
|
||||
* This will try to remove items of the same type as the specified item stack
|
||||
* up to the number of the stack's size for all slots in the specified inventory.
|
||||
* <p/>
|
||||
* This uses the <tt>extractFromInventorySlot</tt> method, and therefore
|
||||
* handles special cases such as sided inventories and stack size limits.
|
||||
*/
|
||||
* Extracts an item stack from an inventory.
|
||||
* <p/>
|
||||
* This will try to remove items of the same type as the specified item stack
|
||||
* up to the number of the stack's size for all slots in the specified inventory.
|
||||
* <p/>
|
||||
* This uses the <tt>extractFromInventorySlot</tt> method, and therefore
|
||||
* handles special cases such as sided inventories and stack size limits.
|
||||
*/
|
||||
def extractFromInventory(stack: ItemStack, inventory: IInventory, side: ForgeDirection, simulate: Boolean = false) = {
|
||||
val range = inventory match {
|
||||
case sided: ISidedInventory => sided.getAccessibleSlotsFromSide(side.ordinal).toIterable
|
||||
@ -362,7 +362,7 @@ object InventoryUtils {
|
||||
/**
|
||||
* Utility method for spawning an item stack in the world.
|
||||
*/
|
||||
def spawnStackInWorld(position: BlockPosition, stack: ItemStack, direction: Option[ForgeDirection] = None): EntityItem = position.world match {
|
||||
def spawnStackInWorld(position: BlockPosition, stack: ItemStack, direction: Option[ForgeDirection] = None, validator: Option[EntityItem => Boolean] = None): EntityItem = position.world match {
|
||||
case Some(world) if stack != null && stack.stackSize > 0 =>
|
||||
val rng = world.rand
|
||||
val (ox, oy, oz) = direction.fold((0, 0, 0))(d => (d.offsetX, d.offsetY, d.offsetZ))
|
||||
@ -376,8 +376,11 @@ object InventoryUtils {
|
||||
entity.motionY = 0.0125 * (rng.nextDouble - 0.5) + oy * 0.08 + (ox + oz) * 0.03
|
||||
entity.motionZ = 0.0125 * (rng.nextDouble - 0.5) + oz * 0.03
|
||||
entity.delayBeforeCanPickup = 15
|
||||
world.spawnEntityInWorld(entity)
|
||||
entity
|
||||
if (validator.fold(true)(_(entity))) {
|
||||
world.spawnEntityInWorld(entity)
|
||||
entity
|
||||
}
|
||||
else null
|
||||
case _ => null
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user