Add mount point name to mount point class.

Allow template's assemble to return a `Number`, not only `Double`s.
This commit is contained in:
Florian Nücke 2015-04-23 18:54:12 +02:00
parent fef2784141
commit d52ed578b7
3 changed files with 26 additions and 2 deletions

View File

@ -1,10 +1,15 @@
package li.cil.oc.api.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import li.cil.oc.api.driver.item.UpgradeRenderer;
import li.cil.oc.api.internal.Agent;
import li.cil.oc.api.internal.Robot;
import net.minecraft.item.ItemStack;
import org.lwjgl.util.vector.Vector3f;
import org.lwjgl.util.vector.Vector4f;
import java.util.Set;
/**
* Fired directly before the robot's chassis is rendered.
* <p/>
@ -57,5 +62,20 @@ public class RobotRenderEvent extends RobotEvent {
* Note that the rotation is applied <em>before</em> the translation.
*/
public final Vector4f rotation = new Vector4f(0, 0, 0, 0);
/**
* The mount point's reference name.
* <p/>
* This is what's used in {@link UpgradeRenderer#computePreferredMountPoint(ItemStack, Robot, Set)}.
*/
public final String name;
public MountPoint() {
name = null;
}
public MountPoint(String name) {
this.name = name;
}
}
}

View File

@ -38,7 +38,7 @@ import scala.collection.mutable
object RobotRenderer extends TileEntitySpecialRenderer {
private val displayList = GLAllocation.generateDisplayLists(2)
private val mountPoints = Array.fill(7)(new RobotRenderEvent.MountPoint())
private val mountPoints = new Array[RobotRenderEvent.MountPoint](7)
private val slotNameMapping = Map(
UpgradeRenderer.MountPointName.TopLeft -> 0,
@ -50,6 +50,10 @@ object RobotRenderer extends TileEntitySpecialRenderer {
UpgradeRenderer.MountPointName.BottomFront -> 6
)
for ((name, index) <- slotNameMapping) {
mountPoints(index) = new RobotRenderEvent.MountPoint(name)
}
private val gap = 1.0f / 28.0f
private val gt = 0.5f + gap
private val gb = 0.5f - gap

View File

@ -64,7 +64,7 @@ object AssemblerTemplates {
}
def assemble(inventory: IInventory) = IMC.tryInvokeStatic(assembler, inventory)(null: Array[AnyRef]) match {
case Array(stack: ItemStack, energy: java.lang.Double) => (stack, energy: Double)
case Array(stack: ItemStack, energy: java.lang.Number) => (stack, energy.doubleValue(): Double)
case Array(stack: ItemStack) => (stack, 0.0)
case _ => (null, 0.0)
}