diff --git a/codechicken/microblock/CommonMicroblock.scala b/codechicken/microblock/CommonMicroblock.scala index b4bbe8c..7adb592 100644 --- a/codechicken/microblock/CommonMicroblock.scala +++ b/codechicken/microblock/CommonMicroblock.scala @@ -180,8 +180,6 @@ abstract class Microblock(var shape:Byte = 0, var material:Int = 0) extends TCub } def isTransparent = MicroMaterialRegistry.getMaterial(material).isTransparent - - override def blocksRedstone = true } trait CommonMicroblockClient extends CommonMicroblock with MicroblockClient with TMicroOcclusionClient diff --git a/codechicken/microblock/EdgeMicroblock.scala b/codechicken/microblock/EdgeMicroblock.scala index e709383..7bbc694 100644 --- a/codechicken/microblock/EdgeMicroblock.scala +++ b/codechicken/microblock/EdgeMicroblock.scala @@ -19,6 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly import cpw.mods.fml.relauncher.Side import codechicken.scala.ScalaBridge._ import codechicken.core.raytracer.ExtendedMOP +import codechicken.multipart.TEdgePart object EdgePlacement extends PlacementProperties { @@ -116,7 +117,7 @@ class EdgeMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends EdgeMicro def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-15)).toByte, material) } -class EdgeMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$) +class EdgeMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$) with TEdgePart { def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-15)).toByte, material) diff --git a/codechicken/microblock/HolloMicroblock.scala b/codechicken/microblock/HolloMicroblock.scala index a8eb527..217cc55 100644 --- a/codechicken/microblock/HolloMicroblock.scala +++ b/codechicken/microblock/HolloMicroblock.scala @@ -179,18 +179,19 @@ class HollowMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicrobl override def getPartialOcclusionBoxes = HollowMicroClass.pBoxes(shape) - def getHollowSize = + def getHollowSize = tile match { - val part = tile.partMap(6) - if(part.isInstanceOf[IHollowConnect]) - part.asInstanceOf[IHollowConnect].getSize - else - 8 + case null => 8 + case _ => tile.partMap(6) match + { + case part:IHollowConnect => part.getSize + case _ => 8 + } } def getOcclusionBoxes:JSeq[Cuboid6] = { - val size = getSize + val size = getHollowSize val c = HollowMicroClass.occBounds(shape) val d1 = 0.5-size/32D val d2 = 0.5+size/32D @@ -230,4 +231,6 @@ class HollowMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicrobl override def allowCompleteOcclusion = true override def solid(side:Int) = false + + override def redstoneConductionMap() = 0x10 } \ No newline at end of file diff --git a/codechicken/microblock/ItemMicroPart.scala b/codechicken/microblock/ItemMicroPart.scala index ee87707..6936cfc 100644 --- a/codechicken/microblock/ItemMicroPart.scala +++ b/codechicken/microblock/ItemMicroPart.scala @@ -52,21 +52,7 @@ class ItemMicroPart(id:Int) extends Item(id) override def registerIcons(register:IconRegister){} - override def onItemUseFirst(item:ItemStack, player:EntityPlayer, world:World, x:Int, y:Int, z:Int, s:Int, hitX:Float, hitY:Float, hitZ:Float):Boolean = - { - if(player.isSneaking) - return useItem(item, player, world, x, y, z) && !world.isRemote - return false - } - override def onItemUse(item:ItemStack, player:EntityPlayer, world:World, x:Int, y:Int, z:Int, s:Int, hitX:Float, hitY:Float, hitZ:Float):Boolean = - { - if(!player.isSneaking) - return useItem(item, player, world, x, y, z) - return false - } - - def useItem(item:ItemStack, player:EntityPlayer, world:World, x:Int, y:Int, z:Int):Boolean = { val material = getMaterialID(item) val mcrClass = MicroblockClassRegistry.getMicroClass(item.getItemDamage) diff --git a/codechicken/microblock/MicroblockPlacement.scala b/codechicken/microblock/MicroblockPlacement.scala index ac53c64..32f5aa7 100644 --- a/codechicken/microblock/MicroblockPlacement.scala +++ b/codechicken/microblock/MicroblockPlacement.scala @@ -11,7 +11,7 @@ import codechicken.multipart.ControlKeyModifer._ import net.minecraft.item.ItemStack import codechicken.microblock.handler.MicroblockProxy import codechicken.multipart.TMultiPart -import codechicken.multipart.TileMultipartObj +import codechicken.multipart.TileMultipart import codechicken.core.raytracer.ExtendedMOP abstract class ExecutablePlacement(val pos:BlockCoord, val part:Microblock) @@ -24,7 +24,7 @@ class AdditionPlacement($pos:BlockCoord, $part:Microblock) extends ExecutablePla { def place(world:World, player:EntityPlayer, item:ItemStack) { - TileMultipartObj.addPart(world, pos, part) + TileMultipart.addPart(world, pos, part) } def consume(world:World, player:EntityPlayer, item:ItemStack) @@ -74,7 +74,7 @@ class MicroblockPlacement(val world:World, val player:EntityPlayer, val hit:Movi val mcrClass = pp.microClass val pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ) val vhit = new Vector3(hit.hitVec).add(-pos.x, -pos.y, -pos.z) - val gtile = TileMultipartObj.getOrConvertTile2(world, pos) + val gtile = TileMultipart.getOrConvertTile2(world, pos) val htile = gtile._1 val slot = pp.placementGrid.getHitSlot(vhit, hit.sideHit) val oslot = pp.opposite(slot, hit.sideHit) @@ -183,18 +183,13 @@ class MicroblockPlacement(val world:World, val player:EntityPlayer, val hit:Movi def externalPlacement(npart:Microblock):ExecutablePlacement = { val pos = this.pos.copy().offset(side) - if(TileMultipartObj.canAddPart(world, pos, npart)) + if(TileMultipart.canPlacePart(world, pos, npart)) return new AdditionPlacement(pos, npart) return null } def getHitDepth(vhit:Vector3, side:Int):Double = - { - var d = vhit.copy().scalarProject(Rotation.axes(side)) - if(side%2 == 0) - d+=1 - return d - } + vhit.copy.scalarProject(Rotation.axes(side)) + (side%2^1) def create(size:Int, slot:Int, material:Int) = mcrClass.create(size, slot, material, world.isRemote) } \ No newline at end of file diff --git a/codechicken/multipart/BlockMultipart.scala b/codechicken/multipart/BlockMultipart.scala index 0e8b2b7..1264acb 100644 --- a/codechicken/multipart/BlockMultipart.scala +++ b/codechicken/multipart/BlockMultipart.scala @@ -145,7 +145,7 @@ trait BlockMultipart extends Block override def isOpaqueCube() = false - override def getRenderType() = TileMultipartObj.renderID + override def getRenderType() = TileMultipart.renderID override def isAirBlock(world:World, x:Int, y:Int, z:Int) = getTile(world, x, y, z) == null || getTile(world, x, y, z).partList.isEmpty diff --git a/codechicken/multipart/ItemMultiPart.scala b/codechicken/multipart/ItemMultiPart.scala new file mode 100644 index 0000000..9579a56 --- /dev/null +++ b/codechicken/multipart/ItemMultiPart.scala @@ -0,0 +1,43 @@ +package codechicken.multipart + +import net.minecraft.item.Item +import codechicken.core.vec.Vector3 +import codechicken.core.vec.Rotation +import net.minecraft.item.ItemStack +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.world.World +import codechicken.core.vec.BlockCoord + +abstract class ItemMultiPart(id:Int) extends Item(id) +{ + def getHitDepth(vhit:Vector3, side:Int):Double = + vhit.copy.scalarProject(Rotation.axes(side)) + (side%2^1) + + override def onItemUse(item:ItemStack, player:EntityPlayer, world:World, x:Int, y:Int, z:Int, side:Int, hitX:Float, hitY:Float, hitZ:Float):Boolean = + { + val pos = new BlockCoord(x, y, z) + val vhit = new Vector3(hitX, hitY, hitZ) + val d = getHitDepth(vhit, side) + + def place():Boolean = + { + val part = newPart(item, player, world, pos, side, vhit) + if(part == null || !TileMultipart.canPlacePart(world, pos, part)) + return false + + if(!world.isRemote) + TileMultipart.addPart(world, pos, part) + if(!player.capabilities.isCreativeMode) + item.stackSize-=1 + return true + } + + if(d < 1 && place()) + return true + + pos.offset(side) + return place() + } + + def newPart(item:ItemStack, player:EntityPlayer, world:World, pos:BlockCoord, side:Int, vhit:Vector3):TMultiPart +} \ No newline at end of file diff --git a/codechicken/multipart/MultipartGenerator.scala b/codechicken/multipart/MultipartGenerator.scala index bad53a1..78ea051 100644 --- a/codechicken/multipart/MultipartGenerator.scala +++ b/codechicken/multipart/MultipartGenerator.scala @@ -57,7 +57,7 @@ object MultipartGenerator */ private[multipart] def addPart(world:World, pos:BlockCoord, part:TMultiPart):TileMultipart = { - var loaded = TileMultipartObj.getOrConvertTile2(world, pos) + var loaded = TileMultipart.getOrConvertTile2(world, pos) var partTraits = traitsForPart(part, world.isRemote) val tile = loaded._1 var ntile = tile @@ -87,7 +87,7 @@ object MultipartGenerator ntile = factory.generateTile(partTraits, world.isRemote) world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile) } - ntile.addPart(part) + ntile.addPart_impl(part) return ntile } diff --git a/codechicken/multipart/MultipartRenderer.scala b/codechicken/multipart/MultipartRenderer.scala index 29f19dc..f5c1a24 100644 --- a/codechicken/multipart/MultipartRenderer.scala +++ b/codechicken/multipart/MultipartRenderer.scala @@ -23,7 +23,7 @@ import codechicken.core.lighting.LazyLightMatrix @SideOnly(Side.CLIENT) object MultipartRenderer extends TileEntitySpecialRenderer with ISimpleBlockRenderingHandler { - TileMultipartObj.renderID = RenderingRegistry.getNextAvailableRenderId() + TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId() private val olm = new LazyLightMatrix var pass:Int = 0 @@ -42,7 +42,7 @@ object MultipartRenderer extends TileEntitySpecialRenderer with ISimpleBlockRend tmpart.renderDynamic(pos, f, pass) } - override def getRenderId = TileMultipartObj.renderID + override def getRenderId = TileMultipart.renderID override def renderWorldBlock(world:IBlockAccess, x:Int, y:Int, z:Int, block:Block, modelId:Int, renderer:RenderBlocks):Boolean = { diff --git a/codechicken/multipart/TEdgePart.scala b/codechicken/multipart/TEdgePart.scala new file mode 100644 index 0000000..8b308a7 --- /dev/null +++ b/codechicken/multipart/TEdgePart.scala @@ -0,0 +1,6 @@ +package codechicken.multipart + +trait TEdgePart extends TMultiPart +{ + def conductsRedstone = false +} \ No newline at end of file diff --git a/codechicken/multipart/TFacePart.scala b/codechicken/multipart/TFacePart.scala index f547b19..a249cde 100644 --- a/codechicken/multipart/TFacePart.scala +++ b/codechicken/multipart/TFacePart.scala @@ -3,4 +3,5 @@ package codechicken.multipart trait TFacePart extends TMultiPart { def solid(side:Int):Boolean = true + def redstoneConductionMap = 0 } \ No newline at end of file diff --git a/codechicken/multipart/TMultiPart.scala b/codechicken/multipart/TMultiPart.scala index ab613e7..847ac0a 100644 --- a/codechicken/multipart/TMultiPart.scala +++ b/codechicken/multipart/TMultiPart.scala @@ -41,8 +41,6 @@ abstract class TMultiPart tile = t } - def blocksRedstone:Boolean = false//Not necessarily sure this is the best way to test this - def occlusionTest(npart:TMultiPart):Boolean = true def getSubParts:JSeq[IndexedCuboid6] = Seq() def getCollisionBoxes:JSeq[Cuboid6] = Seq() diff --git a/codechicken/multipart/TileMultipart.scala b/codechicken/multipart/TileMultipart.scala index 58d1252..0ca5f63 100644 --- a/codechicken/multipart/TileMultipart.scala +++ b/codechicken/multipart/TileMultipart.scala @@ -79,9 +79,9 @@ class TileMultipart extends TileEntity { super.updateEntity() - TileMultipartObj.startOperation(this) + TileMultipart.startOperation(this) partList.foreach(_.update()) - TileMultipartObj.finishOperation(this) + TileMultipart.finishOperation(this) } override def onChunkUnload() @@ -111,9 +111,9 @@ class TileMultipart extends TileEntity def notifyPartChange() { - TileMultipartObj.startOperation(this) + TileMultipart.startOperation(this) partList.foreach(_.onPartChanged()) - TileMultipartObj.finishOperation(this) + TileMultipart.finishOperation(this) worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID) worldObj.updateAllLightTypes(xCoord, yCoord, zCoord) @@ -121,9 +121,9 @@ class TileMultipart extends TileEntity def onNeighborBlockChange(world:World, x:Int, y:Int, z:Int, id:Int) { - TileMultipartObj.startOperation(this) + TileMultipart.startOperation(this) partList.foreach(_.onNeighborChanged()) - TileMultipartObj.finishOperation(this) + TileMultipart.finishOperation(this) } def getLightValue() = partList.foldLeft(0)((l, p) => Math.max(l, p.getLightValue)) @@ -183,7 +183,7 @@ class TileMultipart extends TileEntity private[multipart] def getWriteStream = MultipartSPH.getTileStream(worldObj, new BlockCoord(this)) - private[multipart] def addPart(part:TMultiPart) + private[multipart] def addPart_impl(part:TMultiPart) { if(!worldObj.isRemote) writeAddPart(part) @@ -205,8 +205,7 @@ class TileMultipart extends TileEntity private[multipart] def addPart_do(part:TMultiPart) { - if(partList.size >= 250) - throw new IllegalArgumentException("Tried to add more than 250 parts to the one tile. You're doing it wrong") + assert(partList.size < 250, "Tried to add more than 250 parts to the one tile. You're doing it wrong") partList+=part bindPart(part) @@ -225,9 +224,16 @@ class TileMultipart extends TileEntity def remPart(part:TMultiPart):TileMultipart = { - if(TileMultipartObj.queueRemoval(this, part)) + assert(!worldObj.isRemote, "Cannot remove multi parts from a client tile") + + if(TileMultipart.queueRemoval(this, part)) return null + remPart_impl(part) + } + + private[multipart] def remPart_impl(part:TMultiPart):TileMultipart = + { val i = remPart_do(part) if(!isInvalid()) { @@ -311,7 +317,7 @@ class TileMultipart extends TileEntity def dropItems(items:Seq[ItemStack]) { val pos = Vector3.fromTileEntityCenter(this) - items.foreach(item => TileMultipartObj.dropItem(item, worldObj, pos)) + items.foreach(item => TileMultipart.dropItem(item, worldObj, pos)) } def markRender() @@ -334,9 +340,9 @@ class TileMultipart extends TileEntity def onEntityCollision(entity:Entity) { - TileMultipartObj.startOperation(this) + TileMultipart.startOperation(this) partList.foreach(_.onEntityCollision(entity)) - TileMultipartObj.finishOperation(this) + TileMultipart.finishOperation(this) } def strongPowerLevel(side:Int) = 0 @@ -373,7 +379,7 @@ class TileMultipartClient extends TileMultipart } } -object TileMultipartObj +object TileMultipart { var renderID:Int = -1 @@ -411,7 +417,7 @@ object TileMultipartObj val world = tile.worldObj val pos = new BlockCoord(tile) while(!removalQueue.isEmpty) - otile = otile.remPart(removalQueue.dequeue) + otile = otile.remPart_impl(removalQueue.dequeue) while(!additionQueue.isEmpty) MultipartGenerator.addPart(world, pos, additionQueue.dequeue) @@ -499,17 +505,7 @@ object TileMultipartObj } } - private var operationSync_ = new ThreadLocal[OperationSynchroniser] - private def operationSync():OperationSynchroniser = - { - var r = operationSync_.get - if(r == null) - { - r = new OperationSynchroniser - operationSync_.set(r) - } - return r - } + private val operationSync = new OperationSynchroniser def startOperation(tile:TileMultipart) = operationSync.startOperation(tile) @@ -550,7 +546,7 @@ object TileMultipartObj return null } - def canAddPart(world:World, pos:BlockCoord, part:TMultiPart):Boolean = + def canPlacePart(world:World, pos:BlockCoord, part:TMultiPart):Boolean = { part.getCollisionBoxes.foreach{b => if(!world.checkNoEntityCollision(b.toAABB().offset(pos.x, pos.y, pos.z))) @@ -575,6 +571,8 @@ object TileMultipartObj def addPart(world:World, pos:BlockCoord, part:TMultiPart):TileMultipart = { + assert(!world.isRemote, "Cannot add multi parts to a client tile.") + if(queueAddition(world, pos, part)) return null @@ -613,10 +611,10 @@ object TileMultipartObj case 253 => { val part = MultiPartRegistry.readPart(packet) part.readDesc(packet) - addPart(world, pos, part) + MultipartGenerator.addPart(world, pos, part) } case 254 => if(tilemp != null) { - tilemp.remPart(tilemp.partList(packet.readUnsignedByte())) + tilemp.remPart_impl(tilemp.partList(packet.readUnsignedByte())) } case _ => if(tilemp != null) { tilemp.partList(i).read(packet) diff --git a/codechicken/multipart/asm/ASMMixinCompiler.scala b/codechicken/multipart/asm/ASMMixinCompiler.scala index 52cca9e..f2ae9e2 100644 --- a/codechicken/multipart/asm/ASMMixinCompiler.scala +++ b/codechicken/multipart/asm/ASMMixinCompiler.scala @@ -86,7 +86,11 @@ object ASMMixinCompiler def isScala(cnode:ClassNode) = ScalaSigReader.ann(cnode).isDefined - def isTrait(cnode:ClassNode) = ScalaSigReader.read(ScalaSigReader.ann(cnode).get).evalT[ClassSymbol](0).isTrait + def isTrait(cnode:ClassNode) = + { + val csym:ClassSymbol = ScalaSigReader.read(ScalaSigReader.ann(cnode).get).evalT(0) + csym.isTrait && !csym.isInterface + } def getMixinInfo(name:String) = mixinMap.get(name) @@ -517,8 +521,11 @@ object ASMMixinCompiler def registerScalaTrait(cnode:ClassNode) { for(i <- cnode.interfaces) - if(classNode(i+"$class") != null) + { + val inode = classNode(i) + if(isScala(inode) && isTrait(inode)) throw new IllegalArgumentException("Multipart trait "+cnode.name+" cannot extend other traits") + } val fieldAccessors = MMap[String, MethodSymbol]() val fields = MList[MethodSymbol]() diff --git a/codechicken/multipart/asm/ScalaSignature.scala b/codechicken/multipart/asm/ScalaSignature.scala index 79fe44d..061df70 100644 --- a/codechicken/multipart/asm/ScalaSignature.scala +++ b/codechicken/multipart/asm/ScalaSignature.scala @@ -30,10 +30,10 @@ object ScalaSignature { def hasFlag(flag:Int):Boolean - def isProtected = hasFlag(0x00000001) def isPrivate = hasFlag(0x00000004) - def isAbstract = hasFlag(0x00000008) - def isInterface = hasFlag(0x00000080) + def isProtected = hasFlag(0x00000008) + def isAbstract = hasFlag(0x00000080) + def isInterface = hasFlag(0x00000800) def isMethod = hasFlag(0x00000200) def isParam = hasFlag(0x00002000) def isStatic = hasFlag(0x00800000) diff --git a/codechicken/multipart/handler/EventHandler.scala b/codechicken/multipart/handler/EventHandler.scala index 521285d..4467bcc 100644 --- a/codechicken/multipart/handler/EventHandler.scala +++ b/codechicken/multipart/handler/EventHandler.scala @@ -3,7 +3,6 @@ package codechicken.multipart.handler import net.minecraft.nbt.NBTTagCompound import codechicken.multipart.TileMultipart import net.minecraftforge.event.ForgeSubscribe -import codechicken.multipart.TileMultipartObj import cpw.mods.fml.common.network.IConnectionHandler import net.minecraft.network.packet.NetHandler import net.minecraft.network.INetworkManager diff --git a/codechicken/multipart/handler/MultipartSaveLoad.scala b/codechicken/multipart/handler/MultipartSaveLoad.scala index 2a8f1dd..580f5af 100644 --- a/codechicken/multipart/handler/MultipartSaveLoad.scala +++ b/codechicken/multipart/handler/MultipartSaveLoad.scala @@ -5,7 +5,7 @@ import net.minecraft.nbt.NBTTagCompound import java.util.Map import net.minecraft.world.chunk.Chunk import net.minecraft.world.ChunkPosition -import codechicken.multipart.TileMultipartObj +import codechicken.multipart.TileMultipart /** @@ -54,7 +54,7 @@ object MultipartSaveLoad val e = iterator.next if(e.getValue.isInstanceOf[TileNBTContainer]) { - val t = TileMultipartObj.createFromNBT(e.getValue.asInstanceOf[TileNBTContainer].tag) + val t = TileMultipart.createFromNBT(e.getValue.asInstanceOf[TileNBTContainer].tag) if(t != null) { t.setWorldObj(e.getValue.worldObj) diff --git a/codechicken/multipart/handler/PacketHandlers.scala b/codechicken/multipart/handler/PacketHandlers.scala index b5c9626..2449ea3 100644 --- a/codechicken/multipart/handler/PacketHandlers.scala +++ b/codechicken/multipart/handler/PacketHandlers.scala @@ -10,7 +10,7 @@ import net.minecraft.network.NetServerHandler import net.minecraft.entity.player.EntityPlayerMP import codechicken.multipart.TileMultipart import codechicken.multipart.ControlKeyModifer -import codechicken.multipart.TileMultipartObj +import codechicken.multipart.TileMultipart import net.minecraft.network.packet.Packet255KickDisconnect import net.minecraft.server.MinecraftServer import net.minecraft.world.World @@ -53,7 +53,7 @@ object MultipartCPH extends IClientPacketHandler { val cc = new ChunkCoordIntPair(packet.readInt, packet.readInt) while(packet.more) - TileMultipartObj.handleDescPacket(world, indexInChunk(cc, packet.readShort), packet) + TileMultipart.handleDescPacket(world, indexInChunk(cc, packet.readShort), packet) } def handleCompressedTileData(packet:PacketCustom, world:World) @@ -64,7 +64,7 @@ object MultipartCPH extends IClientPacketHandler var i = packet.readUnsignedByte while(i < 255) { - TileMultipartObj.handlePacket(pos, world, i, packet) + TileMultipart.handlePacket(pos, world, i, packet) i = packet.readUnsignedByte } } diff --git a/codechicken/multipart/minecraft/EventHandler.java b/codechicken/multipart/minecraft/EventHandler.java index e55434b..7b6e836 100644 --- a/codechicken/multipart/minecraft/EventHandler.java +++ b/codechicken/multipart/minecraft/EventHandler.java @@ -5,7 +5,6 @@ import codechicken.core.raytracer.RayTracer; import codechicken.core.vec.BlockCoord; import codechicken.core.vec.Vector3; import codechicken.multipart.TileMultipart; -import codechicken.multipart.TileMultipartObj; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -65,13 +64,13 @@ public class EventHandler } } - TileMultipart tile = TileMultipartObj.getOrConvertTile(world, pos); + TileMultipart tile = TileMultipart.getOrConvertTile(world, pos); if(tile == null || !tile.canAddPart(part)) return false; if(!world.isRemote) { - TileMultipartObj.addPart(world, pos, part); + TileMultipart.addPart(world, pos, part); world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, part.getBlock().stepSound.getPlaceSound(), (part.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, diff --git a/codechicken/multipart/minecraft/McSidedMetaPart.java b/codechicken/multipart/minecraft/McSidedMetaPart.java index 86c69fc..06ac201 100644 --- a/codechicken/multipart/minecraft/McSidedMetaPart.java +++ b/codechicken/multipart/minecraft/McSidedMetaPart.java @@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeDirection; import codechicken.core.vec.BlockCoord; import codechicken.core.vec.Vector3; -import codechicken.multipart.TileMultipartObj; +import codechicken.multipart.TileMultipart; public abstract class McSidedMetaPart extends McMetaPart { @@ -40,6 +40,6 @@ public abstract class McSidedMetaPart extends McMetaPart public void drop() { tile().remPart(this); - TileMultipartObj.dropItem(new ItemStack(getBlock()), world(), Vector3.fromTileEntityCenter(getTile())); + TileMultipart.dropItem(new ItemStack(getBlock()), world(), Vector3.fromTileEntityCenter(getTile())); } } diff --git a/codechicken/multipart/scalatraits/TRedstone.scala b/codechicken/multipart/scalatraits/TRedstone.scala index 182ae1b..6d92015 100644 --- a/codechicken/multipart/scalatraits/TRedstone.scala +++ b/codechicken/multipart/scalatraits/TRedstone.scala @@ -7,6 +7,9 @@ import codechicken.multipart.RedstoneInteractions._ import codechicken.multipart.PartMap._ import codechicken.core.vec.Rotation._ import codechicken.multipart.IRedstoneTile +import codechicken.multipart.TFacePart +import codechicken.multipart.TEdgePart +import codechicken.multipart.TEdgePart trait TRedstoneTile extends TileMultipart with IRedstoneTile { @@ -23,21 +26,27 @@ trait TRedstoneTile extends TileMultipart with IRedstoneTile def openConnections(side:Int):Int = { - if(blocksRedstone(side)) - return 0 - var m = 0x10 var i = 0 while(i < 4) { - if(!blocksRedstone(edgeBetween(side, rotateSide(side&6, i)))) + if(redstoneConductionE(edgeBetween(side, rotateSide(side&6, i)))) m|=1< 0x1F + case p => p.asInstanceOf[TFacePart].redstoneConductionMap + } + + def redstoneConductionE(i:Int) = partMap(i) match { + case null => true + case p => p.asInstanceOf[TEdgePart].conductsRedstone + } override def weakPowerLevel(side:Int):Int = weakPowerLevel(side, otherConnectionMask(worldObj, xCoord, yCoord, zCoord, side, true))