Work on transporters

This commit is contained in:
Aidan Brady 2013-12-20 17:46:24 -05:00
parent 40e2d3b7fc
commit f2d202d90f
16 changed files with 207 additions and 114 deletions

View file

@ -5,19 +5,10 @@ import net.minecraft.tileentity.TileEntity;
public enum TransmissionType
{
ENERGY(Size.SMALL),
FLUID(Size.LARGE),
GAS(Size.SMALL),
ITEM(Size.LARGE);
public Size transmitterSize;
private TransmissionType(Size size)
{
transmitterSize = size;
}
public static TransmissionType[] metaArray = {GAS, ENERGY, FLUID, ITEM};
ENERGY,
FLUID,
GAS,
ITEM;
public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type)
{
@ -49,32 +40,4 @@ public enum TransmissionType
return false;
}
public static TransmissionType fromOldMeta(int meta)
{
if(meta < metaArray.length)
{
return metaArray[meta];
}
if(meta == 4 || meta == 5)
{
return ITEM;
}
return null;
}
public static enum Size
{
SMALL(6),
LARGE(8);
public int centreSize;
private Size(int size) {
centreSize = size;
}
}
}

View file

@ -5,11 +5,12 @@ import net.minecraft.util.Icon;
public class PartTransmitterIcons
{
private Icon sideIcon;
private Icon[] sideIcons;
private Icon[] centerIcons;
public PartTransmitterIcons(int numCentres)
public PartTransmitterIcons(int numCentres, int numSides)
{
sideIcons = new Icon[numSides];
centerIcons = new Icon[numCentres];
}
@ -21,14 +22,17 @@ public class PartTransmitterIcons
}
}
public void registerSideIcon(IconRegister register, String filename)
public void registerSideIcons(IconRegister register, String[] filenames)
{
sideIcon = register.registerIcon("mekanism:models/" + filename);
for(int i = 0; i < sideIcons.length; i++)
{
sideIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]);
}
}
public Icon getSideIcon()
public Icon getSideIcon(int n)
{
return sideIcon;
return sideIcons[n];
}
public Icon getCenterIcon(int n)

View file

@ -2,8 +2,6 @@ package mekanism.client.render.item;
import mekanism.api.EnumColor;
import mekanism.api.energy.IEnergizedItem;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.transmitters.TransmissionType.Size;
import mekanism.client.ClientProxy;
import mekanism.client.MekanismClient;
import mekanism.client.model.ModelEnergyCube;
@ -33,6 +31,9 @@ import mekanism.common.item.ItemRobit;
import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.multipart.TransmitterType;
import mekanism.common.multipart.TransmitterType.Size;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
@ -44,6 +45,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@ -72,7 +74,7 @@ public class ItemRenderingHandler implements IItemRenderer
public ModelScubaTank scubaTank = new ModelScubaTank();
public RenderBalloon balloonRenderer = new RenderBalloon();
public RenderBin binRenderer = new RenderBin();
public RenderBin binRenderer = (RenderBin)TileEntityRenderer.instance.specialRendererMap.get(TileEntityBin.class);
private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
@Override
@ -378,9 +380,15 @@ public class ItemRenderingHandler implements IItemRenderer
case 3:
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
break;
case 4:
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RestrictiveTransporter.png"));
break;
case 5:
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DiversionTransporter.png"));
break;
}
if(TransmissionType.values()[item.getItemDamage()].transmitterSize == Size.SMALL)
if(TransmitterType.values()[item.getItemDamage()].getSize() == Size.SMALL)
{
transmitterSmall.renderSide(ForgeDirection.UP, true);
transmitterSmall.renderSide(ForgeDirection.DOWN, true);

View file

@ -3,8 +3,8 @@ package mekanism.common.multipart;
import java.util.ArrayList;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.ITransmitterNetwork;
import mekanism.api.transmitters.TransmissionType;
@ -69,7 +69,7 @@ public class ItemPartTransmitter extends JItemMultiPart
}
}
return PartTransmitter.getPartType(TransmissionType.values()[getDamage(stack)]);
return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]);
}
@Override
@ -107,7 +107,9 @@ public class ItemPartTransmitter extends JItemMultiPart
list.add("- " + EnumColor.PURPLE + "O " + EnumColor.GREY + "(Oxygen)");
list.add("- " + EnumColor.PURPLE + "H " + EnumColor.GREY + "(Hydrogen)");
}
case 3:
}
if(itemstack.getItemDamage() >= 3 && itemstack.getItemDamage() <= 5)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
@ -115,12 +117,11 @@ public class ItemPartTransmitter extends JItemMultiPart
}
}
}
}
@Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
{
for(TransmissionType type : TransmissionType.values())
for(TransmitterType type : TransmitterType.values())
{
listToAddTo.add(new ItemStack(itemID, 1, type.ordinal()));
}
@ -136,6 +137,6 @@ public class ItemPartTransmitter extends JItemMultiPart
@Override
public String getUnlocalizedName(ItemStack stack)
{
return getUnlocalizedName() + "." + TransmissionType.values()[stack.getItemDamage()].name().toLowerCase();
return getUnlocalizedName() + "." + TransmitterType.values()[stack.getItemDamage()].getName();
}
}

View file

@ -75,7 +75,7 @@ public class MultipartMekanism implements IPartFactory, IPartConverter
if(world.getBlockId(pos.x, pos.y, pos.z) == Mekanism.transmitterID)
{
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
return PartTransmitter.getPartType(TransmissionType.fromOldMeta(meta), meta);
return PartTransmitter.getPartType(TransmitterType.fromOldMeta(meta));
}
return null;

View file

@ -1,6 +1,24 @@
package mekanism.common.multipart;
import net.minecraft.util.Icon;
public class PartDiversionTransporter extends PartLogisticalTransporter
{
@Override
public String getType()
{
return "mekanism:diversion_transporter";
}
@Override
public TransmitterType getTransmitter()
{
return TransmitterType.DIVERSION_TRANSPORTER;
}
@Override
public Icon getCenterIcon()
{
return transporterIcons.getCenterIcon(2);
}
}

View file

@ -1,8 +1,5 @@
package mekanism.common.multipart;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
import mekanism.client.render.RenderPartTransmitter;
@ -11,6 +8,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraftforge.common.ForgeDirection;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartLogisticalTransporter extends PartSidedPipe
{
@ -23,16 +23,16 @@ public class PartLogisticalTransporter extends PartSidedPipe
}
@Override
public TransmissionType getTransmissionType()
public TransmitterType getTransmitter()
{
return TransmissionType.ITEM;
return TransmitterType.LOGISTICAL_TRANSPORTER;
}
public static void registerIcons(IconRegister register)
{
transporterIcons = new PartTransmitterIcons(1);
transporterIcons.registerCenterIcons(register, new String[] {"LogisticalTransporter", "RestrictionTransporter", "DiversionTransporter"});
transporterIcons.registerSideIcon(register, "LogisticalTransporterSide");
transporterIcons = new PartTransmitterIcons(3, 2);
transporterIcons.registerCenterIcons(register, new String[] {"LogisticalTransporter", "RestrictiveTransporter", "DiversionTransporter"});
transporterIcons.registerSideIcons(register, new String[] {"LogisticalTransporterSide", "RestrictiveTransporterSide"});
}
@Override
@ -51,7 +51,7 @@ public class PartLogisticalTransporter extends PartSidedPipe
@Override
public Icon getSideIcon()
{
return transporterIcons.getSideIcon();
return transporterIcons.getSideIcon(0);
}
@Override

View file

@ -150,9 +150,9 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
public static void registerIcons(IconRegister register)
{
pipeIcons = new PartTransmitterIcons(2);
pipeIcons = new PartTransmitterIcons(2, 1);
pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"});
pipeIcons.registerSideIcon(register, "MechanicalPipeSide");
pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeSide"});
}
@Override
@ -164,7 +164,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
@Override
public Icon getSideIcon()
{
return pipeIcons.getSideIcon();
return pipeIcons.getSideIcon(0);
}
@Override
@ -173,6 +173,12 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
return TransmissionType.FLUID;
}
@Override
public TransmitterType getTransmitter()
{
return TransmitterType.MECHANICAL_PIPE;
}
@Override
public boolean isValidAcceptor(TileEntity tile, ForgeDirection side)
{

View file

@ -59,6 +59,12 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
super.update();
}
@Override
public TransmitterType getTransmitter()
{
return TransmitterType.PRESSURIZED_TUBE;
}
@Override
public void preSingleMerge(GasNetwork network)
{
@ -132,9 +138,9 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
public static void registerIcons(IconRegister register)
{
tubeIcons = new PartTransmitterIcons(1);
tubeIcons = new PartTransmitterIcons(1, 1);
tubeIcons.registerCenterIcons(register, new String[] {"PressurizedTube"});
tubeIcons.registerSideIcon(register, "TransmitterSideSmall");
tubeIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"});
}
@Override
@ -146,7 +152,7 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
@Override
public Icon getSideIcon()
{
return tubeIcons.getSideIcon();
return tubeIcons.getSideIcon(0);
}
@Override

View file

@ -0,0 +1,30 @@
package mekanism.common.multipart;
import net.minecraft.util.Icon;
public class PartRestrictiveTransporter extends PartLogisticalTransporter
{
@Override
public String getType()
{
return "mekanism:restrictive_transporter";
}
@Override
public TransmitterType getTransmitter()
{
return TransmitterType.RESTRICTIVE_TRANSPORTER;
}
@Override
public Icon getCenterIcon()
{
return transporterIcons.getCenterIcon(1);
}
@Override
public Icon getSideIcon()
{
return transporterIcons.getSideIcon(1);
}
}

View file

@ -15,6 +15,7 @@ import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.multipart.TransmitterType.Size;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -86,28 +87,22 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
largeSides[6] = new IndexedCuboid6(6, new Cuboid6(0.25, 0.25, 0.25, 0.75, 0.75, 0.75));
}
public static TMultiPart getPartType(TransmissionType type, int sub)
public static TMultiPart getPartType(TransmitterType type)
{
switch(type)
{
case ENERGY:
case UNIVERSAL_CABLE:
return new PartUniversalCable();
case FLUID:
case MECHANICAL_PIPE:
return new PartMechanicalPipe();
case GAS:
case PRESSURIZED_TUBE:
return new PartPressurizedTube();
case ITEM:
{
switch(sub)
{
case 3:
case LOGISTICAL_TRANSPORTER:
return new PartLogisticalTransporter();
case 4:
return new PartLogisticalTransporter();
case 5:
case RESTRICTIVE_TRANSPORTER:
return new PartRestrictiveTransporter();
case DIVERSION_TRANSPORTER:
return new PartDiversionTransporter();
}
}
default:
return null;
}
@ -119,13 +114,6 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
return (connections & tester) > 0;
}
public abstract TransmissionType getTransmissionType();
public TransmissionType.Size getTransmitterSize()
{
return getTransmissionType().transmitterSize;
}
public abstract Icon getCenterIcon();
public abstract Icon getSideIcon();
@ -158,7 +146,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
{
TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world());
if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType()) && isConnectable(tileEntity))
if(TransmissionType.checkTransmissionType(tileEntity, getTransmitter().getType()) && isConnectable(tileEntity))
{
connections |= 1 << side.ordinal();
}
@ -223,16 +211,18 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
if(connectionMapContainsSide(connections, side) || side == testingSide)
{
subParts.add(getTransmissionType().transmitterSize == TransmissionType.Size.SMALL ? smallSides[ord] : largeSides[ord]);
subParts.add(getTransmitter().getSize() == Size.SMALL ? smallSides[ord] : largeSides[ord]);
}
}
}
subParts.add(getTransmissionType().transmitterSize == TransmissionType.Size.SMALL ? smallSides[6] : largeSides[6]);
subParts.add(getTransmitter().getSize() == Size.SMALL ? smallSides[6] : largeSides[6]);
return subParts;
}
public abstract TransmitterType getTransmitter();
@Override
public Iterable<Cuboid6> getCollisionBoxes()
{
@ -275,7 +265,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
@Override
public int getHollowSize()
{
return getTransmissionType().transmitterSize == TransmissionType.Size.SMALL ? 7 : 8;
return getTransmitter().getSize() == Size.SMALL ? 7 : 9;
}
@Override
@ -400,7 +390,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
@Override
public ItemStack pickItem(MovingObjectPosition hit)
{
return new ItemStack(Mekanism.PartTransmitter, 1, getTransmissionType().ordinal());
return new ItemStack(Mekanism.PartTransmitter, 1, getTransmitter().ordinal());
}
@Override
@ -458,7 +448,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
return RenderPartTransmitter.contents_models.get(name);
}
else {
if(getTransmitterSize() == TransmissionType.Size.LARGE)
if(getTransmitter().getSize() == Size.LARGE)
{
return RenderPartTransmitter.large_models.get(name);
}

View file

@ -61,6 +61,12 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
super.update();
}
@Override
public TransmitterType getTransmitter()
{
return TransmitterType.UNIVERSAL_CABLE;
}
@Override
public void load(NBTTagCompound nbtTags)
{
@ -88,9 +94,9 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
public static void registerIcons(IconRegister register)
{
cableIcons = new PartTransmitterIcons(1);
cableIcons = new PartTransmitterIcons(1, 1);
cableIcons.registerCenterIcons(register, new String[] {"UniversalCable"});
cableIcons.registerSideIcon(register, "TransmitterSideSmall");
cableIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"});
}
@Override
@ -109,7 +115,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
@Override
public Icon getSideIcon()
{
return cableIcons.getSideIcon();
return cableIcons.getSideIcon(0);
}
@Override

View file

@ -0,0 +1,59 @@
package mekanism.common.multipart;
import mekanism.api.transmitters.TransmissionType;
public enum TransmitterType
{
UNIVERSAL_CABLE("UniversalCable", TransmissionType.ENERGY),
MECHANICAL_PIPE("MechanicalPipe", TransmissionType.FLUID),
PRESSURIZED_TUBE("PressurizedTube", TransmissionType.GAS),
LOGISTICAL_TRANSPORTER("LogisticalTransporter", TransmissionType.ITEM),
RESTRICTIVE_TRANSPORTER("RestrictiveTransporter", TransmissionType.ITEM),
DIVERSION_TRANSPORTER("DiversionTransporter", TransmissionType.ITEM);
private String unlocalizedName;
private Size size;
private TransmissionType transmissionType;
public static TransmitterType[] oldMetaArray = {PRESSURIZED_TUBE, UNIVERSAL_CABLE, MECHANICAL_PIPE, LOGISTICAL_TRANSPORTER, RESTRICTIVE_TRANSPORTER, DIVERSION_TRANSPORTER};
private TransmitterType(String name, TransmissionType type)
{
unlocalizedName = name;
transmissionType = type;
}
public String getName()
{
return unlocalizedName;
}
public Size getSize()
{
return size;
}
public TransmissionType getType()
{
return transmissionType;
}
public static enum Size
{
SMALL(6),
LARGE(8);
public int centreSize;
private Size(int size)
{
centreSize = size;
}
}
public static TransmitterType fromOldMeta(int meta)
{
return oldMetaArray[meta];
}
}

View file

@ -82,10 +82,12 @@ tile.Transmitter.LogisticalTransporter.name=Logistical Transporter
tile.Transmitter.RestrictiveTransporter.name=Restrictive Transporter
tile.Transmitter.DiversionTransporter.name=Diversion Transporter
item.MultipartTransmitter.gas.name=Pressurized Tube
item.MultipartTransmitter.energy.name=Universal Cable
item.MultipartTransmitter.fluid.name=Mechanical Pipe
item.MultipartTransmitter.item.name=Logistical Transporter
item.MultipartTransmitter.PressurizedTube.name=Pressurized Tube
item.MultipartTransmitter.UniversalCable.name=Universal Cable
item.MultipartTransmitter.MechanicalPipe.name=Mechanical Pipe
item.MultipartTransmitter.LogisticalTransporter.name=Logistical Transporter
item.MultipartTransmitter.RestrictiveTransporter.name=Restrictive Transporter
item.MultipartTransmitter.DiversionTransporter.name=Diversion Transporter
//Energy Cubes
tile.EnergyCube.Basic.name=Basic Energy Cube