Work on Alchemy Arrays and getting symbols to render in the TE

This commit is contained in:
Pahimar 2014-09-25 16:23:45 -04:00
parent 745098665c
commit 21368b49f5
14 changed files with 92 additions and 53 deletions

View file

@ -6,14 +6,19 @@ import net.minecraft.util.ResourceLocation;
public class Symbol
{
private final ResourceLocation texture;
private final float size;
private final int size;
public Symbol(String texture, float size)
public Symbol(String texture)
{
this(texture, 1);
}
public Symbol(String texture, int size)
{
this(ResourceLocationHelper.getResourceLocation(texture), size);
}
public Symbol(ResourceLocation texture, float size)
public Symbol(ResourceLocation texture, int size)
{
this.texture = texture;
this.size = size;
@ -24,8 +29,19 @@ public class Symbol
return texture;
}
public float getSize()
public int getSize()
{
return size;
}
@Override
public boolean equals(Object object)
{
if (object instanceof Symbol)
{
return this.texture.equals(((Symbol) object).getTexture()) && this.size == ((Symbol) object).size;
}
return false;
}
}

View file

@ -3,5 +3,18 @@ package com.pahimar.ee3.alchemy;
public class Symbols
{
private static final String SYMBOL_TEXTURE_LOCATION = "textures/array/";
public static final Symbol CIRCLE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transBaseCircle.png", 1f);
public static final Symbol BASE_CIRCLE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transBaseCircle.png");
public static final Symbol DOT = new Symbol(SYMBOL_TEXTURE_LOCATION + "transDot.png");
public static final Symbol LINE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transLine.png");
public static final Symbol CIRCLE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transCircle.png");
public static final Symbol TRIANGLE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transTriangle.png");
public static final Symbol INVERTED_TRIANGLE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transInvertedTriangle.png");
public static final Symbol SQUARE = new Symbol(SYMBOL_TEXTURE_LOCATION + "transSquare.png");
public static final Symbol DIAMOND = new Symbol(SYMBOL_TEXTURE_LOCATION + "transDiamond.png");
public static final Symbol PENTAGON = new Symbol(SYMBOL_TEXTURE_LOCATION + "transPentagon.png");
public static final Symbol HEXAGON = new Symbol(SYMBOL_TEXTURE_LOCATION + "transHexagon.png");
public static final Symbol HEPTGON = new Symbol(SYMBOL_TEXTURE_LOCATION + "transHeptagon.png");
public static final Symbol OCTAGON = new Symbol(SYMBOL_TEXTURE_LOCATION + "transOctagon.png");
}

View file

@ -6,6 +6,8 @@ import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
@ -46,4 +48,15 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
{
return new TileEntityAlchemyArray();
}
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
{
if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
}
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
}
}

View file

@ -4,11 +4,10 @@ import com.pahimar.ee3.alchemy.Symbol;
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@SideOnly(Side.CLIENT)
public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer
@ -19,52 +18,35 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer
if (tileEntity instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) tileEntity;
ForgeDirection direction = null;
if (tileEntityAlchemyArray.getWorldObj() != null)
{
direction = tileEntityAlchemyArray.getOrientation();
}
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
short angle = 0;
if (direction != null)
{
if (direction == ForgeDirection.NORTH)
{
angle = 180;
}
else if (direction == ForgeDirection.SOUTH)
{
angle = 0;
}
else if (direction == ForgeDirection.WEST)
{
angle = 90;
}
else if (direction == ForgeDirection.EAST)
{
angle = -90;
}
}
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
for (Symbol symbol : tileEntityAlchemyArray.getAlchemySymbols())
for (Symbol symbol : tileEntityAlchemyArray.getSymbols())
{
this.bindTexture(symbol.getTexture());
renderSymbol(symbol, x, y, z);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
}
}
private void renderSymbol(Symbol symbol, double x, double y, double z)
{
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glTranslatef(0.5f - (symbol.getSize() / 2f), 0f, 0.5f - (symbol.getSize() / 2f));
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x + symbol.getSize(), y + 0.001d, z + symbol.getSize(), 0, 0);
tessellator.addVertexWithUV(x + symbol.getSize(), y + 0.001d, z, 0, 1);
tessellator.addVertexWithUV(x, y + 0.001d, z, 1, 1);
tessellator.addVertexWithUV(x, y + 0.001d, z + symbol.getSize(), 1, 0);
tessellator.draw();
GL11.glPopMatrix();
}
}

View file

@ -1,24 +1,39 @@
package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.alchemy.Symbol;
import com.pahimar.ee3.alchemy.Symbols;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.AxisAlignedBB;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TileEntityAlchemyArray extends TileEntityEE
{
private List<Symbol> alchemySymbols;
private List<Symbol> symbols;
private int largestSymbolSize;
public TileEntityAlchemyArray()
{
super();
alchemySymbols = new ArrayList<Symbol>(Arrays.asList(Symbols.CIRCLE));
symbols = new ArrayList<Symbol>();
this.largestSymbolSize = 0;
}
public List<Symbol> getAlchemySymbols()
public List<Symbol> getSymbols()
{
return alchemySymbols;
return symbols;
}
public int getLargestSymbolSize()
{
return largestSymbolSize;
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return AxisAlignedBB.getBoundingBox(xCoord - largestSymbolSize, yCoord, zCoord - largestSymbolSize, xCoord + largestSymbolSize, yCoord, zCoord + largestSymbolSize);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB