mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-19 19:59:40 +00:00
Fixed unimplemented method in TFluidHandlerTile
Added message for duplicate definition exception in ASMMixinCompiler Cleaned a bit of syntax
This commit is contained in:
1 parent
a68f34f428
commit
cc76ccf821
2 files changed
+52
-21
No files matched your search
@@ -3,7 +3,6 @@ package codechicken.multipart.asm
|
||||
import scala.collection.mutable.{Map => MMap, ListBuffer => MList, Set => MSet}
|
||||
import java.util.{Set => JSet}
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.JavaConverters._
|
||||
import org.objectweb.asm.tree._
|
||||
import org.objectweb.asm.Opcodes._
|
||||
import org.objectweb.asm.ClassReader
|
||||
@@ -78,7 +77,13 @@ object ASMMixinCompiler
|
||||
{
|
||||
internalDefine(name, bytes)
|
||||
DebugPrinter.defined(name, bytes)
|
||||
m_defineClass.invoke(cl, bytes, 0:Integer, bytes.length:Integer).asInstanceOf[Class[_]]
|
||||
|
||||
try {
|
||||
m_defineClass.invoke(cl, bytes, 0:Integer, bytes.length:Integer).asInstanceOf[Class[_]]
|
||||
} catch {
|
||||
case link:LinkageError if link.getMessage.contains("duplicate") =>
|
||||
throw new IllegalStateException("class with name: "+name+" already loaded. Do not reference your mixin classes before registering them with MultipartGenerator", link)
|
||||
}
|
||||
}
|
||||
|
||||
getBytes("cpw/mods/fml/common/asm/FMLSanityChecker")
|
||||
@@ -236,7 +241,7 @@ object ASMMixinCompiler
|
||||
|
||||
def exportedMethods(o:ClassInfoSource):Map[String, MethodNodeInfo] =
|
||||
{
|
||||
val eMethods = o.methods.filter(!_.isPrivate)//defined accessable methods
|
||||
val eMethods = o.methods.filter(!_.isPrivate)//defined accessible methods
|
||||
.map(m => (m.name+m.desc, MethodNodeInfo(o.name, m))).toMap
|
||||
|
||||
eMethods ++ (o.superClass++o.interfaces).flatMap(_.publicmethods)
|
||||
@@ -344,7 +349,7 @@ object ASMMixinCompiler
|
||||
def staticDesc(owner:String, desc:String) =
|
||||
{
|
||||
val descT = getMethodType(desc)
|
||||
getMethodDescriptor(descT.getReturnType, (getType("L"+owner+";")+:descT.getArgumentTypes):_*)
|
||||
getMethodDescriptor(descT.getReturnType, getType("L"+owner+";")+:descT.getArgumentTypes : _*)
|
||||
}
|
||||
|
||||
def getSuper(minsn:MethodInsnNode, stack:StackAnalyser):Option[String] =
|
||||
@@ -383,7 +388,7 @@ object ASMMixinCompiler
|
||||
if((cnode.access & ACC_ABSTRACT) != 0)
|
||||
throw new IllegalArgumentException("Cannot register abstract class "+cnode.name+" as a multipart trait")
|
||||
if(!cnode.innerClasses.isEmpty)
|
||||
throw new IllegalArgumentException("Inner classes are not permitted for "+cnode.name+" as a multipart trait")
|
||||
throw new IllegalArgumentException("Inner classes are not permitted for "+cnode.name+" as a multipart trait. Use scala")
|
||||
|
||||
val inode = new ClassNode()//impl node
|
||||
inode.visit(V1_6, ACC_ABSTRACT|ACC_PUBLIC, cnode.name+"$class", null, "java/lang/Object", null)
|
||||
@@ -476,7 +481,7 @@ object ASMMixinCompiler
|
||||
if(!mnode.desc.equals("()V"))
|
||||
throw new IllegalArgumentException("Constructor arguments are not permitted "+cnode.name+" as a multipart trait")
|
||||
|
||||
var mv = staticClone(mnode, "$init$", ACC_PUBLIC)
|
||||
val mv = staticClone(mnode, "$init$", ACC_PUBLIC)
|
||||
def removeSuperConstructor()
|
||||
{
|
||||
def throwI = throw new IllegalArgumentException("Invalid constructor insn sequence "+cnode.name)
|
||||
@@ -486,7 +491,7 @@ object ASMMixinCompiler
|
||||
var state = 0
|
||||
while(insn != null && state < 2)
|
||||
{
|
||||
var next = insn.getNext
|
||||
val next = insn.getNext
|
||||
insn match {
|
||||
case linsn:LabelNode =>
|
||||
case linsn:LineNumberNode =>
|
||||
@@ -537,12 +542,12 @@ object ASMMixinCompiler
|
||||
|
||||
//convert that method!
|
||||
val access = if((mnode.access & ACC_PRIVATE) == 0) ACC_PUBLIC else ACC_PRIVATE
|
||||
var mv = staticClone(mnode, mnode.name, access)
|
||||
val mv = staticClone(mnode, mnode.name, access)
|
||||
staticTransform(mv, mnode)
|
||||
}
|
||||
|
||||
cnode.methods.foreach(convertMethod)
|
||||
|
||||
|
||||
define(inode.name, createBytes(inode, 0))
|
||||
define(tnode.name, createBytes(tnode, 0))
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import net.minecraftforge.fluids.Fluid
|
||||
|
||||
/**
|
||||
* Mixin trait implementation for parts implementing IFluidHandler.
|
||||
* Distributes fluid manipulation amoung fluid handling parts.
|
||||
* Distributes fluid manipulation among fluid handling parts.
|
||||
*/
|
||||
trait TFluidHandlerTile extends TileMultipart with IFluidHandler
|
||||
class TFluidHandlerTile extends TileMultipart with IFluidHandler
|
||||
{
|
||||
var tankList = ListBuffer[IFluidHandler]()
|
||||
|
||||
@@ -42,7 +42,7 @@ trait TFluidHandlerTile extends TileMultipart with IFluidHandler
|
||||
override def clearParts()
|
||||
{
|
||||
super.clearParts()
|
||||
tankList.clear
|
||||
tankList.clear()
|
||||
}
|
||||
|
||||
override def getTankInfo(dir:ForgeDirection):Array[FluidTankInfo] =
|
||||
@@ -61,7 +61,7 @@ trait TFluidHandlerTile extends TileMultipart with IFluidHandler
|
||||
override def fill(dir:ForgeDirection, liquid:FluidStack, doFill:Boolean):Int =
|
||||
{
|
||||
var filled = 0
|
||||
var initial = liquid.amount
|
||||
val initial = liquid.amount
|
||||
tankList.foreach(p =>
|
||||
filled+=p.fill(dir, copy(liquid, initial-filled), doFill)
|
||||
)
|
||||
@@ -72,33 +72,59 @@ trait TFluidHandlerTile extends TileMultipart with IFluidHandler
|
||||
|
||||
override def canDrain(dir:ForgeDirection, liquid:Fluid) = tankList.find(_.canDrain(dir, liquid)).isDefined
|
||||
|
||||
def copy(liquid:FluidStack, quantity:Int):FluidStack =
|
||||
private def copy(liquid:FluidStack, quantity:Int):FluidStack =
|
||||
{
|
||||
val copy = liquid.copy
|
||||
copy.amount = quantity
|
||||
return copy
|
||||
}
|
||||
|
||||
override def drain(dir:ForgeDirection, amount:Int, doDrain:Boolean):FluidStack =
|
||||
|
||||
override def drain(dir:ForgeDirection, amount:Int, doDrain:Boolean):FluidStack =
|
||||
{
|
||||
var drained:FluidStack = null
|
||||
var d_amount = 0
|
||||
tankList.foreach{p =>
|
||||
val ret = p.drain(dir, amount-d_amount, false)
|
||||
val drain = amount-d_amount
|
||||
val ret = p.drain(dir, drain, false)
|
||||
if(ret != null && ret.amount > 0 && (drained == null || drained.isFluidEqual(ret)))
|
||||
{
|
||||
if(doDrain)
|
||||
p.drain(dir, amount-d_amount, true)
|
||||
|
||||
p.drain(dir, drain, true)
|
||||
|
||||
if(drained == null)
|
||||
drained = ret
|
||||
|
||||
|
||||
d_amount+=ret.amount
|
||||
}
|
||||
}
|
||||
if(drained != null)
|
||||
drained.amount = d_amount
|
||||
|
||||
|
||||
return drained
|
||||
}
|
||||
|
||||
override def drain(dir:ForgeDirection, fluid:FluidStack, doDrain:Boolean):FluidStack =
|
||||
{
|
||||
val amount = fluid.amount
|
||||
var drained:FluidStack = null
|
||||
var d_amount = 0
|
||||
tankList.foreach{p =>
|
||||
val drain = copy(fluid, amount-d_amount)
|
||||
val ret = p.drain(dir, drain, false)
|
||||
if(ret != null && ret.amount > 0 && (drained == null || drained.isFluidEqual(ret)))
|
||||
{
|
||||
if(doDrain)
|
||||
p.drain(dir, drain, true)
|
||||
|
||||
if(drained == null)
|
||||
drained = ret
|
||||
|
||||
d_amount+=ret.amount
|
||||
}
|
||||
}
|
||||
if(drained != null)
|
||||
drained.amount = d_amount
|
||||
|
||||
return drained
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user