Machines: Getting them to render in world. Still not functional.

This commit is contained in:
pahimar 2014-04-11 16:01:11 -04:00
parent ac14fe32ab
commit 664387f063
25 changed files with 1250 additions and 11 deletions

View file

@ -33,7 +33,7 @@ public class BlockAlchemicalChest extends BlockEE implements ITileEntityProvider
}
@Override
public TileEntity createNewTileEntity(World var1, int metaData)
public TileEntity createNewTileEntity(World world, int metaData)
{
if (metaData == 0)
{

View file

@ -19,7 +19,7 @@ public class BlockAludel extends BlockEE implements ITileEntityProvider
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileAludel();
}

View file

@ -26,7 +26,7 @@ public class BlockCalcinator extends BlockEE implements ITileEntityProvider
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileCalcinator();
}

View file

@ -18,7 +18,7 @@ public class BlockGlassBell extends BlockEE implements ITileEntityProvider
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileGlassBell();
}

View file

@ -0,0 +1,43 @@
package com.pahimar.ee3.block;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.RenderIds;
import com.pahimar.ee3.tileentity.TileResearchStation;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockResearchStation extends BlockEE implements ITileEntityProvider
{
public BlockResearchStation()
{
super(Material.rock);
this.setHardness(2.0f);
this.setBlockName(Names.Blocks.RESEARCH_STATION);
}
@Override
public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileResearchStation();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType()
{
return RenderIds.researchStation;
}
}

View file

@ -12,7 +12,10 @@ public class ModBlocks
public static final BlockEE infusedWood = new BlockInfusedWood();
public static final BlockEE infusedPlank = new BlockInfusedPlank();
public static final BlockEE alchemicalChest = new BlockAlchemicalChest();
public static final BlockEE aludel = new BlockAludel();
public static final BlockEE calcinator = new BlockCalcinator();
public static final BlockEE glassBell = new BlockGlassBell();
public static final BlockEE researchStation = new BlockResearchStation();
public static void init()
{
@ -22,5 +25,9 @@ public class ModBlocks
GameRegistry.registerBlock(infusedWood, ItemBlockInfusedWood.class, "tile." + Names.Blocks.INFUSED_WOOD);
GameRegistry.registerBlock(infusedPlank, ItemBlockInfusedPlank.class, "tile." + Names.Blocks.INFUSED_PLANK);
GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, "tile." + Names.Blocks.ALCHEMICAL_CHEST);
GameRegistry.registerBlock(aludel, "tile." + Names.Blocks.ALUDEL);
GameRegistry.registerBlock(calcinator, "tile." + Names.Blocks.CALCINATOR);
GameRegistry.registerBlock(glassBell, "tile." + Names.Blocks.GLASS_BELL);
GameRegistry.registerBlock(researchStation, "tile." + Names.Blocks.RESEARCH_STATION);
}
}

View file

@ -2,11 +2,14 @@ package com.pahimar.ee3.client.renderer.item;
import com.pahimar.ee3.reference.Textures;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelChest;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ItemAlchemicalChestRenderer implements IItemRenderer
{
private final ModelChest modelChest;

View file

@ -0,0 +1,82 @@
package com.pahimar.ee3.client.renderer.item;
import com.pahimar.ee3.client.renderer.model.ModelAludel;
import com.pahimar.ee3.reference.Textures;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ItemAludelRenderer implements IItemRenderer
{
private final ModelAludel modelAludel;
public ItemAludelRenderer()
{
modelAludel = new ModelAludel();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
switch (type)
{
case ENTITY:
{
renderAludel(-0.5F, -0.38F, 0.5F);
return;
}
case EQUIPPED:
{
renderAludel(0.0F, 0.0F, 1.0F);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderAludel(0.0F, 0.0F, 1.0F);
return;
}
case INVENTORY:
{
renderAludel(-1.0F, -0.9F, 0.0F);
return;
}
default:
}
}
private void renderAludel(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1F, 1F, 1F);
GL11.glTranslatef(x, y, z);
GL11.glRotatef(-90F, 1F, 0, 0);
// Bind texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALUDEL);
// Render
modelAludel.render();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,84 @@
package com.pahimar.ee3.client.renderer.item;
import com.pahimar.ee3.client.renderer.model.ModelCalcinator;
import com.pahimar.ee3.reference.Textures;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ItemCalcinatorRenderer implements IItemRenderer
{
private final ModelCalcinator modelCalcinator;
public ItemCalcinatorRenderer()
{
modelCalcinator = new ModelCalcinator();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
switch (type)
{
case ENTITY:
{
renderCalcinator(-0.5F, 0.0F, 0.5F);
return;
}
case EQUIPPED:
{
renderCalcinator(0.0F, 0.0F, 1.0F);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderCalcinator(0.0F, 0.0F, 1.0F);
return;
}
case INVENTORY:
{
renderCalcinator(0.0F, -0.1F, 1.0F);
return;
}
default:
{
}
}
}
private void renderCalcinator(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1F, 1F, 1F);
GL11.glTranslatef(x, y, z);
GL11.glRotatef(-90F, 1F, 0, 0);
// Bind texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
// Render
modelCalcinator.renderPart("Calcinator");
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,84 @@
package com.pahimar.ee3.client.renderer.item;
import com.pahimar.ee3.client.renderer.model.ModelGlassBell;
import com.pahimar.ee3.reference.Textures;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ItemGlassBellRenderer implements IItemRenderer
{
private final ModelGlassBell modelGlassBell;
public ItemGlassBellRenderer()
{
modelGlassBell = new ModelGlassBell();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
switch (type)
{
case ENTITY:
{
renderGlassBell(-0.5F, -1.2F, 0.5F);
return;
}
case EQUIPPED:
{
renderGlassBell(-0.2F, -0.85F, 0.8F);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderGlassBell(-0.2F, -0.85F, 0.8F);
return;
}
case INVENTORY:
{
renderGlassBell(-1.0F, -1.675F, 0.0F);
return;
}
default:
{
}
}
}
private void renderGlassBell(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1.4F, 1.4F, 1.4F);
GL11.glTranslatef(x, y, z);
GL11.glRotatef(-90F, 1F, 0, 0);
// Bind texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_GLASS_BELL);
// Render
modelGlassBell.render();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,83 @@
package com.pahimar.ee3.client.renderer.item;
import com.pahimar.ee3.client.renderer.model.ModelResearchStation;
import com.pahimar.ee3.reference.Textures;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class ItemResearchStationRenderer implements IItemRenderer
{
private final ModelResearchStation modelResearchStation;
public ItemResearchStationRenderer()
{
modelResearchStation = new ModelResearchStation();
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
switch (type)
{
case ENTITY:
{
renderCalcinator(-0.5F, 0.0F, 0.5F);
return;
}
case EQUIPPED:
{
renderCalcinator(0.0F, 0.0F, 1.0F);
return;
}
case EQUIPPED_FIRST_PERSON:
{
renderCalcinator(0.0F, 0.0F, 1.0F);
return;
}
case INVENTORY:
{
renderCalcinator(0.0F, -0.1F, 1.0F);
return;
}
default:
{
}
}
}
private void renderCalcinator(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef(x, y, z);
// Bind texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_RESEARCH_STATION);
// Render
modelResearchStation.render();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,23 @@
package com.pahimar.ee3.client.renderer.model;
import com.pahimar.ee3.reference.Models;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@SideOnly(Side.CLIENT)
public class ModelAludel
{
private IModelCustom modelAludel;
public ModelAludel()
{
modelAludel = AdvancedModelLoader.loadModel(Models.ALUDEL);
}
public void render()
{
modelAludel.renderPart("Base");
}
}

View file

@ -0,0 +1,28 @@
package com.pahimar.ee3.client.renderer.model;
import com.pahimar.ee3.reference.Models;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@SideOnly(Side.CLIENT)
public class ModelCalcinator
{
private IModelCustom modelCalcinator;
public ModelCalcinator()
{
modelCalcinator = AdvancedModelLoader.loadModel(Models.CALCINATOR);
}
public void render()
{
modelCalcinator.renderAll();
}
public void renderPart(String partName)
{
modelCalcinator.renderPart(partName);
}
}

View file

@ -0,0 +1,23 @@
package com.pahimar.ee3.client.renderer.model;
import com.pahimar.ee3.reference.Models;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@SideOnly(Side.CLIENT)
public class ModelGlassBell
{
private IModelCustom modelGlassBell;
public ModelGlassBell()
{
modelGlassBell = AdvancedModelLoader.loadModel(Models.GLASS_BELL);
}
public void render()
{
modelGlassBell.renderPart("Bell");
}
}

View file

@ -0,0 +1,23 @@
package com.pahimar.ee3.client.renderer.model;
import com.pahimar.ee3.reference.Models;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
@SideOnly(Side.CLIENT)
public class ModelResearchStation
{
private IModelCustom modelResearchStation;
public ModelResearchStation()
{
modelResearchStation = AdvancedModelLoader.loadModel(Models.RESEARCH_STATION);
}
public void render()
{
modelResearchStation.renderAll();
}
}

View file

@ -0,0 +1,182 @@
package com.pahimar.ee3.client.renderer.tileentity;
import com.pahimar.ee3.client.renderer.model.ModelAludel;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileAludel;
import com.pahimar.ee3.tileentity.TileGlassBell;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class TileEntityAludelRenderer extends TileEntitySpecialRenderer
{
private final ModelAludel modelAludel = new ModelAludel();
private final RenderItem customRenderItem;
public TileEntityAludelRenderer()
{
customRenderItem = new RenderItem()
{
@Override
public boolean shouldBob()
{
return false;
}
};
customRenderItem.setRenderManager(RenderManager.instance);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
if (tileEntity instanceof TileAludel)
{
TileAludel tileAludel = (TileAludel) tileEntity;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
scaleTranslateRotate(x, y, z, tileAludel.getOrientation());
// Bind texture
this.bindTexture(Textures.MODEL_ALUDEL);
// Render
modelAludel.render();
GL11.glPopMatrix();
/**
* Render the ghost item inside of the Aludel, slowly spinning
*/
GL11.glPushMatrix();
TileEntity tileGlassBell = tileAludel.getWorldObj().getTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
if (tileGlassBell instanceof TileGlassBell)
{
if (tileAludel.outputItemStack != null)
{
float scaleFactor = getGhostItemScaleFactor(tileAludel.outputItemStack);
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
EntityItem ghostEntityItem = new EntityItem(tileAludel.getWorldObj());
ghostEntityItem.hoverStart = 0.0F;
ghostEntityItem.setEntityItemStack(tileAludel.outputItemStack);
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
}
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
}
}
private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation)
{
if (orientation == ForgeDirection.NORTH)
{
GL11.glTranslated(x + 1, y, z);
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
}
else if (orientation == ForgeDirection.EAST)
{
GL11.glTranslated(x + 1, y, z + 1);
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
}
else if (orientation == ForgeDirection.SOUTH)
{
GL11.glTranslated(x, y, z + 1);
GL11.glRotatef(0F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
}
else if (orientation == ForgeDirection.WEST)
{
GL11.glTranslated(x, y, z);
GL11.glRotatef(-90F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
}
}
private float getGhostItemScaleFactor(ItemStack itemStack)
{
float scaleFactor = 1.0F;
if (itemStack != null)
{
byte numBlocks = 1;
if (itemStack.stackSize > 1)
{
numBlocks = 2;
}
else if (itemStack.stackSize > 5)
{
numBlocks = 3;
}
else if (itemStack.stackSize > 20)
{
numBlocks = 4;
}
else if (itemStack.stackSize > 40)
{
numBlocks = 5;
}
if (itemStack.getItem() instanceof ItemBlock)
{
switch (numBlocks)
{
case 1:
return 0.90F;
case 2:
return 0.90F;
case 3:
return 0.90F;
case 4:
return 0.90F;
case 5:
return 0.80F;
default:
return 0.90F;
}
}
else
{
switch (numBlocks)
{
case 1:
return 0.65F;
case 2:
return 0.65F;
case 3:
return 0.65F;
case 4:
return 0.65F;
default:
return 0.65F;
}
}
}
return scaleFactor;
}
}

View file

@ -0,0 +1,117 @@
package com.pahimar.ee3.client.renderer.tileentity;
import com.pahimar.ee3.client.renderer.model.ModelCalcinator;
import com.pahimar.ee3.client.util.ColorUtils;
import com.pahimar.ee3.reference.Colors;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileCalcinator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
{
private final ModelCalcinator modelCalcinator = new ModelCalcinator();
private static float[] getBlendedDustColour(int leftStackSize, int leftStackMeta, int rightStackSize, int rightStackMeta)
{
int totalDustStacksSize = leftStackSize + rightStackSize;
if (totalDustStacksSize > 0)
{
int leftStackColour = Integer.parseInt(Colors.DUST_COLOURS[MathHelper.clamp_int(leftStackMeta, 0, Colors.DUST_COLOURS.length)], 16);
int rightStackColour = Integer.parseInt(Colors.DUST_COLOURS[MathHelper.clamp_int(rightStackMeta, 0, Colors.DUST_COLOURS.length)], 16);
float leftStackRatio = leftStackSize * 1f / totalDustStacksSize;
float rightStackRatio = rightStackSize * 1f / totalDustStacksSize;
float[][] blendedColours = ColorUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 32);
if (blendedColours.length > 0)
{
if (Float.compare(leftStackRatio, rightStackRatio) > 0)
{
return blendedColours[Math.round((1 - leftStackRatio) * (blendedColours.length - 1))];
}
else
{
return blendedColours[Math.round(rightStackRatio * (blendedColours.length - 1))];
}
}
}
return new float[]{1F, 1F, 1F};
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
if (tileEntity instanceof TileCalcinator)
{
TileCalcinator tileCalcinator = (TileCalcinator) tileEntity;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.0F, (float) z + 1.2F);
GL11.glRotatef(45F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
// Bind texture
if (tileCalcinator.getState() == 1)
{
this.bindTexture(Textures.MODEL_CALCINATOR_ACTIVE);
}
else
{
this.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
}
// Render
modelCalcinator.renderPart("Calcinator");
int dustStackSize = tileCalcinator.leftStackSize + tileCalcinator.rightStackSize;
if (dustStackSize > 0)
{
GL11.glPushMatrix();
// Reverse previous rotation to get back into a workable frame of reference
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glRotatef(-45F, 0F, 1F, 0F);
float[] dustColour = getBlendedDustColour(tileCalcinator.leftStackSize, tileCalcinator.leftStackMeta, tileCalcinator.rightStackSize, tileCalcinator.rightStackMeta);
GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F);
if (dustStackSize <= 32)
{
GL11.glScalef(0.25F, 0.25F, 0.25F);
GL11.glTranslatef(0.0F, 2.20F, -2.1125F);
}
else if (dustStackSize <= 64)
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(-0.0125F, 0.75F, -0.7125F);
}
// Reapply previous rotation to get it back to a viewable state
GL11.glRotatef(45F, 0F, 1F, 0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
// Render the dust in the Calcinator bowl
modelCalcinator.renderPart("Dust");
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
}

View file

@ -0,0 +1,304 @@
package com.pahimar.ee3.client.renderer.tileentity;
import com.pahimar.ee3.client.renderer.model.ModelGlassBell;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileGlassBell;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer
{
private final ModelGlassBell modelGlassBell = new ModelGlassBell();
private final RenderItem customRenderItem;
public TileEntityGlassBellRenderer()
{
customRenderItem = new RenderItem()
{
@Override
public boolean shouldBob()
{
return false;
}
};
customRenderItem.setRenderManager(RenderManager.instance);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
if (tileEntity instanceof TileGlassBell)
{
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
/**
* Render the Glass Bell
*/
GL11.glPushMatrix();
// Scale, Translate, Rotate
renderGlassBellByOrientation(x, y, z, tileGlassBell.getOrientation());
// Bind texture
this.bindTexture(Textures.MODEL_GLASS_BELL);
modelGlassBell.render();
GL11.glPopMatrix();
/**
* Render the ghost item inside of the Glass Bell, slowly spinning
*/
GL11.glPushMatrix();
if (tileGlassBell.outputItemStack != null)
{
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.outputItemStack);
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
EntityItem ghostEntityItem = new EntityItem(tileGlassBell.getWorldObj());
ghostEntityItem.hoverStart = 0.0F;
ghostEntityItem.setEntityItemStack(tileGlassBell.outputItemStack);
translateGhostItemByOrientation(ghostEntityItem.getEntityItem(), x, y, z, tileGlassBell.getOrientation());
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
}
}
private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection)
{
switch (forgeDirection)
{
case DOWN:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.0F, (float) y + 2.0F, (float) z + 0.0F);
GL11.glRotatef(90F, 1F, 0F, 0F);
return;
}
case UP:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.0F, (float) y + -1.0F, (float) z + 1.0F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
return;
}
case NORTH:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 1.0F, (float) y + 0.0F, (float) z + 2.0F);
GL11.glRotatef(180F, 0F, 1F, 0F);
return;
}
case SOUTH:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + -1.0F);
return;
}
case EAST:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + -1.0F, (float) y + 1.0F, (float) z + 1.0F);
GL11.glRotatef(-90F, 0F, 0F, 1F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
return;
}
case WEST:
{
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 2.0F, (float) y + 0.0F, (float) z + 1.0F);
GL11.glRotatef(90F, 0F, 0F, 1F);
GL11.glRotatef(-90F, 1F, 0F, 0F);
return;
}
case UNKNOWN:
{
return;
}
default:
{
}
}
}
private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, ForgeDirection forgeDirection)
{
if (ghostItemStack != null)
{
if (ghostItemStack.getItem() instanceof ItemBlock)
{
switch (forgeDirection)
{
case DOWN:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.7F, (float) z + 0.5F);
return;
}
case UP:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F);
return;
}
case NORTH:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F);
return;
}
case SOUTH:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F);
return;
}
case EAST:
{
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F);
return;
}
case WEST:
{
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F);
return;
}
case UNKNOWN:
{
return;
}
default:
{
}
}
}
else
{
switch (forgeDirection)
{
case DOWN:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F);
return;
}
case UP:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F);
return;
}
case NORTH:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F);
return;
}
case SOUTH:
{
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F);
return;
}
case EAST:
{
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F);
return;
}
case WEST:
{
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
return;
}
case UNKNOWN:
{
return;
}
default:
{
}
}
}
}
}
private float getGhostItemScaleFactor(ItemStack itemStack)
{
float scaleFactor = 1.0F;
if (itemStack != null)
{
byte numBlocks = 1;
if (itemStack.stackSize > 1)
{
numBlocks = 2;
}
else if (itemStack.stackSize > 5)
{
numBlocks = 3;
}
else if (itemStack.stackSize > 20)
{
numBlocks = 4;
}
else if (itemStack.stackSize > 40)
{
numBlocks = 5;
}
if (itemStack.getItem() instanceof ItemBlock)
{
switch (numBlocks)
{
case 1:
return 0.90F;
case 2:
return 0.90F;
case 3:
return 0.90F;
case 4:
return 0.90F;
case 5:
return 0.80F;
default:
return 0.90F;
}
}
else
{
switch (numBlocks)
{
case 1:
return 0.65F;
case 2:
return 0.65F;
case 3:
return 0.65F;
case 4:
return 0.65F;
default:
return 0.65F;
}
}
}
return scaleFactor;
}
}

View file

@ -0,0 +1,39 @@
package com.pahimar.ee3.client.renderer.tileentity;
import com.pahimar.ee3.client.renderer.model.ModelResearchStation;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileResearchStation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class TileEntityResearchStationRenderer extends TileEntitySpecialRenderer
{
private final ModelResearchStation modelResearchStation = new ModelResearchStation();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
{
if (tileEntity instanceof TileResearchStation)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
// Scale, Translate, Rotate
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + 1.0F);
// Bind texture
this.bindTexture(Textures.MODEL_RESEARCH_STATION);
// Render
modelResearchStation.render();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
}

View file

@ -0,0 +1,89 @@
package com.pahimar.ee3.client.util;
public class ColorUtils
{
public static byte[] convertIntColourToByteArray(int intColour)
{
byte[] colourByteArray = new byte[3];
colourByteArray[0] = (byte) (intColour >> 16 & 255);
colourByteArray[1] = (byte) (intColour >> 8 & 255);
colourByteArray[2] = (byte) (intColour & 255);
return colourByteArray;
}
public static float[] convertIntColourToFloatArray(int intColour)
{
float[] colourFloatArray = new float[3];
colourFloatArray[0] = ((intColour >> 16 & 0xFF) / 255F);
colourFloatArray[1] = ((intColour >> 8 & 0xFF) / 255F);
colourFloatArray[2] = ((intColour & 0xFF) / 255F);
return colourFloatArray;
}
public static byte[][] getByteBlendedColours(byte[] firstColour, byte[] secondColour, int steps)
{
if (firstColour.length == 3 && secondColour.length == 3 && steps > 0)
{
byte[][] blendedColours = new byte[steps + 2][3];
byte redDifference = (byte) (((secondColour[0] & 0xFF) - (firstColour[0] & 0xFF)) / steps);
byte greenDifference = (byte) (((secondColour[1] & 0xFF) - (firstColour[1] & 0xFF)) / steps);
byte blueDifference = (byte) (((secondColour[2] & 0xFF) - (firstColour[2] & 0xFF)) / steps);
blendedColours[0] = firstColour;
for (int i = 1; i < blendedColours.length - 1; i++)
{
blendedColours[i][0] = (byte) (firstColour[0] + i * redDifference);
blendedColours[i][1] = (byte) (firstColour[1] + i * greenDifference);
blendedColours[i][2] = (byte) (firstColour[2] + i * blueDifference);
}
blendedColours[blendedColours.length - 1] = secondColour;
return blendedColours;
}
return null;
}
public static float[][] getFloatBlendedColours(byte[] firstColour, byte[] secondColour, int steps)
{
byte[][] byteBlendedColours = getByteBlendedColours(firstColour, secondColour, steps);
if (byteBlendedColours != null)
{
float[][] floatBlendedColours = new float[byteBlendedColours.length][3];
for (int i = 0; i < byteBlendedColours.length; i++)
{
floatBlendedColours[i][0] = (byteBlendedColours[i][0] & 0xFF) / 255F;
floatBlendedColours[i][1] = (byteBlendedColours[i][1] & 0xFF) / 255F;
floatBlendedColours[i][2] = (byteBlendedColours[i][2] & 0xFF) / 255F;
}
return floatBlendedColours;
}
else
{
return null;
}
}
public static float[][] getFloatBlendedColours(int firstColour, int secondColour, int steps)
{
byte[] firstColourByteArray = convertIntColourToByteArray(firstColour);
byte[] secondColourByteArray = convertIntColourToByteArray(secondColour);
if (firstColourByteArray != null && secondColourByteArray != null)
{
return getFloatBlendedColours(firstColourByteArray, secondColourByteArray, steps);
}
else
{
return null;
}
}
}

View file

@ -1,10 +1,10 @@
package com.pahimar.ee3.proxy;
import com.pahimar.ee3.block.ModBlocks;
import com.pahimar.ee3.client.renderer.item.ItemAlchemicalChestRenderer;
import com.pahimar.ee3.client.renderer.tileentity.TileEntityAlchemicalChestRenderer;
import com.pahimar.ee3.client.renderer.item.*;
import com.pahimar.ee3.client.renderer.tileentity.*;
import com.pahimar.ee3.reference.RenderIds;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import com.pahimar.ee3.tileentity.*;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.item.Item;
@ -22,7 +22,15 @@ public class ClientProxy extends CommonProxy
RenderIds.researchStation = RenderingRegistry.getNextAvailableRenderId();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.alchemicalChest), new ItemAlchemicalChestRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.aludel), new ItemAludelRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.calcinator), new ItemCalcinatorRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.glassBell), new ItemGlassBellRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.researchStation), new ItemResearchStationRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileAlchemicalChest.class, new TileEntityAlchemicalChestRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCalcinator.class, new TileEntityCalcinatorRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileAludel.class, new TileEntityAludelRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileGlassBell.class, new TileEntityGlassBellRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileResearchStation.class, new TileEntityResearchStationRenderer());
}
}

View file

@ -0,0 +1,14 @@
package com.pahimar.ee3.reference;
import com.pahimar.ee3.util.ResourceLocationHelper;
import net.minecraft.util.ResourceLocation;
public class Models
{
public static final String MODEL_LOCATION = "models/";
public static final ResourceLocation ALUDEL = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj");
public static final ResourceLocation CALCINATOR = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "calcinator.obj");
public static final ResourceLocation GLASS_BELL = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj");
public static final ResourceLocation RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "researchStation.obj");
}

View file

@ -11,6 +11,7 @@ public class Names
public static final String ALUDEL = "aludel";
public static final String GLASS_BELL = "glassBell";
public static final String CALCINATOR = "calcinator";
public static final String RESEARCH_STATION = "researchStation";
}
public static class Items
@ -60,6 +61,5 @@ public class Names
public static final String ALUDEL_NAME = "container.ee3:" + Blocks.ALUDEL;
public static final String GLASS_BELL = "container.ee3:" + Blocks.GLASS_BELL;
}
}

View file

@ -16,8 +16,6 @@ public class Textures
public static final ResourceLocation MODEL_ALUDEL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "aludel.png");
public static final ResourceLocation MODEL_ALCHEMICAL_CHEST_SMALL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_small.png");
public static final ResourceLocation MODEL_ALCHEMICAL_CHEST_MEDIUM = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_medium.png");
// Armor sprite sheets
public static final ResourceLocation MODEL_ALCHEMICAL_CHEST_LARGE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_large.png");
public static final ResourceLocation MODEL_GLASS_BELL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "aludel.png");
public static final ResourceLocation MODEL_RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "researchStation.png");

View file

@ -0,0 +1,5 @@
package com.pahimar.ee3.tileentity;
public class TileResearchStation extends TileEntityEE
{
}