Converted remaining java classes, not que to be added to RE or removed, into scala
This commit is contained in:
parent
5a7de25f11
commit
96ea35d598
|
@ -1,122 +0,0 @@
|
|||
package resonantinduction.atomic.schematic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.schematic.Schematic;
|
||||
import resonant.lib.type.Pair;
|
||||
import resonantinduction.atomic.AtomicContent;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SchematicFissionReactor extends Schematic
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "schematic.fissionReactor.name";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Vector3, Pair<Block, Integer>> getStructure(ForgeDirection dir, int size)
|
||||
{
|
||||
HashMap<Vector3, Pair<Block, Integer>> returnMap = new HashMap<Vector3, Pair<Block, Integer>>();
|
||||
|
||||
if (size <= 1)
|
||||
{
|
||||
int r = 2;
|
||||
|
||||
for (int x = -r; x <= r; x++)
|
||||
{
|
||||
for (int z = -r; z <= r; z++)
|
||||
{
|
||||
Vector3 targetPosition = new Vector3(x, 0, z);
|
||||
returnMap.put(targetPosition, new Pair(Blocks.water, 0));
|
||||
}
|
||||
}
|
||||
|
||||
r -= 1;
|
||||
|
||||
/** Create turbines and control rods */
|
||||
for (int x = -r; x <= r; x++)
|
||||
{
|
||||
for (int z = -r; z <= r; z++)
|
||||
{
|
||||
Vector3 targetPosition = new Vector3(x, 1, z);
|
||||
returnMap.put(targetPosition, new Pair(Block.getBlockFromName("electricTurbine"), 0));
|
||||
|
||||
if (!((x == -r || x == r) && (z == -r || z == r)) && new Vector3(x, 0, z).magnitude() <= 1)
|
||||
{
|
||||
returnMap.put(new Vector3(x, -1, z), new Pair(AtomicContent.blockControlRod(), 0));
|
||||
returnMap.put(new Vector3(x, -2, z), new Pair(Blocks.sticky_piston, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returnMap.put(new Vector3(0, -1, 0), new Pair(AtomicContent.blockThermometer(), 0));
|
||||
// TODO: IF Siren is a Tile, don't do this. Redstone can't hold it.
|
||||
returnMap.put(new Vector3(0, -3, 0), new Pair(AtomicContent.blockSiren(), 0));
|
||||
returnMap.put(new Vector3(0, -2, 0), new Pair(Blocks.redstone_wire, 0));
|
||||
returnMap.put(new Vector3(), new Pair(AtomicContent.blockReactorCell(), 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
int r = 2;
|
||||
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
for (int x = -r; x <= r; x++)
|
||||
{
|
||||
for (int z = -r; z <= r; z++)
|
||||
{
|
||||
Vector3 targetPosition = new Vector3(x, y, z);
|
||||
Vector3 leveledPosition = new Vector3(0, y, 0);
|
||||
|
||||
if (y < size - 1)
|
||||
{
|
||||
if (targetPosition.distance(leveledPosition) == 2)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair(AtomicContent.blockControlRod(), 0));
|
||||
|
||||
/** Place piston base to push control rods in. */
|
||||
int rotationMetadata = 0;
|
||||
Vector3 offset = new Vector3(x, 0, z).normalize();
|
||||
|
||||
for (ForgeDirection checkDir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (offset.x() == checkDir.offsetX && offset.y() == checkDir.offsetY && offset.z() == checkDir.offsetZ)
|
||||
{
|
||||
rotationMetadata = checkDir.getOpposite().ordinal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
returnMap.put(targetPosition.clone().add(offset), new Pair(Blocks.sticky_piston, rotationMetadata));
|
||||
}
|
||||
else if (x == -r || x == r || z == -r || z == r)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair(Blocks.glass, 0));
|
||||
|
||||
}
|
||||
else if (x == 0 && z == 0)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair(AtomicContent.blockReactorCell(), 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair(Blocks.water, 0));
|
||||
}
|
||||
}
|
||||
else if (targetPosition.distance(leveledPosition) < 2)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair(Block.getBlockFromName("electricTurbine"), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package resonantinduction.atomic.schematic
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.`type`.Pair
|
||||
import resonant.lib.schematic.Schematic
|
||||
import resonantinduction.atomic.AtomicContent
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
class SchematicFissionReactor extends Schematic
|
||||
{
|
||||
def getName: String =
|
||||
{
|
||||
return "schematic.fissionReactor.name"
|
||||
}
|
||||
|
||||
def getStructure(dir: ForgeDirection, size: Int): HashMap[Vector3, Pair[Block, Integer]] =
|
||||
{
|
||||
val returnMap: HashMap[Vector3, Pair[Block, Integer]] = new HashMap[Vector3, Pair[Block, Integer]]
|
||||
if (size <= 1)
|
||||
{
|
||||
var r: Int = 2
|
||||
|
||||
for (x <- -r to r; z <- -r to r)
|
||||
{
|
||||
val targetPosition: Vector3 = new Vector3(x, 0, z)
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](Blocks.water, 0))
|
||||
}
|
||||
|
||||
r -= 1
|
||||
for (x <- -r to r; z <- -r to r)
|
||||
{
|
||||
val targetPosition: Vector3 = new Vector3(x, 1, z)
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](Block.getBlockFromName("electricTurbine"), 0))
|
||||
if (!((x == -r || x == r) && (z == -r || z == r)) && new Vector3(x, 0, z).magnitude <= 1)
|
||||
{
|
||||
returnMap.put(new Vector3(x, -1, z), new Pair[Block, Integer](AtomicContent.blockControlRod, 0))
|
||||
returnMap.put(new Vector3(x, -2, z), new Pair[Block, Integer](Blocks.sticky_piston, 1))
|
||||
}
|
||||
}
|
||||
|
||||
returnMap.put(new Vector3(0, -1, 0), new Pair[Block, Integer](AtomicContent.blockThermometer, 0))
|
||||
returnMap.put(new Vector3(0, -3, 0), new Pair[Block, Integer](AtomicContent.blockSiren, 0))
|
||||
returnMap.put(new Vector3(0, -2, 0), new Pair[Block, Integer](Blocks.redstone_wire, 0))
|
||||
returnMap.put(new Vector3, new Pair[Block, Integer](AtomicContent.blockReactorCell, 0))
|
||||
}
|
||||
else
|
||||
{
|
||||
val r: Int = 2
|
||||
|
||||
for (y <- 0 to size; x <- -r to r; z <- -r to r)
|
||||
{
|
||||
val targetPosition: Vector3 = new Vector3(x, y, z)
|
||||
val leveledPosition: Vector3 = new Vector3(0, y, 0)
|
||||
if (y < size - 1)
|
||||
{
|
||||
if (targetPosition.distance(leveledPosition) == 2)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](AtomicContent.blockControlRod, 0))
|
||||
var rotationMetadata: Int = 0
|
||||
val offset: Vector3 = new Vector3(x, 0, z).normalize
|
||||
for (checkDir <- ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (offset.x == checkDir.offsetX && offset.y == checkDir.offsetY && offset.z == checkDir.offsetZ)
|
||||
{
|
||||
rotationMetadata = checkDir.getOpposite.ordinal
|
||||
}
|
||||
}
|
||||
returnMap.put(targetPosition.clone.add(offset), new Pair[Block, Integer](Blocks.sticky_piston, rotationMetadata))
|
||||
}
|
||||
else if (x == -r || x == r || z == -r || z == r)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](Blocks.glass, 0))
|
||||
}
|
||||
else if (x == 0 && z == 0)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](AtomicContent.blockReactorCell, 0))
|
||||
}
|
||||
else
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](Blocks.water, 0))
|
||||
}
|
||||
}
|
||||
else if (targetPosition.distance(leveledPosition) < 2)
|
||||
{
|
||||
returnMap.put(targetPosition, new Pair[Block, Integer](Block.getBlockFromName("electricTurbine"), 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMap
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package resonantinduction.atomic.schematic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.schematic.Schematic;
|
||||
import resonant.lib.type.Pair;
|
||||
import resonantinduction.atomic.AtomicContent;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SchematicFusionReactor extends Schematic
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "schematic.fusionReactor.name";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Vector3, Pair<Block, Integer>> getStructure(ForgeDirection dir, int size)
|
||||
{
|
||||
HashMap<Vector3, Pair<Block, Integer>> returnMap = new HashMap<Vector3, Pair<Block, Integer>>();
|
||||
|
||||
/** Fusion Torus */
|
||||
int radius = size + 2;
|
||||
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
for (int z = -radius; z <= radius; z++)
|
||||
{
|
||||
for (int y = 0; y <= size; y++)
|
||||
{
|
||||
Vector3 position = new Vector3(x, y, z);
|
||||
double magnitude = Math.sqrt(x * x + z * z);
|
||||
|
||||
if (!returnMap.containsKey(position))
|
||||
{
|
||||
returnMap.put(position, new Pair(0, 0));
|
||||
}
|
||||
|
||||
if (magnitude <= radius)
|
||||
{
|
||||
if (y == 0 || y == size)
|
||||
{
|
||||
if (magnitude >= 1)
|
||||
{
|
||||
double yDeviation = (y == 0 ? size / 3 : -size / 3) + (y == 0 ? -1 : 1) * Math.sin(magnitude / radius * Math.PI) * size / 2d;
|
||||
Vector3 newPos = position.clone().add(0, yDeviation, 0);
|
||||
returnMap.put(newPos.round(), new Pair(AtomicContent.blockElectromagnet(), 1));
|
||||
}
|
||||
}
|
||||
else if (magnitude > radius - 1)
|
||||
{
|
||||
returnMap.put(position, new Pair(AtomicContent.blockElectromagnet(), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Fusion Core */
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
returnMap.put(new Vector3(0, y, 0), new Pair(AtomicContent.blockReactorCell(), 0));
|
||||
returnMap.put(new Vector3(1, y, 0), new Pair(AtomicContent.blockElectromagnet(), 0));
|
||||
returnMap.put(new Vector3(0, y, 1), new Pair(AtomicContent.blockElectromagnet(), 0));
|
||||
returnMap.put(new Vector3(0, y, -1), new Pair(AtomicContent.blockElectromagnet(), 0));
|
||||
returnMap.put(new Vector3(-1, y, 0), new Pair(AtomicContent.blockElectromagnet(), 0));
|
||||
}
|
||||
|
||||
returnMap.put(new Vector3(0, 0, 0), new Pair(AtomicContent.blockReactorCell(), 0));
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package resonantinduction.atomic.schematic
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.`type`.Pair
|
||||
import resonant.lib.schematic.Schematic
|
||||
import resonantinduction.atomic.AtomicContent
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
class SchematicFusionReactor extends Schematic
|
||||
{
|
||||
def getName: String =
|
||||
{
|
||||
return "schematic.fusionReactor.name"
|
||||
}
|
||||
|
||||
def getStructure(dir: ForgeDirection, size: Int): HashMap[Vector3, Pair[Block, Integer]] =
|
||||
{
|
||||
val returnMap: HashMap[Vector3, Pair[Block, Integer]] = new HashMap[Vector3, Pair[Block, Integer]]
|
||||
val r: Int = size + 2
|
||||
for (y <- 0 to size; x <- -r to r; z <- -r to r)
|
||||
{
|
||||
val position: Vector3 = new Vector3(x, y, z)
|
||||
val magnitude: Double = Math.sqrt(x * x + z * z)
|
||||
if (!returnMap.containsKey(position))
|
||||
{
|
||||
returnMap.put(position, new Pair[Block, Integer](Blocks.air, 0))
|
||||
}
|
||||
if (magnitude <= r)
|
||||
{
|
||||
if (y == 0 || y == size)
|
||||
{
|
||||
if (magnitude >= 1)
|
||||
{
|
||||
val yDeviation: Double = (if (y == 0) size / 3 else -size / 3) + (if (y == 0) -1 else 1) * Math.sin(magnitude / r * Math.PI) * size / 2d
|
||||
val newPos: Vector3 = position.clone.add(0, yDeviation, 0)
|
||||
returnMap.put(newPos.round, new Pair[Block, Integer](AtomicContent.blockElectromagnet, 1))
|
||||
}
|
||||
}
|
||||
else if (magnitude > r - 1)
|
||||
{
|
||||
returnMap.put(position, new Pair[Block, Integer](AtomicContent.blockElectromagnet, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (y <- 0 to size)
|
||||
{
|
||||
returnMap.put(new Vector3(0, y, 0), new Pair[Block, Integer](AtomicContent.blockReactorCell, 0))
|
||||
returnMap.put(new Vector3(1, y, 0), new Pair[Block, Integer](AtomicContent.blockElectromagnet, 0))
|
||||
returnMap.put(new Vector3(0, y, 1), new Pair[Block, Integer](AtomicContent.blockElectromagnet, 0))
|
||||
returnMap.put(new Vector3(0, y, -1), new Pair[Block, Integer](AtomicContent.blockElectromagnet, 0))
|
||||
returnMap.put(new Vector3(-1, y, 0), new Pair[Block, Integer](AtomicContent.blockElectromagnet, 0))
|
||||
|
||||
}
|
||||
returnMap.put(new Vector3(0, 0, 0), new Pair[Block, Integer](AtomicContent.blockReactorCell, 0))
|
||||
return returnMap
|
||||
}
|
||||
}
|
|
@ -1,194 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package resonantinduction.electrical.battery;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.glPopMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glPushMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
|
||||
import resonant.lib.render.RenderUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import universalelectricity.core.transform.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* TODO: Make this more efficient.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleItemRenderer
|
||||
{
|
||||
public static RenderBattery INSTANCE = new RenderBattery();
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelPath() + "battery/battery.tcn"));
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
|
||||
{
|
||||
glPushMatrix();
|
||||
GL11.glTranslated(0, 0, 0);
|
||||
int energyLevel = (int) (((double) ((ItemBlockBattery) itemStack.getItem()).getEnergy(itemStack) / (double) ((ItemBlockBattery) itemStack.getItem()).getEnergyCapacity(itemStack)) * 8);
|
||||
RenderUtility.bind(Reference.domain(), Reference.modelPath() + "battery/battery.png");
|
||||
|
||||
List<String> disabledParts = new ArrayList<String>();
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "connector", "connectorIn", "connectorOut" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }));
|
||||
MODEL.renderAllExcept(disabledParts.toArray(new String[0]));
|
||||
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
if (i != 1 || !disabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) <= energyLevel)
|
||||
MODEL.renderOnly("coil" + i + "lit");
|
||||
else
|
||||
MODEL.renderOnly("coil" + i);
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
{
|
||||
final String[][] partToDisable = new String[][] { new String[] { "bottom" }, new String[] { "top" }, new String[] { "frame1", "frame2" }, new String[] { "frame3", "frame4" }, new String[] { "frame4", "frame1" }, new String[] { "frame2", "frame3" } };
|
||||
final String[][] connectionPartToEnable = new String[][] { null, null, new String[] { "frame1con", "frame2con" }, new String[] { "frame3con", "frame4con" }, new String[] { "frame4con", "frame1con" }, new String[] { "frame2con", "frame3con" } };
|
||||
// final String[][] connectionPartSideToEnable = new String[][] { null, null, new String[] {
|
||||
// "frame1conSide", "frame2conSide" }, new String[] { "frame3conSide", "frame4conSide" },
|
||||
// new String[] { "frame4conSide", "frame1conSide" }, new String[] { "frame2conSide",
|
||||
// "frame3conSide" } };
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
|
||||
TileBattery tile = (TileBattery) t;
|
||||
|
||||
int energyLevel = (int) Math.round(((double) tile.energy().getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
|
||||
RenderUtility.bind(Reference.domain(), Reference.modelPath() + "battery/battery.png");
|
||||
|
||||
List<String> disabledParts = new ArrayList();
|
||||
List<String> enabledParts = new ArrayList();
|
||||
|
||||
for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (new Vector3(t).add(check).getTileEntity(t.getWorldObj()) instanceof TileBattery)
|
||||
{
|
||||
disabledParts.addAll(Arrays.asList(partToDisable[check.ordinal()]));
|
||||
|
||||
if (check == ForgeDirection.UP)
|
||||
{
|
||||
enabledParts.addAll(Arrays.asList(partToDisable[check.ordinal()]));
|
||||
enabledParts.add("coil1");
|
||||
}
|
||||
else if (check == ForgeDirection.DOWN)
|
||||
{
|
||||
List<String> connectionParts = new ArrayList<String>();
|
||||
|
||||
for (ForgeDirection sideCheck : ForgeDirection.VALID_DIRECTIONS)
|
||||
if (sideCheck.offsetY == 0)
|
||||
connectionParts.addAll(Arrays.asList(connectionPartToEnable[sideCheck.ordinal()]));
|
||||
|
||||
for (ForgeDirection sideCheck : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (sideCheck.offsetY == 0)
|
||||
{
|
||||
if (new Vector3(t).add(sideCheck).getTileEntity(t.getWorldObj()) instanceof TileBattery)
|
||||
{
|
||||
connectionParts.removeAll(Arrays.asList(connectionPartToEnable[sideCheck.ordinal()]));
|
||||
// connectionParts.addAll(Arrays.asList(connectionPartSideToEnable[sideCheck.ordinal()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enabledParts.addAll(connectionParts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render IO interface.
|
||||
*/
|
||||
if (check.offsetY == 0)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderUtility.rotateBlockBasedOnDirection(check);
|
||||
|
||||
//TODO: Fix this horrible patch.
|
||||
switch (check)
|
||||
{
|
||||
case NORTH:
|
||||
glRotatef(0, 0, 1, 0);
|
||||
break;
|
||||
case SOUTH:
|
||||
glRotatef(0, 0, 1, 0);
|
||||
break;
|
||||
case WEST:
|
||||
glRotatef(-180, 0, 1, 0);
|
||||
break;
|
||||
case EAST:
|
||||
glRotatef(180, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
|
||||
int io = tile.getIO(check);
|
||||
|
||||
if (io == 1)
|
||||
{
|
||||
MODEL.renderOnly("connectorIn");
|
||||
}
|
||||
else if (io == 2)
|
||||
{
|
||||
MODEL.renderOnly("connectorOut");
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
enabledParts.removeAll(disabledParts);
|
||||
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
if (i != 1 || enabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) < energyLevel)
|
||||
MODEL.renderOnly("coil" + i + "lit");
|
||||
else
|
||||
MODEL.renderOnly("coil" + i);
|
||||
}
|
||||
}
|
||||
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "connector", "connectorIn", "connectorOut" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }));
|
||||
|
||||
enabledParts.removeAll(Arrays.asList(new String[] { "coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8" }));
|
||||
MODEL.renderAllExcept(disabledParts.toArray(new String[0]));
|
||||
MODEL.renderOnly(enabledParts.toArray(new String[0]));
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package resonantinduction.electrical.battery
|
||||
|
||||
import java.util.{ArrayList, Arrays, List}
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.IItemRenderer
|
||||
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL11.{glPopMatrix, glPushMatrix, glRotatef}
|
||||
import resonant.content.prefab.scala.render.ISimpleItemRenderer
|
||||
import resonant.lib.render.RenderUtility
|
||||
import resonantinduction.core.Reference
|
||||
import universalelectricity.core.transform.vector.Vector3
|
||||
|
||||
/**
|
||||
* TODO: Make this more efficient.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
@SideOnly(Side.CLIENT) object RenderBattery
|
||||
{
|
||||
var INSTANCE: RenderBattery = new RenderBattery
|
||||
final val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "battery/battery.tcn"))
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) class RenderBattery extends TileEntitySpecialRenderer with ISimpleItemRenderer
|
||||
{
|
||||
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
|
||||
{
|
||||
glPushMatrix
|
||||
GL11.glTranslated(0, 0, 0)
|
||||
val energyLevel: Int = (((itemStack.getItem.asInstanceOf[ItemBlockBattery]).getEnergy(itemStack).asInstanceOf[Double] / (itemStack.getItem.asInstanceOf[ItemBlockBattery]).getEnergyCapacity(itemStack).asInstanceOf[Double]) * 8).asInstanceOf[Int]
|
||||
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
||||
val disabledParts: List[String] = new ArrayList[String]
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut"): _*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"): _*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"): _*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"): _*))
|
||||
RenderBattery.MODEL.renderAllExcept(disabledParts.toArray(new Array[String](0)): _*)
|
||||
|
||||
for (i <- 1 until 8)
|
||||
{
|
||||
if (i != 1 || !disabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) <= energyLevel) RenderBattery.MODEL.renderOnly("coil" + i + "lit")
|
||||
else RenderBattery.MODEL.renderOnly("coil" + i)
|
||||
}
|
||||
}
|
||||
glPopMatrix
|
||||
}
|
||||
|
||||
def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float)
|
||||
{
|
||||
val partToDisable: Array[Array[String]] = Array[Array[String]](Array[String]("bottom"), Array[String]("top"), Array[String]("frame1", "frame2"), Array[String]("frame3", "frame4"), Array[String]("frame4", "frame1"), Array[String]("frame2", "frame3"))
|
||||
val connectionPartToEnable: Array[Array[String]] = Array[Array[String]](null, null, Array[String]("frame1con", "frame2con"), Array[String]("frame3con", "frame4con"), Array[String]("frame4con", "frame1con"), Array[String]("frame2con", "frame3con"))
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
val tile: TileBattery = t.asInstanceOf[TileBattery]
|
||||
val energyLevel: Int = Math.round((tile.energy.getEnergy.asInstanceOf[Double] / TileBattery.getEnergyForTier(tile.getBlockMetadata).asInstanceOf[Double]) * 8).asInstanceOf[Int]
|
||||
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
||||
val disabledParts: List[String] = new ArrayList[String]
|
||||
val enabledParts: List[String] = new ArrayList[String]
|
||||
for (check <- ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (new Vector3(t).add(check).getTileEntity(t.getWorldObj).isInstanceOf[TileBattery])
|
||||
{
|
||||
disabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
||||
if (check eq ForgeDirection.UP)
|
||||
{
|
||||
enabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
||||
enabledParts.add("coil1")
|
||||
}
|
||||
else if (check eq ForgeDirection.DOWN)
|
||||
{
|
||||
val connectionParts: List[String] = new ArrayList[String]
|
||||
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS) if (sideCheck.offsetY == 0) connectionParts.addAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal): _*))
|
||||
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (sideCheck.offsetY == 0)
|
||||
{
|
||||
if (new Vector3(t).add(sideCheck).getTileEntity(t.getWorldObj).isInstanceOf[TileBattery])
|
||||
{
|
||||
connectionParts.removeAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal)))
|
||||
}
|
||||
}
|
||||
}
|
||||
enabledParts.addAll(connectionParts)
|
||||
}
|
||||
}
|
||||
if (check.offsetY == 0)
|
||||
{
|
||||
GL11.glPushMatrix
|
||||
RenderUtility.rotateBlockBasedOnDirection(check)
|
||||
|
||||
if (check == ForgeDirection.NORTH)
|
||||
{
|
||||
glRotatef(0, 0, 1, 0)
|
||||
}
|
||||
if (check == ForgeDirection.SOUTH)
|
||||
{
|
||||
glRotatef(0, 0, 1, 0)
|
||||
}
|
||||
else if (check == ForgeDirection.WEST)
|
||||
{
|
||||
glRotatef(-180, 0, 1, 0)
|
||||
}
|
||||
else if (check == ForgeDirection.EAST)
|
||||
{
|
||||
glRotatef(180, 0, 1, 0)
|
||||
}
|
||||
GL11.glRotatef(-90, 0, 1, 0)
|
||||
val io: Int = tile.getIO(check)
|
||||
if (io == 1)
|
||||
{
|
||||
RenderBattery.MODEL.renderOnly("connectorIn")
|
||||
}
|
||||
else if (io == 2)
|
||||
{
|
||||
RenderBattery.MODEL.renderOnly("connectorOut")
|
||||
}
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
}
|
||||
enabledParts.removeAll(disabledParts)
|
||||
|
||||
for (i <- 1 to 8)
|
||||
{
|
||||
if (i != 1 || enabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) < energyLevel) RenderBattery.MODEL.renderOnly("coil" + i + "lit")
|
||||
else RenderBattery.MODEL.renderOnly("coil" + i)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut") :_*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"):_*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"):_*))
|
||||
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"):_*))
|
||||
enabledParts.removeAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8")))
|
||||
RenderBattery.MODEL.renderAllExcept(disabledParts.toArray(new Array[String](0)) :_*)
|
||||
RenderBattery.MODEL.renderOnly(enabledParts.toArray(new Array[String](0)):_*)
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue