package com.pixelutilitys.models.renderers; import com.pixelmonmod.pixelmon.client.models.pokeballs.ModelPokeball; import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; public class PokeballRenderer extends TileEntitySpecialRenderer { ResourceLocation texture = new ResourceLocation("pixelmon:textures/pokeballs/pokeball.png"); //The model of your block private final ModelPokeball model; public PokeballRenderer() { this.model = new com.pixelmonmod.pixelmon.client.models.pokeballs.ModelPokeball(); } private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); GL11.glPushMatrix(); GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); GL11.glPopMatrix(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) (y + 0.1), (float) z + 0.5F); //1.7 edited here //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); //Use in 1.6.2 this //the ':' is very important //binding the textures this.bindTexture(texture); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); GL11.glRotatef(0, 90.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. switch (te.getBlockMetadata()) { default: GL11.glRotatef(360f, 0f, 1f, 0f); break; case 1: GL11.glRotatef(90f, 0f, 1f, 0f); break; case 2: GL11.glRotatef(180f, 0f, 1f, 0f); break; case 3: GL11.glRotatef(270f, 0f, 1f, 0f); break; } this.model.render(null, (float) (1.0 / 200.0)); //Tell it to stop rendering for both the PushMatrix's GL11.glPopMatrix(); GL11.glPopMatrix(); } //Set the lighting stuff, so it changes it's brightness properly. private void adjustLightFixture(World world, int i, int j, int k, Block block) { //float brightness = block.getBlockBrightness(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; // tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); this.bindTexture(texture); } }