Fixed bounding box weirdness for blocks with stateful bounds (keyboards and cables, most notably). Closes #699.

This commit is contained in:
Florian Nücke 2014-11-29 21:42:11 +01:00
parent 3966def5d3
commit 42f5fb7c6b
3 changed files with 8 additions and 3 deletions

View File

@ -57,7 +57,7 @@ class Keyboard extends SimpleBlock with traits.SpecialBlock {
}) })
} }
override def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) = override protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int) =
world.getTileEntity(x, y, z) match { world.getTileEntity(x, y, z) match {
case keyboard: tileentity.Keyboard => setBlockBounds(keyboard.pitch, keyboard.yaw) case keyboard: tileentity.Keyboard => setBlockBounds(keyboard.pitch, keyboard.yaw)
case _ => case _ =>

View File

@ -193,7 +193,7 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int): Unit = protected def doSetBlockBoundsBasedOnState(world: IBlockAccess, x: Int, y: Int, z: Int): Unit =
super.setBlockBoundsBasedOnState(world, x, y, z) super.setBlockBoundsBasedOnState(world, x, y, z)
def setBlockBounds(bounds: AxisAlignedBB) { protected def setBlockBounds(bounds: AxisAlignedBB) {
setBlockBounds( setBlockBounds(
bounds.minX.toFloat, bounds.minX.toFloat,
bounds.minY.toFloat, bounds.minY.toFloat,
@ -207,6 +207,11 @@ class SimpleBlock(material: Material = Material.iron) extends Block(material) {
override def collisionRayTrace(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) = override def collisionRayTrace(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) =
this.synchronized(intersect(world, x, y, z, origin, direction)) this.synchronized(intersect(world, x, y, z, origin, direction))
override def getCollisionBoundingBoxFromPool(world: World, x: Int, y: Int, z: Int) = this.synchronized {
doSetBlockBoundsBasedOnState(world, x, y, z)
super.getCollisionBoundingBoxFromPool(world, x, y, z)
}
protected def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) = protected def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) =
super.collisionRayTrace(world, x, y, z, origin, direction) super.collisionRayTrace(world, x, y, z, origin, direction)

View File

@ -97,7 +97,7 @@ object DebugCard {
} }
} }
@Callback(doc = """function():userdata -- Get the container's world object.""") @Callback(doc = """function():userdata -- Get the player's world object.""")
def getWorld(context: Context, args: Arguments): Array[AnyRef] = { def getWorld(context: Context, args: Arguments): Array[AnyRef] = {
withPlayer(player => result(new DebugCard.WorldValue(player.getEntityWorld))) withPlayer(player => result(new DebugCard.WorldValue(player.getEntityWorld)))
} }