Fixed MultipartGenerator crashing with interfaces that override methods

Fixed a harvest bug
Some syntax cleanup
Changed references to getWorldTime to getTotalWorldTime
This commit is contained in:
Chicken-Bones committed 2013-12-22 00:51:08 +10:00
1 parent bcfe499556
commit 3b3460279f
8 files changed
+32 -39

No files matched your search

+2 -1
View File
@@ -131,7 +131,8 @@ class BlockMultipart(id:Int) extends Block(id, Material.rock)
return true
}
return tile.harvestPart(index, mop, player)
tile.harvestPart(index, mop, player)
return world.getBlockTileEntity(x, y, z) == null
}
def dropAndDestroy(world:World, x:Int, y:Int, z:Int)
+8 -11
View File
@@ -26,14 +26,14 @@ import codechicken.lib.lighting.LazyLightMatrix
@SideOnly(Side.CLIENT)
object MultipartRenderer extends TileEntitySpecialRenderer with ISimpleBlockRenderingHandler
{
TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId()
TileMultipart.renderID = RenderingRegistry.getNextAvailableRenderId
private val olm = new LazyLightMatrix
var pass:Int = 0
override def renderTileEntityAt(t:TileEntity, x:Double, y:Double, z:Double, f:Float)
{
var tmpart = t.asInstanceOf[TileMultipartClient]
val tmpart = t.asInstanceOf[TileMultipartClient]
if(tmpart.partList.isEmpty)
return
@@ -49,17 +49,17 @@ object MultipartRenderer extends TileEntitySpecialRenderer with ISimpleBlockRend
override def renderWorldBlock(world:IBlockAccess, x:Int, y:Int, z:Int, block:Block, modelId:Int, renderer:RenderBlocks):Boolean =
{
var t = world.getBlockTileEntity(x, y, z)
val t = world.getBlockTileEntity(x, y, z)
if(!t.isInstanceOf[TileMultipartClient])
return false
var tmpart = t.asInstanceOf[TileMultipartClient]
val tmpart = t.asInstanceOf[TileMultipartClient]
if(tmpart.partList.isEmpty)
return false
if(renderer.hasOverrideBlockTexture())
if(renderer.hasOverrideBlockTexture)
{
val hit = Minecraft.getMinecraft().objectMouseOver
val hit = Minecraft.getMinecraft.objectMouseOver
if(hit != null && hit.blockX == x && hit.blockY == y && hit.blockZ == z && ExtendedMOP.getData(hit).isInstanceOf[(_, _)])
{
val hitInfo:(Int, _) = ExtendedMOP.getData(hit)
@@ -77,10 +77,7 @@ object MultipartRenderer extends TileEntitySpecialRenderer with ISimpleBlockRend
return true
}
override def renderInventoryBlock(block:Block, meta:Int, modelId:Int, renderer:RenderBlocks)
{
//TODO: pass to the super renderer.
}
override def renderInventoryBlock(block:Block, meta:Int, modelId:Int, renderer:RenderBlocks) {}
override def shouldRender3DInInventory = false
}
+6 -1
View File
@@ -16,7 +16,12 @@ object PacketScheduler
/**
* Add bits to the current update mask for part. (binary OR)
*/
def schedulePacket(part:TMultiPart, mask:Long) = map.put(part, map.getOrElse(part, 0L)|mask)
def schedulePacket(part:TMultiPart, mask:Long) = {//TODO remove = in 1.7
if(part.world.isRemote)
throw new IllegalArgumentException("Cannot use PacketScheduler on a client world")
map.put(part, map.getOrElse(part, 0L)|mask)
}
private[multipart] def sendScheduled() {
map.foreach{ e =>
+1 -1
View File
@@ -280,7 +280,7 @@ abstract class TMultiPart
* This should not modify the part client side. If the client call returns false, the server will not call this function.
* @param hit An instance of ExtendedMOP from collisionRayTrace
*/
def activate(player:EntityPlayer, hit:MovingObjectPosition, item:ItemStack):Boolean = false
def activate(player:EntityPlayer, hit:MovingObjectPosition, item:ItemStack) = false
/**
* Called on block left click. item is the player's held item.
* @param hit An instance of ExtendedMOP from collisionRayTrace
+3 -1
View File
@@ -107,7 +107,7 @@ object TickScheduler extends WorldExtensionInstantiator
if(tag.hasKey("schedTime"))
schedTime = tag.getLong("schedTime")
else
schedTime = world.getWorldTime
schedTime = world.getTotalWorldTime
}
def saveTag():NBTTagCompound =
@@ -274,6 +274,8 @@ object TickScheduler extends WorldExtensionInstantiator
/**
* Returns the current scheduler time. Like the world time, but unaffected by the time set command and other things changing time of day.
* Deprecated in favor of world.getTotalWorldTime
*/
@Deprecated
def getSchedulerTime(world:World):Long = getExtension(world).asInstanceOf[WorldTickScheduler].schedTime
}
+4 -8
View File
@@ -462,14 +462,10 @@ class TileMultipart extends TileEntity
/**
* Drop and remove part at index (internal mining callback)
*/
def harvestPart(index:Int, hit:ExtendedMOP, player:EntityPlayer):Boolean =
partList(index) match {
case null => false
case part => {
part.harvest(hit, player)
partList.isEmpty
}
}
def harvestPart(index:Int, hit:ExtendedMOP, player:EntityPlayer) = partList(index) match {
case null =>
case part => part.harvest(hit, player)
}
/**
* Utility function for dropping items around the center of this space
@@ -4,21 +4,12 @@ import scala.collection.Seq
import codechicken.multipart.TileMultipart
import codechicken.multipart.TileMultipartClient
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import org.objectweb.asm.Opcodes._
import org.objectweb.asm.ClassWriter
import codechicken.lib.asm.CC_ClassWriter
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.FieldVisitor
import org.objectweb.asm.Label
import cpw.mods.fml.relauncher.ReflectionHelper
import org.objectweb.asm.commons.RemappingClassAdapter
import org.objectweb.asm.commons.SimpleRemapper
import scala.collection.mutable.ArrayBuffer
import org.objectweb.asm.tree._
import org.objectweb.asm.Type
import Type._
import scala.collection.immutable.Range
import codechicken.lib.asm.ASMHelper._
import codechicken.lib.asm.ObfMapping
import codechicken.multipart.MultipartGenerator
@@ -291,12 +282,13 @@ object ASMMixinFactory extends IMultipartFactory
mv.visitEnd()
}
def methods(cnode:ClassNode):Seq[MethodNode] =
def methods(cnode:ClassNode):Map[String, MethodNode] =
{
val m = cnode.methods
val m = cnode.methods.map(m => (m.name+m.desc, m)).toMap
if(cnode.interfaces != null)
m++=cnode.interfaces.flatMap(i => methods(classNode(i)))
m
m++cnode.interfaces.flatMap(i => methods(classNode(i)))
else
m
}
def generatePassThroughMethod(m:MethodNode)
@@ -307,7 +299,7 @@ object ASMMixinFactory extends IMultipartFactory
finishBridgeCall(mv, m.desc, INVOKEINTERFACE, iname, m.name, m.desc)
}
methods(inode).foreach(generatePassThroughMethod(_))
methods(inode).values.foreach(generatePassThroughMethod(_))
cw.visitEnd()
internalDefine(tname, cw.toByteArray)
@@ -144,13 +144,13 @@ public class RedstoneTorchPart extends TorchPart implements IFaceRedstonePart, I
private boolean burnedOut(boolean add)
{
long time = world().getWorldTime();
long time = world().getTotalWorldTime();
while(burnout != null && burnout.timeout <= time)
burnout = burnout.next;
if(add)
{
BurnoutEntry e = new BurnoutEntry(world().getWorldTime()+60);
BurnoutEntry e = new BurnoutEntry(world().getTotalWorldTime()+60);
if(burnout == null)
burnout = e;
else