mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-11 16:28:12 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
Conflicts: src/main/scala/li/cil/oc/common/nanomachines/provider/ParticleProvider.scala src/main/scala/li/cil/oc/common/tileentity/Charger.scala
This commit is contained in:
commit
f190fa2aaf
@ -995,7 +995,7 @@ opencomputers {
|
|||||||
# if there are a total of 10 behaviors available, 0.5 means there will
|
# if there are a total of 10 behaviors available, 0.5 means there will
|
||||||
# be 5 trigger inputs, triggers being the inputs that can be activated
|
# be 5 trigger inputs, triggers being the inputs that can be activated
|
||||||
# via nanomachines.
|
# via nanomachines.
|
||||||
triggerQuota: 0.5
|
triggerQuota: 0.4
|
||||||
|
|
||||||
# The relative number of connectors based on the number of available
|
# The relative number of connectors based on the number of available
|
||||||
# behaviors (see triggerQuota).
|
# behaviors (see triggerQuota).
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
### Карты
|
### Карты
|
||||||
* [Карта абстрактной шины](abstractBusCard.md)
|
* [Карта абстрактной шины](abstractBusCard.md)
|
||||||
* [Карта данных](dataCard.md)
|
* [Карта данных](dataCard1.md)
|
||||||
* [Отладочная карта](debugCard.md)
|
* [Отладочная карта](debugCard.md)
|
||||||
* [Видеокарта](graphicsCard1.md)
|
* [Видеокарта](graphicsCard1.md)
|
||||||
* [Интернет карта](internetCard.md)
|
* [Интернет карта](internetCard.md)
|
||||||
|
@ -63,5 +63,5 @@ trait InventoryProxy extends IInventory {
|
|||||||
|
|
||||||
override def getField(id: Int) = inventory.getField(id)
|
override def getField(id: Int) = inventory.getField(id)
|
||||||
|
|
||||||
private def isValidSlot(slot: Int) = slot >= 0 && slot < getSizeInventory
|
private def isValidSlot(slot: Int) = slot >= offset && slot < getSizeInventory + offset
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,13 @@ class ControllerImpl(val player: EntityPlayer) extends Controller with WirelessE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def debug(): Unit = {
|
||||||
|
if (isServer) {
|
||||||
|
configuration.debug()
|
||||||
|
activeBehaviorsDirty = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
def save(nbt: NBTTagCompound): Unit = configuration.synchronized {
|
def save(nbt: NBTTagCompound): Unit = configuration.synchronized {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package li.cil.oc.common.nanomachines
|
package li.cil.oc.common.nanomachines
|
||||||
|
|
||||||
|
import li.cil.oc.OpenComputers
|
||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api
|
import li.cil.oc.api
|
||||||
import li.cil.oc.api.Persistable
|
import li.cil.oc.api.Persistable
|
||||||
@ -83,6 +84,29 @@ class NeuralNetwork(controller: ControllerImpl) extends Persistable {
|
|||||||
behaviorMap ++= behaviors.map(n => n.behavior -> n)
|
behaviorMap ++= behaviors.map(n => n.behavior -> n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enter debug configuration, one input -> one behavior, and list mapping in console.
|
||||||
|
def debug(): Unit = {
|
||||||
|
OpenComputers.log.info(s"Creating debug configuration for nanomachines in player ${controller.player.getDisplayName}.")
|
||||||
|
|
||||||
|
behaviors.clear()
|
||||||
|
behaviors ++= api.Nanomachines.getProviders.
|
||||||
|
map(p => (p, Option(p.createBehaviors(controller.player)).map(_.filter(_ != null)).orNull)). // Remove null behaviors.
|
||||||
|
filter(_._2 != null). // Remove null lists..
|
||||||
|
flatMap(pb => pb._2.map(b => new BehaviorNeuron(pb._1, b)))
|
||||||
|
|
||||||
|
connectors.clear()
|
||||||
|
|
||||||
|
triggers.clear()
|
||||||
|
for (i <- behaviors.indices) {
|
||||||
|
val behavior = behaviors(i)
|
||||||
|
val trigger = new TriggerNeuron()
|
||||||
|
triggers += trigger
|
||||||
|
behavior.inputs += trigger
|
||||||
|
|
||||||
|
OpenComputers.log.info(s"$i -> ${behavior.behavior.getNameHint} (${behavior.behavior.getClass.toString})")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override def save(nbt: NBTTagCompound): Unit = {
|
override def save(nbt: NBTTagCompound): Unit = {
|
||||||
nbt.setNewTagList("triggers", triggers.map(t => {
|
nbt.setNewTagList("triggers", triggers.map(t => {
|
||||||
val nbt = new NBTTagCompound()
|
val nbt = new NBTTagCompound()
|
||||||
@ -149,7 +173,7 @@ class NeuralNetwork(controller: ControllerImpl) extends Persistable {
|
|||||||
class ConnectorNeuron extends Neuron {
|
class ConnectorNeuron extends Neuron {
|
||||||
val inputs = mutable.ArrayBuffer.empty[Neuron]
|
val inputs = mutable.ArrayBuffer.empty[Neuron]
|
||||||
|
|
||||||
override def isActive = inputs.exists(_.isActive)
|
override def isActive = inputs.forall(_.isActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
class BehaviorNeuron(val provider: BehaviorProvider, val behavior: Behavior) extends ConnectorNeuron
|
class BehaviorNeuron(val provider: BehaviorProvider, val behavior: Behavior) extends ConnectorNeuron
|
||||||
|
@ -41,7 +41,7 @@ object ParticleProvider extends ScalaProvider("b48c4bbd-51bb-4915-9367-16cff3220
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ParticleBehavior(var effectType: EnumParticleTypes, player: EntityPlayer) extends AbstractBehavior(player) {
|
class ParticleBehavior(var effectType: EnumParticleTypes, player: EntityPlayer) extends AbstractBehavior(player) {
|
||||||
override def getNameHint = "particles"
|
override def getNameHint = "particles." + effectType.getParticleName
|
||||||
|
|
||||||
override def update(): Unit = {
|
override def update(): Unit = {
|
||||||
val world = player.getEntityWorld
|
val world = player.getEntityWorld
|
||||||
|
@ -226,14 +226,29 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
|
|||||||
|
|
||||||
abstract class ConnectorChargeable(val connector: Connector) extends Chargeable {
|
abstract class ConnectorChargeable(val connector: Connector) extends Chargeable {
|
||||||
override def changeBuffer(delta: Double): Double = connector.changeBuffer(delta)
|
override def changeBuffer(delta: Double): Double = connector.changeBuffer(delta)
|
||||||
|
|
||||||
|
override def equals(obj: scala.Any): Boolean = obj match {
|
||||||
|
case chargeable: ConnectorChargeable => chargeable.connector == chargeable
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RobotChargeable(val robot: Robot) extends ConnectorChargeable(robot.node.asInstanceOf[Connector]) {
|
class RobotChargeable(val robot: Robot) extends ConnectorChargeable(robot.node.asInstanceOf[Connector]) {
|
||||||
override def pos: Vec3 = BlockPosition(robot).toVec3
|
override def pos: Vec3 = BlockPosition(robot).toVec3
|
||||||
|
|
||||||
|
override def equals(obj: scala.Any): Boolean = obj match {
|
||||||
|
case chargeable: RobotChargeable => chargeable.robot == robot
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DroneChargeable(val drone: Drone) extends ConnectorChargeable(drone.components.node.asInstanceOf[Connector]) {
|
class DroneChargeable(val drone: Drone) extends ConnectorChargeable(drone.components.node.asInstanceOf[Connector]) {
|
||||||
override def pos: Vec3 = new Vec3(drone.posX, drone.posY, drone.posZ)
|
override def pos: Vec3 = new Vec3(drone.posX, drone.posY, drone.posZ)
|
||||||
|
|
||||||
|
override def equals(obj: scala.Any): Boolean = obj match {
|
||||||
|
case chargeable: DroneChargeable => chargeable.drone == drone
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PlayerChargeable(val player: EntityPlayer) extends Chargeable {
|
class PlayerChargeable(val player: EntityPlayer) extends Chargeable {
|
||||||
@ -245,6 +260,11 @@ class Charger extends traits.Environment with traits.PowerAcceptor with traits.R
|
|||||||
case _ => delta // Cannot charge.
|
case _ => delta // Cannot charge.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override def equals(obj: scala.Any): Boolean = obj match {
|
||||||
|
case chargeable: PlayerChargeable => chargeable.player == player
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,12 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
|
|||||||
while (buffer >= Settings.get.disassemblerItemCost && queue.nonEmpty) {
|
while (buffer >= Settings.get.disassemblerItemCost && queue.nonEmpty) {
|
||||||
buffer -= Settings.get.disassemblerItemCost
|
buffer -= Settings.get.disassemblerItemCost
|
||||||
val stack = queue.remove(0)
|
val stack = queue.remove(0)
|
||||||
if (world.rand.nextDouble >= Settings.get.disassemblerBreakChance) {
|
if (disassembleNextInstantly || world.rand.nextDouble >= Settings.get.disassemblerBreakChance) {
|
||||||
drop(stack)
|
drop(stack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
disassembleNextInstantly = queue.nonEmpty // If we have nothing left to do, stop being creative.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +106,11 @@ class Disassembler extends traits.Environment with traits.PowerAcceptor with tra
|
|||||||
totalRequiredEnergy = queue.size * Settings.get.disassemblerItemCost
|
totalRequiredEnergy = queue.size * Settings.get.disassemblerItemCost
|
||||||
if (instant) {
|
if (instant) {
|
||||||
buffer = totalRequiredEnergy
|
buffer = totalRequiredEnergy
|
||||||
disassembleNextInstantly = false // Just to be sure...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
drop(stack)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def drop(stack: ItemStack) {
|
private def drop(stack: ItemStack) {
|
||||||
|
@ -39,7 +39,7 @@ object Mods {
|
|||||||
val CraftingCosts = new SimpleMod(IDs.CraftingCosts)
|
val CraftingCosts = new SimpleMod(IDs.CraftingCosts)
|
||||||
val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit")()
|
val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit")()
|
||||||
val ElectricalAge = new SimpleMod(IDs.ElectricalAge, providesPower = true)
|
val ElectricalAge = new SimpleMod(IDs.ElectricalAge, providesPower = true)
|
||||||
val EnderIO = new SimpleMod(IDs.EnderIO)
|
val EnderIO = new SimpleMod(IDs.EnderIO, version = "@[2.2,2.3)")
|
||||||
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
||||||
val ExtraCells = new SimpleMod(IDs.ExtraCells, version = "@[2.2.73,)")
|
val ExtraCells = new SimpleMod(IDs.ExtraCells, version = "@[2.2.73,)")
|
||||||
val Factorization = new SimpleMod(IDs.Factorization, providesPower = true)
|
val Factorization = new SimpleMod(IDs.Factorization, providesPower = true)
|
||||||
|
@ -4,6 +4,7 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent
|
|||||||
|
|
||||||
object CommandHandler {
|
object CommandHandler {
|
||||||
def register(e: FMLServerStartingEvent) {
|
def register(e: FMLServerStartingEvent) {
|
||||||
|
e.registerServerCommand(DebugNanomachinesCommand)
|
||||||
e.registerServerCommand(NonDisassemblyAgreementCommand)
|
e.registerServerCommand(NonDisassemblyAgreementCommand)
|
||||||
e.registerServerCommand(WirelessRenderingCommand)
|
e.registerServerCommand(WirelessRenderingCommand)
|
||||||
e.registerServerCommand(SpawnComputerCommand)
|
e.registerServerCommand(SpawnComputerCommand)
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package li.cil.oc.server.command
|
||||||
|
|
||||||
|
import li.cil.oc.api
|
||||||
|
import li.cil.oc.common.command.SimpleCommand
|
||||||
|
import li.cil.oc.common.nanomachines.ControllerImpl
|
||||||
|
import net.minecraft.command.ICommandSender
|
||||||
|
import net.minecraft.command.WrongUsageException
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.util.ChatComponentText
|
||||||
|
|
||||||
|
object DebugNanomachinesCommand extends SimpleCommand("oc_debugNanomachines") {
|
||||||
|
aliases += "oc_dn"
|
||||||
|
|
||||||
|
override def getCommandUsage(source: ICommandSender): String = name
|
||||||
|
|
||||||
|
override def execute(source: ICommandSender, args: Array[String]): Unit = {
|
||||||
|
source match {
|
||||||
|
case player: EntityPlayer =>
|
||||||
|
api.Nanomachines.installController(player) match {
|
||||||
|
case controller: ControllerImpl =>
|
||||||
|
controller.debug()
|
||||||
|
player.addChatMessage(new ChatComponentText("Debug configuration created, see log for mappings."))
|
||||||
|
case _ => // Someone did something.
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user