Just about finished rendering! :D

This commit is contained in:
Aidan C. Brady 2013-10-23 20:34:33 -04:00
parent 84f7bd1f85
commit ab8361f9e8
10 changed files with 132 additions and 44 deletions

View file

@ -7,33 +7,36 @@ package mekanism.api;
*/
public enum EnumColor
{
BLACK("\u00a70", "Black"),
DARK_BLUE("\u00a71", "Dark Blue"),
DARK_GREEN("\u00a72", "Dark Green"),
DARK_AQUA("\u00a73", "Dark Aqua"),
DARK_RED("\u00a74", "Dark Red"),
PURPLE("\u00a75", "Purple"),
ORANGE("\u00a76", "Orange"),
GREY("\u00a77", "Grey"),
DARK_GREY("\u00a78", "Dark Grey"),
INDIGO("\u00a79", "Indigo"),
BRIGHT_GREEN("\u00a7a", "Bright Green"),
AQUA("\u00a7b", "Aqua"),
RED("\u00a7c", "Red"),
PINK("\u00a7d", "Pink"),
YELLOW("\u00a7e", "Yellow"),
WHITE("\u00a7f", "White");
BLACK("\u00a70", "Black", new int[] {0, 0, 0}),
DARK_BLUE("\u00a71", "Dark Blue", new int[] {0, 0, 170}),
DARK_GREEN("\u00a72", "Dark Green", new int[] {0, 170, 0}),
DARK_AQUA("\u00a73", "Dark Aqua", new int[] {0, 170, 170}),
DARK_RED("\u00a74", "Dark Red", new int[] {170, 0, 0}),
PURPLE("\u00a75", "Purple", new int[] {170, 0, 170}),
ORANGE("\u00a76", "Orange", new int[] {255, 170, 0}),
GREY("\u00a77", "Grey", new int[] {170, 170, 170}),
DARK_GREY("\u00a78", "Dark Grey", new int[] {85, 85, 85}),
INDIGO("\u00a79", "Indigo", new int[] {85, 85, 255}),
BRIGHT_GREEN("\u00a7a", "Bright Green", new int[] {85, 255, 85}),
AQUA("\u00a7b", "Aqua", new int[] {85, 255, 255}),
RED("\u00a7c", "Red", new int[] {255, 85, 85}),
PINK("\u00a7d", "Pink", new int[] {255, 85, 255}),
YELLOW("\u00a7e", "Yellow", new int[] {255, 255, 85}),
WHITE("\u00a7f", "White", new int[] {255, 255, 255});
/** The color code that will be displayed */
public final String code;
public final int[] rgbCode;
/** A friendly name of the color. */
public String friendlyName;
private EnumColor(String s, String n)
private EnumColor(String s, String n, int[] rgb)
{
code = s;
friendlyName = n;
rgbCode = rgb;
}
public String getName()
@ -41,6 +44,11 @@ public enum EnumColor
return code + friendlyName;
}
public float getColor(int index)
{
return (float)rgbCode[index]/255F;
}
@Override
public String toString()
{

View file

@ -0,0 +1,37 @@
package mekanism.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelTransporterBox extends ModelBase
{
ModelRenderer box;
public ModelTransporterBox()
{
textureWidth = 64;
textureHeight = 64;
box = new ModelRenderer(this, 0, 0);
box.addBox(0F, 0F, 0F, 7, 7, 7);
box.setRotationPoint(-3.5F, 0, -3.5F);
box.setTextureSize(64, 64);
box.mirror = true;
setRotation(box, 0F, 0F, 0F);
}
public void render(float size)
{
box.render(size);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -3,6 +3,7 @@ package mekanism.client.render.tileentity;
import mekanism.api.Object3D;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.model.ModelTransmitter.Size;
import mekanism.client.model.ModelTransporterBox;
import mekanism.common.TransporterStack;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.util.MekanismUtils;
@ -24,6 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
{
private ModelTransmitter model = new ModelTransmitter(Size.LARGE);
private ModelTransporterBox modelBox = new ModelTransporterBox();
private EntityItem entityItem = new EntityItem(null);
private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
@ -42,6 +44,11 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
GL11.glScalef(1.0F, -1F, -1F);
GL11.glDisable(GL11.GL_CULL_FACE);
if(tileEntity.color != null)
{
GL11.glColor4f(tileEntity.color.getColor(0), tileEntity.color.getColor(1), tileEntity.color.getColor(2), 1.0F);
}
boolean[] connectable = TransporterUtils.getConnections(tileEntity);
model.renderCenter(connectable);
@ -77,6 +84,17 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
renderer.doRenderItem(entityItem, x + 0.5 + offset.xCoord*progress, y + 0.5 + offset.yCoord*progress - entityItem.yOffset - itemFix, z + 0.5 + offset.zCoord*progress, 0, 0);
GL11.glPopMatrix();
if(stack.color != null)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png"));
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F);
GL11.glTranslatef((float)(x + 0.5 + offset.xCoord*progress), (float)(y + 0.5 + offset.yCoord*progress - entityItem.yOffset - itemFix), (float)(z + 0.5 + offset.zCoord*progress));
modelBox.render(0.0625F);
GL11.glPopMatrix();
}
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.Object3D;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.util.TransporterUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -18,7 +19,7 @@ public class TransporterStack
public int progress;
public EnumColor color;
public EnumColor color = EnumColor.AQUA;
public boolean initiatedPath = false;
@ -37,7 +38,7 @@ public class TransporterStack
{
if(color != null)
{
data.add(color.ordinal());
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
@ -68,7 +69,7 @@ public class TransporterStack
if(c != -1)
{
color = EnumColor.values()[c];
color = TransporterUtils.colors.get(c);
}
else {
color = null;
@ -91,7 +92,7 @@ public class TransporterStack
{
if(color != null)
{
nbtTags.setInteger("color", color.ordinal());
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
nbtTags.setInteger("progress", progress);
@ -104,7 +105,7 @@ public class TransporterStack
{
if(nbtTags.hasKey("color"))
{
color = EnumColor.values()[nbtTags.getInteger("color")];
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
progress = nbtTags.getInteger("progress");

View file

@ -18,6 +18,7 @@ import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -71,7 +72,8 @@ public class ItemConfigurator extends ItemEnergized
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter)
{
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
MekanismUtils.incrementColor(transporter);
TransporterUtils.incrementColor(transporter);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(transporter), transporter.getNetworkedData(new ArrayList())), Object3D.get(transporter), 50D);
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Color bumped to: " + (transporter.color != null ? transporter.color.getName() : EnumColor.BLACK + "None")));
return true;
}

View file

@ -327,7 +327,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
if(c != -1)
{
color = EnumColor.values()[c];
color = TransporterUtils.colors.get(c);
}
else {
color = null;
@ -351,7 +351,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
{
if(color != null)
{
data.add(color.ordinal());
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
@ -374,7 +374,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
if(nbtTags.hasKey("color"))
{
color = EnumColor.values()[nbtTags.getInteger("color")];
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
if(nbtTags.hasKey("stacks"))
@ -395,7 +395,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
if(color != null)
{
nbtTags.setInteger("color", color.ordinal());
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
NBTTagList stacks = new NBTTagList();

View file

@ -1007,23 +1007,6 @@ public final class MekanismUtils
return false;
}
public static void incrementColor(TileEntityLogisticalTransporter tileEntity)
{
if(tileEntity.color == null)
{
tileEntity.color = EnumColor.values()[1];
return;
}
else if(tileEntity.color.ordinal() == EnumColor.values().length-1)
{
tileEntity.color = null;
return;
}
int ordinal = tileEntity.color.ordinal();
tileEntity.color = EnumColor.values()[ordinal+1];
}
public static enum ResourceType
{
GUI("gui"),

View file

@ -1,5 +1,6 @@
package mekanism.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import mekanism.api.EnumColor;
@ -15,6 +16,27 @@ import net.minecraftforge.common.ForgeDirection;
public final class TransporterUtils
{
public static ArrayList<EnumColor> colors = buildColors();
public static ArrayList<EnumColor> buildColors()
{
ArrayList<EnumColor> ret = new ArrayList<EnumColor>();
ret.add(EnumColor.DARK_BLUE);
ret.add(EnumColor.DARK_GREEN);
ret.add(EnumColor.DARK_AQUA);
ret.add(EnumColor.DARK_RED);
ret.add(EnumColor.PURPLE);
ret.add(EnumColor.INDIGO);
ret.add(EnumColor.BRIGHT_GREEN);
ret.add(EnumColor.AQUA);
ret.add(EnumColor.RED);
ret.add(EnumColor.PINK);
ret.add(EnumColor.YELLOW);
return ret;
}
/**
* Gets all the transporters around a tile entity.
* @param tileEntity - center tile entity
@ -327,4 +349,21 @@ public final class TransporterUtils
return null;
}
public static void incrementColor(TileEntityLogisticalTransporter tileEntity)
{
if(tileEntity.color == null)
{
tileEntity.color = colors.get(0);
return;
}
else if(colors.indexOf(tileEntity.color) == colors.size()-1)
{
tileEntity.color = null;
return;
}
int index = colors.indexOf(tileEntity.color);
tileEntity.color = colors.get(index+1);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB