mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 09:18:05 -04:00
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:
parent
fef2784141
commit
d52ed578b7
@ -1,10 +1,15 @@
|
|||||||
package li.cil.oc.api.event;
|
package li.cil.oc.api.event;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
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.Agent;
|
||||||
|
import li.cil.oc.api.internal.Robot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import org.lwjgl.util.vector.Vector3f;
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
import org.lwjgl.util.vector.Vector4f;
|
import org.lwjgl.util.vector.Vector4f;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired directly before the robot's chassis is rendered.
|
* Fired directly before the robot's chassis is rendered.
|
||||||
* <p/>
|
* <p/>
|
||||||
@ -57,5 +62,20 @@ public class RobotRenderEvent extends RobotEvent {
|
|||||||
* Note that the rotation is applied <em>before</em> the translation.
|
* Note that the rotation is applied <em>before</em> the translation.
|
||||||
*/
|
*/
|
||||||
public final Vector4f rotation = new Vector4f(0, 0, 0, 0);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ import scala.collection.mutable
|
|||||||
object RobotRenderer extends TileEntitySpecialRenderer {
|
object RobotRenderer extends TileEntitySpecialRenderer {
|
||||||
private val displayList = GLAllocation.generateDisplayLists(2)
|
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(
|
private val slotNameMapping = Map(
|
||||||
UpgradeRenderer.MountPointName.TopLeft -> 0,
|
UpgradeRenderer.MountPointName.TopLeft -> 0,
|
||||||
@ -50,6 +50,10 @@ object RobotRenderer extends TileEntitySpecialRenderer {
|
|||||||
UpgradeRenderer.MountPointName.BottomFront -> 6
|
UpgradeRenderer.MountPointName.BottomFront -> 6
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for ((name, index) <- slotNameMapping) {
|
||||||
|
mountPoints(index) = new RobotRenderEvent.MountPoint(name)
|
||||||
|
}
|
||||||
|
|
||||||
private val gap = 1.0f / 28.0f
|
private val gap = 1.0f / 28.0f
|
||||||
private val gt = 0.5f + gap
|
private val gt = 0.5f + gap
|
||||||
private val gb = 0.5f - gap
|
private val gb = 0.5f - gap
|
||||||
|
@ -64,7 +64,7 @@ object AssemblerTemplates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def assemble(inventory: IInventory) = IMC.tryInvokeStatic(assembler, inventory)(null: Array[AnyRef]) match {
|
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 Array(stack: ItemStack) => (stack, 0.0)
|
||||||
case _ => (null, 0.0)
|
case _ => (null, 0.0)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user