mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-20 04:09:45 +00:00
Renamed TileMultipartObj to TileMultipart as TileMultipart is now class instead of trait
Fixed hollow occlusion Fixed hollow redstone conduction Added MultiPart item base class
This commit is contained in:
1 parent
3d68d5e3de
commit
62457e8155
21 files changed
+134
-91
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =
|
||||
{
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package codechicken.multipart
|
||||
|
||||
trait TEdgePart extends TMultiPart
|
||||
{
|
||||
def conductsRedstone = false
|
||||
}
|
||||
@@ -3,4 +3,5 @@ package codechicken.multipart
|
||||
trait TFacePart extends TMultiPart
|
||||
{
|
||||
def solid(side:Int):Boolean = true
|
||||
def redstoneConductionMap = 0
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
@@ -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<<i
|
||||
i+=1
|
||||
}
|
||||
m&=redstoneConductionF(side)
|
||||
return m
|
||||
}
|
||||
|
||||
def blocksRedstone(i:Int) = partMap(i) != null && partMap(i).blocksRedstone
|
||||
def redstoneConductionF(i:Int) = partMap(i) match {
|
||||
case null => 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))
|
||||
|
||||
Reference in new issue
Block a user