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

Conflicts:
	src/main/scala/li/cil/oc/common/tileentity/Disassembler.scala
	src/main/scala/li/cil/oc/util/InventoryUtils.scala
This commit is contained in:
Florian Nücke 2015-07-11 22:52:35 +02:00
commit c29366d2f0
7 changed files with 90 additions and 7 deletions

View File

@ -23,7 +23,6 @@
### Расширения
* [Адаптер](adapter.md)
* [Кабель](cable.md)
* [Геоанализатор](geolyzer.md)
* [Датчик движения](motionSensor.md)
* [Редстоун I/O](redstone.md)
@ -38,6 +37,8 @@
## Сеть
* [Точка доступа](accessPoint.md)
* [Кабель](cable.md)
* [Сетевой переключатель](netSplitter.md)
* [Коммутатор](switch.md)
## Управление питанием

View File

@ -0,0 +1,7 @@
# Сетевой переключатель
![*.net *.split](oredict:oc:netSplitter)
Сетевой переключатель позволяет контролировать соединение между подсетями. В отличие от [коммутатора](switch.md) или [конвертера энергии](powerConverter.md) позволяет непосредственно соединить подсети, делая при этом доступными все компоненты. Соединение каждой стороны переключается [ключем](../item/wrench.md). При подаче сигнала красного камня все соединения инвертируются.
Таким образом, этот блок может быть использован для переключения соединения определенных компонентов сети. Используйте [редстоун I/O](redstone.md) или [редстоун карты](../item/redstoneCard1.md) для автоматизации сетевого переключателя.

View File

@ -36,6 +36,7 @@ tile.oc.screen2.name=Монитор (2-ой уровень)
tile.oc.screen3.name=Монитор (3-ий уровень)
tile.oc.serverRack.name=Серверная стойка
tile.oc.switch.name=Коммутатор
tile.oc.netSplitter.name=Сетевой переключатель
tile.oc.waypoint.name=Путевая точка
# Items
@ -330,6 +331,7 @@ oc:tooltip.TabletCase=Простой корпус для планшета. По
oc:tooltip.Terminal=Позволяет дистанционно управлять сервером, пока вы находитесь в радиусе его действия. Действует как портативный дисплей с клавиатурой.[nl] Shift+ПКМ по серверу в стойке для привязки к нему терминала.
oc:tooltip.TexturePicker=Простой инструмент, позволяющий узнать название текстуры блока, которое можно использовать в 3D печати.
oc:tooltip.Tier=§8Уровень %s
oc:tooltip.NetSplitter=Работает как переключатель. Соединение каждой стороны переключается ключем. При подаче сигнала красного камня все соединения инвертируются.
oc:tooltip.TooLong=Удерживайте [§f%s§7], чтобы отобразить описание.
oc:tooltip.Transistor=Базовый элемент для других частей компьютера. Он немного деформирован, но отлично выполняет свою работу.
oc:tooltip.UpgradeAngel=Позволяет роботам размещать блоки в воздухе, даже если отсутствует точка опоры.

View File

@ -36,7 +36,7 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
var disassembleNextInstantly = false
def progress = if (queue.isEmpty) 0 else (1 - (queue.size * Settings.get.disassemblerItemCost - buffer) / totalRequiredEnergy) * 100
def progress = if (queue.isEmpty) 0.0 else (1 - (queue.size * Settings.get.disassemblerItemCost - buffer) / totalRequiredEnergy) * 100
private def setActive(value: Boolean) = if (value != isActive) {
isActive = value
@ -113,7 +113,7 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
private def drop(stack: ItemStack) {
if (stack != null) {
for (side <- EnumFacing.values if stack.stackSize > 0) {
InventoryUtils.insertIntoInventoryAt(stack, BlockPosition(this).offset(side), side.getOpposite)
InventoryUtils.insertIntoInventoryAt(stack, BlockPosition(this).offset(side), Some(side.getOpposite))
}
if (stack.stackSize > 0) {
spawnStackInWorld(stack, Option(EnumFacing.UP))
@ -160,7 +160,7 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
override def isItemValidForSlot(i: Int, stack: ItemStack) =
allowDisassembling(stack) &&
(((Settings.get.disassembleAllTheThings || api.Items.get(stack) != null) && ItemUtils.getIngredients(stack).nonEmpty) ||
DisassemblerTemplates.select(stack) != None)
DisassemblerTemplates.select(stack).isDefined)
private def allowDisassembling(stack: ItemStack) = stack != null && (!stack.hasTagCompound || !stack.getTagCompound.getBoolean(Settings.namespace + "undisassemblable"))

View File

@ -4,7 +4,8 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent
object CommandHandler {
def register(e: FMLServerStartingEvent) {
e.registerServerCommand(WirelessRenderingCommand)
e.registerServerCommand(NonDisassemblyAgreementCommand)
e.registerServerCommand(WirelessRenderingCommand)
e.registerServerCommand(SpawnComputerCommand)
}
}

View File

@ -0,0 +1,72 @@
package li.cil.oc.server.command
import li.cil.oc.Constants
import li.cil.oc.api
import li.cil.oc.common.command.SimpleCommand
import li.cil.oc.common.tileentity
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import li.cil.oc.util.InventoryUtils
import net.minecraft.command.ICommandSender
import net.minecraft.command.WrongUsageException
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.ChatComponentText
import net.minecraft.util.EnumFacing
import net.minecraft.util.MovingObjectPosition
import net.minecraft.util.Vec3
object SpawnComputerCommand extends SimpleCommand("oc_spawnComputer") {
aliases += "oc_sc"
final val MaxDistance = 16
override def getCommandUsage(source: ICommandSender): String = name
override def execute(source: ICommandSender, command: Array[String]) {
source match {
case player: EntityPlayer =>
val world = player.getEntityWorld
val origin = new Vec3(player.posX, player.posY + player.getEyeHeight, player.posZ)
val direction = player.getLookVec
val lookAt = origin.addVector(direction.xCoord * MaxDistance, direction.yCoord * MaxDistance, direction.zCoord * MaxDistance)
world.rayTraceBlocks(origin, lookAt) match {
case hit: MovingObjectPosition if hit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK =>
val hitPos = BlockPosition(hit.getBlockPos, world)
val casePos = hitPos.offset(hit.sideHit)
val screenPos = casePos.offset(EnumFacing.UP)
val keyboardPos = screenPos.offset(EnumFacing.UP)
if (!world.isAirBlock(casePos) || !world.isAirBlock(screenPos) || !world.isAirBlock(keyboardPos)) {
player.addChatMessage(new ChatComponentText("Target position obstructed."))
return
}
world.setBlock(casePos, api.Items.get(Constants.BlockName.CaseCreative).block())
world.setBlock(screenPos, api.Items.get(Constants.BlockName.ScreenTier2).block())
world.setBlock(keyboardPos, api.Items.get(Constants.BlockName.Keyboard).block())
world.getTileEntity(keyboardPos) match {
case t: tileentity.traits.Rotatable => t.setFromFacing(EnumFacing.UP)
case _ => // ???
}
api.Network.joinOrCreateNetwork(world.getTileEntity(casePos))
InventoryUtils.insertIntoInventoryAt(api.Items.get(Constants.ItemName.APUCreative).createItemStack(1), casePos)
InventoryUtils.insertIntoInventoryAt(api.Items.get(Constants.ItemName.RAMTier6).createItemStack(2), casePos)
InventoryUtils.insertIntoInventoryAt(api.Items.get(Constants.ItemName.HDDTier3).createItemStack(1), casePos)
InventoryUtils.insertIntoInventoryAt(api.Items.get(Constants.ItemName.LuaBios).createItemStack(1), casePos)
InventoryUtils.insertIntoInventoryAt(api.Items.get(Constants.ItemName.OpenOS).createItemStack(1), casePos)
case _ => player.addChatMessage(new ChatComponentText("You need to be looking at a nearby block."))
}
case _ => throw new WrongUsageException("Can only be used by players.")
}
}
// OP levels for reference:
// 1 - Ops can bypass spawn protection.
// 2 - Ops can use /clear, /difficulty, /effect, /gamemode, /gamerule, /give, /summon, /setblock and /tp, and can edit command blocks.
// 3 - Ops can use /ban, /deop, /kick, and /op.
// 4 - Ops can use /stop.
override def getRequiredPermissionLevel = 2
}

View File

@ -211,8 +211,8 @@ object InventoryUtils {
* Utility method for calling <tt>insertIntoInventory</tt> on an inventory
* in the world.
*/
def insertIntoInventoryAt(stack: ItemStack, position: BlockPosition, side: EnumFacing, limit: Int = 64, simulate: Boolean = false): Boolean =
inventoryAt(position).exists(insertIntoInventory(stack, _, Option(side), limit, simulate))
def insertIntoInventoryAt(stack: ItemStack, position: BlockPosition, side: Option[EnumFacing] = None, limit: Int = 64, simulate: Boolean = false): Boolean =
inventoryAt(position).exists(insertIntoInventory(stack, _, side, limit, simulate))
/**
* Utility method for calling <tt>extractFromInventory</tt> on an inventory