mirror of
https://github.com/GTNewHorizons/bdlib.git
synced 2026-11-27 15:32:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ff7a75604 | ||
|
|
f8bb1e8fbb | ||
|
|
a530c66680 | ||
|
|
26af828491 | ||
|
|
1c0913d674 | ||
|
|
895cfd9cb6 |
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
bdlib.version=1.8.0
|
bdlib.version=1.8.2
|
||||||
curseforge.id=70496
|
curseforge.id=70496
|
||||||
|
|
||||||
minecraft.version=1.7.10
|
minecraft.version=1.7.10
|
||||||
forge.version=10.13.2.1291
|
forge.version=10.13.4.1448-1.7.10
|
||||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip
|
||||||
@@ -90,7 +90,7 @@ object CommandOreDistribution extends CommandBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val total = distribution.map(_._2).sum
|
val total = distribution.values.sum
|
||||||
val warnings = kinds.filter(_._2.size > 1)
|
val warnings = kinds.filter(_._2.size > 1)
|
||||||
|
|
||||||
if (toFile) {
|
if (toFile) {
|
||||||
@@ -104,7 +104,7 @@ object CommandOreDistribution extends CommandBase {
|
|||||||
))
|
))
|
||||||
dumpWriter.newLine()
|
dumpWriter.newLine()
|
||||||
dumpWriter.newLine()
|
dumpWriter.newLine()
|
||||||
if (warnings.size > 0) {
|
if (warnings.nonEmpty) {
|
||||||
for ((id, types) <- warnings.toList.sortBy(_._1)) {
|
for ((id, types) <- warnings.toList.sortBy(_._1)) {
|
||||||
dumpWriter.write("Warning: %s has multiple variants generated:".format(id))
|
dumpWriter.write("Warning: %s has multiple variants generated:".format(id))
|
||||||
dumpWriter.newLine()
|
dumpWriter.newLine()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ package net.bdew.lib
|
|||||||
class EventBase[T] extends {
|
class EventBase[T] extends {
|
||||||
var listeners = Seq.empty[T]
|
var listeners = Seq.empty[T]
|
||||||
def listen(x: T) = listeners :+= x
|
def listen(x: T) = listeners :+= x
|
||||||
def hasListeners = listeners.size > 0
|
def hasListeners = listeners.nonEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
class Event0 extends EventBase[() => Unit] {
|
class Event0 extends EventBase[() => Unit] {
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ object ServerTickExecutionContext extends ExecutionContext {
|
|||||||
override def reportFailure(cause: Throwable): Unit =
|
override def reportFailure(cause: Throwable): Unit =
|
||||||
BdLib.logErrorException("Error in execution context", cause)
|
BdLib.logErrorException("Error in execution context", cause)
|
||||||
|
|
||||||
@SubscribeEvent
|
def doSingleLoop(): Unit = {
|
||||||
def onTick(ev: ServerTickEvent): Unit = {
|
|
||||||
for (r <- getNextBatch) {
|
for (r <- getNextBatch) {
|
||||||
try {
|
try {
|
||||||
r.run()
|
r.run()
|
||||||
@@ -50,4 +49,7 @@ object ServerTickExecutionContext extends ExecutionContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
def onTick(ev: ServerTickEvent): Unit = doSingleLoop()
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) bdew, 2013 - 2015
|
||||||
|
* https://github.com/bdew/bdlib
|
||||||
|
*
|
||||||
|
* This mod is distributed under the terms of the Minecraft Mod Public
|
||||||
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||||
|
* http://bdew.net/minecraft-mod-public-license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.bdew.lib.block
|
||||||
|
|
||||||
|
import java.util
|
||||||
|
|
||||||
|
import net.minecraft.block.Block
|
||||||
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.item.{ItemBlock, ItemStack}
|
||||||
|
|
||||||
|
trait BlockTooltip extends Block {
|
||||||
|
def getTooltip(stack: ItemStack, player: EntityPlayer, advanced: Boolean): List[String]
|
||||||
|
}
|
||||||
|
|
||||||
|
class ItemBlockTooltip(b: Block) extends ItemBlock(b) {
|
||||||
|
override def addInformation(stack: ItemStack, player: EntityPlayer, list: util.List[_], advanced: Boolean): Unit = {
|
||||||
|
import scala.collection.JavaConversions._
|
||||||
|
if (b.isInstanceOf[BlockTooltip])
|
||||||
|
list.asInstanceOf[util.List[String]].addAll(b.asInstanceOf[BlockTooltip].getTooltip(stack, player, advanced))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,12 +9,14 @@
|
|||||||
|
|
||||||
package net.bdew.lib.config
|
package net.bdew.lib.config
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.ObfuscationReflectionHelper
|
||||||
import cpw.mods.fml.common.registry.GameRegistry
|
import cpw.mods.fml.common.registry.GameRegistry
|
||||||
import net.bdew.lib.Misc
|
import net.bdew.lib.Misc
|
||||||
import net.bdew.lib.block.{HasTE, NamedBlock}
|
import net.bdew.lib.block.{HasTE, NamedBlock}
|
||||||
import net.minecraft.block.Block
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.creativetab.CreativeTabs
|
import net.minecraft.creativetab.CreativeTabs
|
||||||
import net.minecraft.item.{ItemBlock, Item, ItemStack}
|
import net.minecraft.item.{ItemBlock, ItemStack}
|
||||||
|
import net.minecraft.tileentity.TileEntity
|
||||||
|
|
||||||
class BlockManager(creativeTab: CreativeTabs) {
|
class BlockManager(creativeTab: CreativeTabs) {
|
||||||
def regBlock[T <: NamedBlock](block: T): T = regBlock(block, block.name)
|
def regBlock[T <: NamedBlock](block: T): T = regBlock(block, block.name)
|
||||||
@@ -36,5 +38,14 @@ class BlockManager(creativeTab: CreativeTabs) {
|
|||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a legacy TE name->class mapping. Stolen from GameRegistry.registerTileEntityWithAlternatives
|
||||||
|
*/
|
||||||
|
def registerLegacyTileEntity(name: String, cls: Class[_ <: TileEntity]): Unit = {
|
||||||
|
val teMappings: java.util.Map[String, Class[_]] = ObfuscationReflectionHelper.getPrivateValue(classOf[TileEntity], null, "field_" + "145855_i", "nameToClassMap")
|
||||||
|
if (!teMappings.containsKey(name))
|
||||||
|
teMappings.put(name, cls)
|
||||||
|
}
|
||||||
|
|
||||||
def load() {}
|
def load() {}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ case class DataSlotFluidOption(name: String, parent: DataSlotContainer) extends
|
|||||||
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
||||||
|
|
||||||
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
value map { x => t.setString(name, x.getName) }
|
value foreach { x => t.setString(name, x.getName) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override def load(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
|
override def load(t: NBTTagCompound, kind: UpdateKind.Value): Unit = {
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ case class DataSlotGameProfile(name: String, parent: DataSlotContainer) extends
|
|||||||
|
|
||||||
override def save(t: NBTTagCompound, kind: UpdateKind.Value) = {
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) = {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Option(value.getId) map (id => t.setString(name + "_uid", id.toString))
|
Option(value.getId) foreach (id => t.setString(name + "_uid", id.toString))
|
||||||
Option(value.getName) filterNot (name => StringUtils.isBlank(name)) map (name => t.setString(name + "_name", name))
|
Option(value.getName) filterNot (name => StringUtils.isBlank(name)) foreach (name => t.setString(name + "_name", name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ abstract class BaseScreen(cont: Container, xSz: Int, ySz: Int) extends GuiContai
|
|||||||
|
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
|
|
||||||
if (tip.size > 0)
|
if (tip.nonEmpty)
|
||||||
drawHoveringText(tip, x, y, getFontRenderer)
|
drawHoveringText(tip, x, y, getFontRenderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ object Tools {
|
|||||||
val seen = mutable.Set.empty[BlockRef]
|
val seen = mutable.Set.empty[BlockRef]
|
||||||
val queue = mutable.Queue.empty[BlockRef]
|
val queue = mutable.Queue.empty[BlockRef]
|
||||||
queue ++= getConnectedNeighbours(world, core, core, seen)
|
queue ++= getConnectedNeighbours(world, core, core, seen)
|
||||||
while (queue.size > 0) {
|
while (queue.nonEmpty) {
|
||||||
val current = queue.dequeue()
|
val current = queue.dequeue()
|
||||||
seen.add(current)
|
seen.add(current)
|
||||||
queue ++= getConnectedNeighbours(world, core, current, seen)
|
queue ++= getConnectedNeighbours(world, core, current, seen)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ trait BlockOutput[T <: TileOutput[_]] extends BlockModule[T] with BlockAdditiona
|
|||||||
|
|
||||||
def getFaceOverlays(world: IBlockAccess, x: Int, y: Int, z: Int, face: ForgeDirection): List[FaceOverlay] = {
|
def getFaceOverlays(world: IBlockAccess, x: Int, y: Int, z: Int, face: ForgeDirection): List[FaceOverlay] = {
|
||||||
var result = List.empty[FaceOverlay]
|
var result = List.empty[FaceOverlay]
|
||||||
Option(getTE(world, x, y, z)) flatMap (_.getCore) map { core =>
|
Option(getTE(world, x, y, z)) flatMap (_.getCore) foreach { core =>
|
||||||
val bf = BlockFace(x, y, z, face)
|
val bf = BlockFace(x, y, z, face)
|
||||||
if (core.outputFaces.contains(bf))
|
if (core.outputFaces.contains(bf))
|
||||||
result :+= FaceOverlay(resources.output, resources.outputColors(core.outputFaces(bf)))
|
result :+= FaceOverlay(resources.output, resources.outputColors(core.outputFaces(bf)))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ case class DataSlotPos(name: String, parent: DataSlotContainer) extends DataSlot
|
|||||||
setUpdate(UpdateKind.SAVE, UpdateKind.WORLD)
|
setUpdate(UpdateKind.SAVE, UpdateKind.WORLD)
|
||||||
|
|
||||||
def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
value map (x => t.setTag(name, Misc.applyMutator(x.writeToNBT, new NBTTagCompound)))
|
value foreach (x => t.setTag(name, Misc.applyMutator(x.writeToNBT, new NBTTagCompound)))
|
||||||
}
|
}
|
||||||
|
|
||||||
def load(t: NBTTagCompound, kind: UpdateKind.Value) {
|
def load(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class WidgetOutputIcon(p: Point, te: CIOutputFaces, output: Int) extends Widget
|
|||||||
val faces = te.outputFaces.inverted
|
val faces = te.outputFaces.inverted
|
||||||
if (faces.isDefinedAt(output)) {
|
if (faces.isDefinedAt(output)) {
|
||||||
val bf = faces(output)
|
val bf = faces(output)
|
||||||
bf.origin.block(te.getWorldObj) map { block =>
|
bf.origin.block(te.getWorldObj) foreach { block =>
|
||||||
parent.drawTexture(rect, Texture(Texture.BLOCKS, block.getIcon(te.getWorldObj, bf.origin.x, bf.origin.y, bf.origin.z, bf.face.ordinal())))
|
parent.drawTexture(rect, Texture(Texture.BLOCKS, block.getIcon(te.getWorldObj, bf.origin.x, bf.origin.y, bf.origin.z, bf.face.ordinal())))
|
||||||
if (block.isInstanceOf[BlockAdditionalRender]) {
|
if (block.isInstanceOf[BlockAdditionalRender]) {
|
||||||
for (over <- block.asInstanceOf[BlockAdditionalRender].getFaceOverlays(te.getWorldObj, bf.origin.x, bf.origin.y, bf.origin.z, bf.face))
|
for (over <- block.asInstanceOf[BlockAdditionalRender].getFaceOverlays(te.getWorldObj, bf.origin.x, bf.origin.y, bf.origin.z, bf.face))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ trait TileController extends TileDataSlots {
|
|||||||
|
|
||||||
lazy val myPos = BlockRef(xCoord, yCoord, zCoord)
|
lazy val myPos = BlockRef(xCoord, yCoord, zCoord)
|
||||||
|
|
||||||
def getNumOfModules(kind: String) = modules.map(_.getTile[TileModule](getWorldObj)).flatten.count(_.kind == kind)
|
def getNumOfModules(kind: String) = modules.flatMap(_.getTile[TileModule](getWorldObj)).count(_.kind == kind)
|
||||||
|
|
||||||
def onModulesChanged()
|
def onModulesChanged()
|
||||||
def onClick(player: EntityPlayer)
|
def onClick(player: EntityPlayer)
|
||||||
@@ -59,7 +59,7 @@ trait TileController extends TileDataSlots {
|
|||||||
|
|
||||||
def validateModules() {
|
def validateModules() {
|
||||||
modules.filter(x => {
|
modules.filter(x => {
|
||||||
!x.getTile[TileModule](getWorldObj).isDefined || !x.getBlock[BlockModule[TileModule]](getWorldObj).isDefined
|
x.getTile[TileModule](getWorldObj).isEmpty || x.getBlock[BlockModule[TileModule]](getWorldObj).isEmpty
|
||||||
}).foreach(x => {
|
}).foreach(x => {
|
||||||
BdLib.logWarn("Block at %s is not a valid module, removing from machine %s at %d,%d,%d", x, this.getClass.getSimpleName, xCoord, yCoord, zCoord)
|
BdLib.logWarn("Block at %s is not a valid module, removing from machine %s at %d,%d,%d", x, this.getClass.getSimpleName, xCoord, yCoord, zCoord)
|
||||||
modules.remove(x)
|
modules.remove(x)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ abstract class TileControllerGui extends TileController {
|
|||||||
|
|
||||||
def onClick(player: EntityPlayer) = {
|
def onClick(player: EntityPlayer) = {
|
||||||
val missing = cfg.required.filter({ case (mod, cnt) => getNumOfModules(mod) < cnt })
|
val missing = cfg.required.filter({ case (mod, cnt) => getNumOfModules(mod) < cnt })
|
||||||
if (missing.size > 0) {
|
if (missing.nonEmpty) {
|
||||||
player.addChatMessage(new ChatComponentTranslation("bdlib.multiblock.incomplete")
|
player.addChatMessage(new ChatComponentTranslation("bdlib.multiblock.incomplete")
|
||||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)))
|
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)))
|
||||||
for ((mod, cnt) <- missing)
|
for ((mod, cnt) <- missing)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T]
|
|||||||
def onConnectionsChanged(added: Set[ForgeDirection], removed: Set[ForgeDirection]) {}
|
def onConnectionsChanged(added: Set[ForgeDirection], removed: Set[ForgeDirection]) {}
|
||||||
|
|
||||||
def doRescanFaces() {
|
def doRescanFaces() {
|
||||||
getCore map { core =>
|
getCore foreach { core =>
|
||||||
val connections = (
|
val connections = (
|
||||||
ForgeDirection.VALID_DIRECTIONS
|
ForgeDirection.VALID_DIRECTIONS
|
||||||
filterNot { dir => core.modules.contains(myPos.neighbour(dir)) }
|
filterNot { dir => core.modules.contains(myPos.neighbour(dir)) }
|
||||||
@@ -58,7 +58,7 @@ abstract class TileOutput[T <: OutputConfig] extends TileModule with MIOutput[T]
|
|||||||
val toRemove = known -- connections
|
val toRemove = known -- connections
|
||||||
toRemove.foreach(x => core.removeOutput(myPos, x))
|
toRemove.foreach(x => core.removeOutput(myPos, x))
|
||||||
toAdd.foreach(x => core.newOutput(myPos, x, makeCfgObject(x)))
|
toAdd.foreach(x => core.newOutput(myPos, x, makeCfgObject(x)))
|
||||||
if (toAdd.size > 0 || toRemove.size > 0) {
|
if (toAdd.nonEmpty || toRemove.nonEmpty) {
|
||||||
onConnectionsChanged(toAdd, toRemove)
|
onConnectionsChanged(toAdd, toRemove)
|
||||||
getWorldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
getWorldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
package net.bdew.lib.nbt
|
package net.bdew.lib.nbt
|
||||||
|
|
||||||
import net.minecraft.nbt.{NBTBase, NBTTagCompound, NBTTagList}
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.nbt.{NBTBase, NBTTagByte, NBTTagCompound, NBTTagList}
|
||||||
|
|
||||||
import scala.language.implicitConversions
|
import scala.language.implicitConversions
|
||||||
|
|
||||||
@@ -17,20 +18,33 @@ object NBT {
|
|||||||
|
|
||||||
class NBTSerialized(val value: NBTBase) extends AnyVal
|
class NBTSerialized(val value: NBTBase) extends AnyVal
|
||||||
|
|
||||||
implicit def serializeNbtPrimitive[T: Type](v: T): NBTSerialized = new NBTSerialized(Type[T].toNBT(v))
|
object NBTSerialized {
|
||||||
|
implicit def serializeNbtPrimitive[T: Type](v: T): NBTSerialized = new NBTSerialized(Type[T].toNBT(v))
|
||||||
|
|
||||||
implicit def serializeNbtList[T: Type](v: List[T]): NBTSerialized = {
|
implicit def serializeNbtList[T: Type](v: Traversable[T]): NBTSerialized = {
|
||||||
val list = new NBTTagList
|
val list = new NBTTagList
|
||||||
for (x <- v) list.appendTag(Type[T].toNBT(x))
|
for (x <- v) list.appendTag(Type[T].toNBT(x))
|
||||||
new NBTSerialized(list)
|
new NBTSerialized(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Boolean is special because it's represented as a byte in NBT
|
||||||
|
implicit def serializeBoolean(v: Boolean): NBTSerialized = new NBTSerialized(new NBTTagByte(if (v) 1 else 0))
|
||||||
|
|
||||||
|
// Itemstack serialization helpers
|
||||||
|
implicit def serializeItemStack(v: ItemStack): NBTSerialized = new NBTSerialized(NBT.from(v.writeToNBT _))
|
||||||
|
implicit def serializeItemStackList(v: Traversable[ItemStack]): NBTSerialized = serializeNbtList(v map (x => NBT.from(x.writeToNBT _)))
|
||||||
}
|
}
|
||||||
|
|
||||||
def apply(pairs: (String, NBTSerialized)*): NBTTagCompound = apply(pairs.toMap)
|
def apply(pairs: (String, NBTSerialized)*): NBTTagCompound = {
|
||||||
|
|
||||||
def apply(m: Map[String, NBTSerialized]): NBTTagCompound = {
|
|
||||||
val tag = new NBTTagCompound()
|
val tag = new NBTTagCompound()
|
||||||
for ((k, v) <- m)
|
for ((k, v) <- pairs)
|
||||||
tag.setTag(k, v.value)
|
tag.setTag(k, v.value)
|
||||||
tag
|
tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def from(f: (NBTTagCompound) => _) = {
|
||||||
|
val v = new NBTTagCompound
|
||||||
|
f(v)
|
||||||
|
v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -59,8 +59,8 @@ case class ConfigSection(pfx: String = "") extends ConfigEntry with Iterable[(St
|
|||||||
|
|
||||||
def getInt(id: String) = getDouble(id).round.toInt
|
def getInt(id: String) = getDouble(id).round.toInt
|
||||||
def getFloat(id: String) = getDouble(id).toFloat
|
def getFloat(id: String) = getDouble(id).toFloat
|
||||||
def getIntList(id: String) = getDoubleList(id).map(_.round.toInt).toList
|
def getIntList(id: String) = getDoubleList(id).map(_.round.toInt)
|
||||||
def getFloatList(id: String) = getDoubleList(id).map(_.toFloat).toList
|
def getFloatList(id: String) = getDoubleList(id).map(_.toFloat)
|
||||||
|
|
||||||
def getColor(id: String) =
|
def getColor(id: String) =
|
||||||
raw(id) match {
|
raw(id) match {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import net.minecraftforge.common.MinecraftForge
|
|||||||
class IconPreloader(kind: Int) {
|
class IconPreloader(kind: Int) {
|
||||||
lazy val map = {
|
lazy val map = {
|
||||||
(for {
|
(for {
|
||||||
method <- getClass.getMethods if method.getParameterTypes.length == 0 && classOf[TextureLoc].isAssignableFrom(method.getReturnType)
|
method <- getClass.getMethods if method.getParameterTypes.isEmpty && classOf[TextureLoc].isAssignableFrom(method.getReturnType)
|
||||||
value <- Misc.asInstanceOpt(method.invoke(this), classOf[TextureLoc])
|
value <- Misc.asInstanceOpt(method.invoke(this), classOf[TextureLoc])
|
||||||
} yield method.getName -> value).toMap
|
} yield method.getName -> value).toMap
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ case class DataSlotResourceKindOption(name: String, parent: DataSlotContainer) e
|
|||||||
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
setUpdate(UpdateKind.SAVE, UpdateKind.GUI)
|
||||||
|
|
||||||
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
override def save(t: NBTTagCompound, kind: UpdateKind.Value) {
|
||||||
value map { r =>
|
value foreach { r =>
|
||||||
t.setTag(name,
|
t.setTag(name,
|
||||||
Misc.applyMutator(new NBTTagCompound) { tag =>
|
Misc.applyMutator(new NBTTagCompound) { tag =>
|
||||||
r.helperObject.saveToNBT(tag, r)
|
r.helperObject.saveToNBT(tag, r)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import net.minecraft.inventory.{IInventory, Slot}
|
|||||||
|
|
||||||
class SlotSensorType[T, R](inv: IInventory, index: Int, x: Int, y: Int, ds: DataSlotSensor[T, R], types: => Seq[GenericSensorType[T, R]]) extends Slot(inv, index, x, y) with SlotClickable {
|
class SlotSensorType[T, R](inv: IInventory, index: Int, x: Int, y: Int, ds: DataSlotSensor[T, R], types: => Seq[GenericSensorType[T, R]]) extends Slot(inv, index, x, y) with SlotClickable {
|
||||||
override def onClick(button: Int, mods: Int, player: EntityPlayer) = {
|
override def onClick(button: Int, mods: Int, player: EntityPlayer) = {
|
||||||
if (mods == 0 && (button == 0 || button == 1) && types.size > 0 && player.inventory.getItemStack == null) {
|
if (mods == 0 && (button == 0 || button == 1) && types.nonEmpty && player.inventory.getItemStack == null) {
|
||||||
val newSensor =
|
val newSensor =
|
||||||
if (button == 0)
|
if (button == 0)
|
||||||
Misc.nextInSeq(types, ds.sensor)
|
Misc.nextInSeq(types, ds.sensor)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ trait SensorOutput extends GenericSensorType[TileEntity, Boolean] {
|
|||||||
(current, obj) match {
|
(current, obj) match {
|
||||||
case (SensorOutputFlowParameter(n), x: CIOutputFaces) =>
|
case (SensorOutputFlowParameter(n), x: CIOutputFaces) =>
|
||||||
val outputs = x.outputFaces.map.values.toList.sorted
|
val outputs = x.outputFaces.map.values.toList.sorted
|
||||||
if (outputs.size > 0)
|
if (outputs.nonEmpty)
|
||||||
if (button == 0)
|
if (button == 0)
|
||||||
SensorOutputFlowParameter(Misc.nextInSeq(outputs, n))
|
SensorOutputFlowParameter(Misc.nextInSeq(outputs, n))
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ trait BreakableInventoryTile extends TileEntity with BaseInventory {
|
|||||||
for (stack <- inv if stack != null) {
|
for (stack <- inv if stack != null) {
|
||||||
ItemUtils.throwItemAt(getWorldObj, xCoord, yCoord, zCoord, stack)
|
ItemUtils.throwItemAt(getWorldObj, xCoord, yCoord, zCoord, stack)
|
||||||
}
|
}
|
||||||
inv = new Array[ItemStack](inv.size)
|
inv = new Array[ItemStack](inv.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,11 @@ import net.minecraft.tileentity.TileEntity
|
|||||||
trait InventoryProxy extends TileEntity with IInventory {
|
trait InventoryProxy extends TileEntity with IInventory {
|
||||||
def targetInventory: Option[IInventory]
|
def targetInventory: Option[IInventory]
|
||||||
|
|
||||||
override def openInventory() = targetInventory map (_.openInventory())
|
override def openInventory() = targetInventory foreach (_.openInventory())
|
||||||
override def closeInventory() = targetInventory map (_.closeInventory())
|
override def closeInventory() = targetInventory foreach (_.closeInventory())
|
||||||
|
|
||||||
override def markDirty() = {
|
override def markDirty() = {
|
||||||
targetInventory map (_.markDirty())
|
targetInventory foreach (_.markDirty())
|
||||||
super.markDirty()
|
super.markDirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ trait InventoryProxy extends TileEntity with IInventory {
|
|||||||
|
|
||||||
override def getStackInSlot(slot: Int) = targetInventory.map(_.getStackInSlot(slot)).orNull
|
override def getStackInSlot(slot: Int) = targetInventory.map(_.getStackInSlot(slot)).orNull
|
||||||
override def getStackInSlotOnClosing(slot: Int) = targetInventory.map(_.getStackInSlotOnClosing(slot)).orNull
|
override def getStackInSlotOnClosing(slot: Int) = targetInventory.map(_.getStackInSlotOnClosing(slot)).orNull
|
||||||
override def setInventorySlotContents(slot: Int, item: ItemStack) = targetInventory.map(_.setInventorySlotContents(slot, item))
|
override def setInventorySlotContents(slot: Int, item: ItemStack) = targetInventory.foreach(_.setInventorySlotContents(slot, item))
|
||||||
override def decrStackSize(slot: Int, num: Int) = targetInventory.map(_.decrStackSize(slot, num)).orNull
|
override def decrStackSize(slot: Int, num: Int) = targetInventory.map(_.decrStackSize(slot, num)).orNull
|
||||||
|
|
||||||
override def isItemValidForSlot(slot: Int, item: ItemStack) = targetInventory.exists(_.isItemValidForSlot(slot, item))
|
override def isItemValidForSlot(slot: Int, item: ItemStack) = targetInventory.exists(_.isItemValidForSlot(slot, item))
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import net.minecraft.item.ItemStack
|
|||||||
|
|
||||||
class MultipleInventoryAdapter(val map: Map[Int, (IInventory, Int)]) extends IInventory {
|
class MultipleInventoryAdapter(val map: Map[Int, (IInventory, Int)]) extends IInventory {
|
||||||
def this(inventories: Iterable[IInventory]) =
|
def this(inventories: Iterable[IInventory]) =
|
||||||
this((inventories map { inv => (0 until inv.getSizeInventory).map((inv, _)) }).flatten.zipWithIndex.map(_.swap).toMap)
|
this((inventories flatMap { inv => (0 until inv.getSizeInventory).map((inv, _)) }).zipWithIndex.map(_.swap).toMap)
|
||||||
def this(inventories: IInventory*) =
|
def this(inventories: IInventory*) =
|
||||||
this((inventories map { inv => (0 until inv.getSizeInventory).map((inv, _)) }).flatten.zipWithIndex.map(_.swap).toMap)
|
this((inventories flatMap { inv => (0 until inv.getSizeInventory).map((inv, _)) }).zipWithIndex.map(_.swap).toMap)
|
||||||
|
|
||||||
lazy val inventories = map.values.map(_._1).toSet
|
lazy val inventories = map.values.map(_._1).toSet
|
||||||
override lazy val getInventoryStackLimit = inventories.map(_.getInventoryStackLimit).min
|
override lazy val getInventoryStackLimit = inventories.map(_.getInventoryStackLimit).min
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import net.minecraft.item.ItemStack
|
|||||||
trait SidedInventory extends BaseInventory with ISidedInventory {
|
trait SidedInventory extends BaseInventory with ISidedInventory {
|
||||||
var allowSided = false
|
var allowSided = false
|
||||||
|
|
||||||
def getAccessibleSlotsFromSide(side: Int): Array[Int] = (0 until inv.size).toArray
|
def getAccessibleSlotsFromSide(side: Int): Array[Int] = inv.indices.toArray
|
||||||
|
|
||||||
def canInsertItem(slot: Int, stack: ItemStack, side: Int) = allowSided && isItemValidForSlot(slot, stack)
|
def canInsertItem(slot: Int, stack: ItemStack, side: Int) = allowSided && isItemValidForSlot(slot, stack)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user