mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-19 11:59:08 +00:00
Cleaned up unnecessary parentheses in foreach loops
This commit is contained in:
1 parent
38adcdbee1
commit
3fd55ce0a0
7 files changed
+25
-35
No files matched your search
@@ -146,14 +146,13 @@ class MicroblockPlacement(val world:World, val player:EntityPlayer, val hit:Movi
|
||||
|
||||
val mUnits = mcrClass.sizeToVolume(sizea) - mcrClass.sizeToVolume(sizea+size)
|
||||
var mat = 0
|
||||
player.inventory.mainInventory.foreach(item => {
|
||||
player.inventory.mainInventory.foreach(item =>
|
||||
if(item != null && item.itemID == MicroblockProxy.item.itemID)
|
||||
{
|
||||
val mcrClass = MicroblockClassRegistry.getMicroClass(item.getItemDamage)
|
||||
if(ItemMicroPart.getMaterialID(item) == material)
|
||||
mat+=mcrClass.sizeToVolume(item.getItemDamage&0xFF)
|
||||
}
|
||||
})
|
||||
})
|
||||
return mat >= mUnits
|
||||
}
|
||||
|
||||
|
||||
@@ -77,11 +77,8 @@ trait BlockMultipart extends Block
|
||||
return null
|
||||
|
||||
for(i <- 0 until tile.partList.size)
|
||||
{
|
||||
tile.partList(i).getSubParts.foreach { c =>
|
||||
boxes.add(new IndexedCuboid6((i, c.data), c.copy.add(new Vector3(x, y, z))))
|
||||
}
|
||||
}
|
||||
tile.partList(i).getSubParts.foreach(c =>
|
||||
boxes.add(new IndexedCuboid6((i, c.data), c.copy.add(new Vector3(x, y, z)))))
|
||||
|
||||
return RayTracer.instance.rayTraceCuboids(new Vector3(start), new Vector3(end), boxes, new BlockCoord(x, y, z), this)
|
||||
}
|
||||
@@ -125,17 +122,12 @@ trait BlockMultipart extends Block
|
||||
val list = list$.asInstanceOf[List[AxisAlignedBB]]
|
||||
val tile = getTile(world, x, y, z)
|
||||
if(tile != null)
|
||||
{
|
||||
tile.partList.foreach { part =>
|
||||
part.getCollisionBoxes.foreach{ c =>
|
||||
{
|
||||
tile.partList.foreach(part =>
|
||||
part.getCollisionBoxes.foreach{c =>
|
||||
val aabb = c.toAABB().offset(x, y, z)
|
||||
if(aabb.intersectsWith(ebb))
|
||||
list.add(aabb)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override def addBlockHitEffects(world:World, hit:MovingObjectPosition, effectRenderer:EffectRenderer):Boolean =
|
||||
|
||||
@@ -40,13 +40,12 @@ object MultiPartRegistry
|
||||
throw new IllegalStateException("You must register your parts in the init methods.")
|
||||
state=1
|
||||
|
||||
types.foreach(s =>
|
||||
{
|
||||
types.foreach{s =>
|
||||
if(typeMap.contains(s))
|
||||
throw new IllegalStateException("Part with id "+s+" is already registered.");
|
||||
|
||||
typeMap.put(s, (c:Boolean) => partFactory(s, c));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def registerConverter(c:IPartConverter)
|
||||
@@ -116,11 +115,11 @@ object MultiPartRegistry
|
||||
|
||||
def convertBlock(world:World, pos:BlockCoord, id:Int):TMultiPart =
|
||||
{
|
||||
converters(id).foreach(c => {
|
||||
converters(id).foreach{c =>
|
||||
val ret = c.convert(world, pos)
|
||||
if(ret != null)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -43,20 +43,20 @@ trait TLiquidTank extends TileMultipart with ITankContainer
|
||||
tankList.foreach(t => tankCount += t.getTanks(dir).length)
|
||||
val tanks = new Array[ILiquidTank](tankCount)
|
||||
var i = 0
|
||||
tankList.foreach(p => p.getTanks(dir).foreach(t => {
|
||||
tankList.foreach(p => p.getTanks(dir).foreach{t =>
|
||||
tanks(i) = t
|
||||
i+=1
|
||||
}))
|
||||
})
|
||||
return tanks
|
||||
}
|
||||
|
||||
override def getTank(dir:ForgeDirection, liquid:LiquidStack):ILiquidTank =
|
||||
{
|
||||
tankList.foreach(p => {
|
||||
tankList.foreach{p =>
|
||||
val t = p.getTank(dir, liquid)
|
||||
if(t != null)
|
||||
return t//TODO: bad, slow
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ trait TLiquidTank extends TileMultipart with ITankContainer
|
||||
override def drain(dir:ForgeDirection, amount:Int, doDrain:Boolean):LiquidStack =
|
||||
{
|
||||
var drained:LiquidStack = null
|
||||
tankList.foreach(p => {
|
||||
tankList.foreach{p =>
|
||||
val ret = p.drain(dir, amount-drained.amount, false)
|
||||
if(ret != null && ret.amount > 0 && (drained == null || drained.isLiquidEqual(ret)))
|
||||
{
|
||||
@@ -92,7 +92,7 @@ trait TLiquidTank extends TileMultipart with ITankContainer
|
||||
else
|
||||
drained.amount+=ret.amount
|
||||
}
|
||||
})
|
||||
}
|
||||
return drained
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ object TickScheduler extends WorldExtensionInstantiator
|
||||
override def saveData(data:NBTTagCompound)
|
||||
{
|
||||
val tagList = new NBTTagList
|
||||
tickList.foreach(e => {
|
||||
tickList.foreach{e =>
|
||||
val part = e.part
|
||||
if(part.tile != null)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ object TickScheduler extends WorldExtensionInstantiator
|
||||
tag.setInteger("ticks", e.ticks)
|
||||
tagList.appendTag(tag)
|
||||
}
|
||||
})
|
||||
}
|
||||
if(tagList.tagCount > 0)
|
||||
data.setTag("multipartTicks", tagList)
|
||||
}
|
||||
|
||||
@@ -264,10 +264,10 @@ trait TileMultipart extends TileEntity
|
||||
def writeDesc(packet:PacketCustom)
|
||||
{
|
||||
packet.writeByte(partList.size)
|
||||
partList.foreach{part => {
|
||||
partList.foreach{part =>
|
||||
MultiPartRegistry.writePartID(packet, part)
|
||||
part.writeDesc(packet)
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
def harvestPart(index:Int, drop:Boolean):Boolean =
|
||||
@@ -296,12 +296,12 @@ trait TileMultipart extends TileEntity
|
||||
{
|
||||
super.writeToNBT(tag)
|
||||
val taglist = new NBTTagList
|
||||
partList.foreach { part => {
|
||||
partList.foreach{part =>
|
||||
val parttag = new NBTTagCompound
|
||||
parttag.setString("id", part.getType)
|
||||
part.save(parttag)
|
||||
taglist.appendTag(parttag)
|
||||
}}
|
||||
}
|
||||
tag.setTag("parts", taglist)
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ object MultipartSPH extends IServerPacketHandler
|
||||
|
||||
def onTickEnd(players:Seq[EntityPlayerMP])
|
||||
{
|
||||
players.foreach(p => {
|
||||
players.foreach{p =>
|
||||
val m = updateMap.getOrElse(p.worldObj, null)
|
||||
if(!m.isEmpty)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ object MultipartSPH extends IServerPacketHandler
|
||||
if(send)
|
||||
packet.sendToPlayer(p)
|
||||
}
|
||||
})
|
||||
}
|
||||
updateMap.foreach(_._2.clear())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user