Work on Logistical Transporter

This commit is contained in:
Aidan Brady 2013-08-05 23:58:44 -04:00
parent 96b192efef
commit fe9cd85564
7 changed files with 165 additions and 4 deletions

View file

@ -31,6 +31,7 @@ import mekanism.common.TileEntityEnergyCube;
import mekanism.common.TileEntityEnrichmentChamber;
import mekanism.common.TileEntityFactory;
import mekanism.common.TileEntityGasTank;
import mekanism.common.TileEntityLogisticalTransporter;
import mekanism.common.TileEntityMechanicalPipe;
import mekanism.common.TileEntityMetallurgicInfuser;
import mekanism.common.TileEntityOsmiumCompressor;
@ -187,6 +188,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank", new RenderDynamicTank());
ClientRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve", new RenderDynamicTank());
ClientRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad", new RenderChargepad());
ClientRegistry.registerTileEntity(TileEntityLogisticalTransporter.class, "LogisticalTransporter", new RenderLogisticalTransporter());
}
@Override

View file

@ -1,6 +1,44 @@
package mekanism.client;
public class RenderLogisticalTransporter
{
import mekanism.common.MekanismUtils;
import mekanism.common.MekanismUtils.ResourceType;
import mekanism.common.TileEntityLogisticalTransporter;
import mekanism.common.TransporterUtils;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
{
private ModelTransmitter model = new ModelTransmitter();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntityLogisticalTransporter)tileEntity, x, y, z, partialTick);
}
@SuppressWarnings("incomplete-switch")
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
{
func_110628_a(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
boolean[] connectable = TransporterUtils.getConnections(tileEntity);
model.renderCenter(connectable);
for(int i = 0; i < 6; i++)
{
model.renderSide(ForgeDirection.getOrientation(i), connectable[i]);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
}
}

View file

@ -39,6 +39,9 @@ public class TransmitterRenderer implements ISimpleBlockRenderingHandler
case 2:
Minecraft.getMinecraft().renderEngine.func_110577_a(MekanismUtils.getResource(ResourceType.RENDER, "MechanicalPipe.png"));
break;
case 3:
Minecraft.getMinecraft().renderEngine.func_110577_a(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
break;
}
transmitter.renderSide(ForgeDirection.UP, true);

View file

@ -198,6 +198,10 @@ public class BlockTransmitter extends Block
{
connectable = PipeUtils.getConnections(tileEntity);
}
else if(world.getBlockMetadata(x, y, z) == 3)
{
connectable = TransporterUtils.getConnections(tileEntity);
}
}
return connectable;
@ -387,5 +391,4 @@ public class BlockTransmitter extends Block
return itemStack;
}
}

View file

@ -0,0 +1,6 @@
package mekanism.common;
public interface ILogisticalTransporter
{
}

View file

@ -2,7 +2,7 @@ package mekanism.common;
import net.minecraft.tileentity.TileEntity;
public class TileEntityLogisticalTransporter extends TileEntity
public class TileEntityLogisticalTransporter extends TileEntity implements ILogisticalTransporter
{
}

View file

@ -0,0 +1,109 @@
package mekanism.common;
import java.util.Arrays;
import mekanism.api.Object3D;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public final class TransporterUtils
{
/**
* Gets all the transporters around a tile entity.
* @param tileEntity - center tile entity
* @return array of TileEntities
*/
public static TileEntity[] getConnectedTransporters(TileEntity tileEntity)
{
TileEntity[] transporters = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity transporter = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(transporter instanceof ILogisticalTransporter)
{
transporters[orientation.ordinal()] = transporter;
}
}
return transporters;
}
/**
* Gets all the adjacent connections to a TileEntity.
* @param tileEntity - center TileEntity
* @return boolean[] of adjacent connections
*/
public static boolean[] getConnections(TileEntity tileEntity)
{
boolean[] connectable = new boolean[] {false, false, false, false, false, false};
TileEntity[] connectedTransporters = getConnectedTransporters(tileEntity);
IInventory[] connectedInventories = getConnectedInventories(tileEntity);
for(IInventory inventory : connectedInventories)
{
if(inventory != null)
{
int side = Arrays.asList(connectedInventories).indexOf(inventory);
ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite();
if(inventory.getSizeInventory() > 0)
{
if(inventory instanceof ISidedInventory)
{
ISidedInventory sidedInventory = (ISidedInventory)inventory;
if(sidedInventory.getAccessibleSlotsFromSide(forgeSide.ordinal()) != null)
{
if(sidedInventory.getAccessibleSlotsFromSide(forgeSide.ordinal()).length > 0)
{
connectable[side] = true;
}
}
}
else {
connectable[side] = true;
}
}
}
}
for(TileEntity tile : connectedTransporters)
{
if(tile != null)
{
int side = Arrays.asList(connectedTransporters).indexOf(tile);
connectable[side] = true;
}
}
return connectable;
}
/**
* Gets all the inventories around a tile entity.
* @param tileEntity - center tile entity
* @return array of IInventories
*/
public static IInventory[] getConnectedInventories(TileEntity tileEntity)
{
IInventory[] inventories = new IInventory[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity inventory = Object3D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(inventory instanceof IInventory && !(inventory instanceof ILogisticalTransporter))
{
inventories[orientation.ordinal()] = (IInventory)inventory;
}
}
return inventories;
}
}