Jump to content

Custom Block Texture not Loading


afiolmahon

Recommended Posts

I created a custom model for a block, and everything seems to be working well except I can't get the texture to load. I have tried looking at other forums for what people had done for mob entity textures and they didn't seem to work.

 

Here is my code

in the client proxy

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAltarBlockEntity.class, new TileEntityAltarBlockRenderer());

 

The renderer

 

 

package afiolmahon.altercraft;

import org.lwjgl.opengl.GL11;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class TileEntityAltarBlockRenderer extends TileEntitySpecialRenderer {
        
        //The model of your block
        private final AltarBlockModel model;
        
        public TileEntityAltarBlockRenderer() {
                this.model = new AltarBlockModel();
        }
        
        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 + 1.5F, (float) z + 0.5F);
        //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(180F, 0.0F, 0.0F, 1.0F);
        //A reference to your Model file. Again, very important.
                this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        //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) {
                Tessellator tess = Tessellator.instance;
                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);
        }

	/**@Override
	public void renderTileEntityAt(TileEntity tileentity, double d0,
			double d1, double d2, float f) {
	}
	*/
	private static final ResourceLocation field_110890_f = new ResourceLocation(afiolmahon.altercraft.altercraft.modid, "textures/entity/AltarTexture.png");
}

 

 

Block Itself

 

package afiolmahon.altercraft;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class TileEntityAltarBlock extends BlockContainer {

        //Treat it like a normal block here. The Block Bounds are a good idea - the first three are X Y and Z of the botton-left corner,
        //And the second three are the top-right corner.
        public TileEntityAltarBlock(int id) {
                super(id, Material.iron);
                this.setCreativeTab(altercraft.tabaltercraft);
        }

        //Make sure you set this as your TileEntity class relevant for the block!
        @Override
        public TileEntity createNewTileEntity(World world) {
                return new TileEntityAltarBlockEntity();
        }
        
        //You don't want the normal render type, or it wont render properly.
        @Override
        public int getRenderType() {
                return -1;
        }
        
        //It's not an opaque cube, so you need this.
        @Override
        public boolean isOpaqueCube() {
                return false;
        }
        
        //It's not a normal block, so you need this too.
        public boolean renderAsNormalBlock() {
                return false;
        }
        
        //This is the icon to use for showing the block in your hand.
        public void registerIcons(IconRegister icon) {
                this.blockIcon = icon.registerIcon("Roads:TrafficLightIcon");
        }

	@Override
	public TileEntity createNewTileEntity(World world) {
		// TODO Auto-generated method stub
		return null;
	}

}

 

 

Main Mod File

 

package afiolmahon.altercraft;

import java.util.Map;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="afiolmahon.altercraft.modid", name="Altercraft", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class altercraft {

	public static final String modid = "altercraft";

	   public static CreativeTabs tabaltercraft = new CreativeTabs("Altercraft") {
               public ItemStack getIconItemStack() {
                       return new ItemStack(altercraft.BlockShimmeringStone, 1, 0);
               }
       };

        // The instance of your mod that Forge uses.
        @Instance("altercraft")
        public static altercraft instance;
        
        private final static Item ItemShimmeringExtract = new ItemShimmeringExtract(5000).setMaxStackSize(64).setCreativeTab(altercraft.tabaltercraft).setUnlocalizedName("ItemShimmeringExtract");
        public final static Block BlockShimmeringStone = new BlockShimmeringStone(500, Material.ground).setHardness(0.5F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("BlockShimmeringStone").setCreativeTab(altercraft.tabaltercraft).setLightValue(1.0F);
        final static Item ShimmeringSlug = new ShimmeringSlug(5001).setMaxStackSize(64).setCreativeTab(altercraft.tabaltercraft).setUnlocalizedName("ShimmeringSlug");
        public final static Block TileEntityAltarBlock = new TileEntityAltarBlock(501).setHardness(0.5F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("TileEntityAltarBlock").setCreativeTab(altercraft.tabaltercraft);

        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="afiolmahon.altercraft.client.ClientProxy", serverSide="afiolmahon.altercraft.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
                // Stub Method
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                
                LanguageRegistry.addName(ItemShimmeringExtract, "Shimmering Extract");
                GameRegistry.registerBlock(BlockShimmeringStone, "BlockShimmeringStone");
                LanguageRegistry.addName(BlockShimmeringStone, "Shimmering Stone");
                LanguageRegistry.addName(ShimmeringSlug, "Shimmering Slug");
                //Custom Tab
                LanguageRegistry.instance().addStringLocalization("itemGroup.Altercraft", "en_US", "Altercraft");
                //AltarBlock
                GameRegistry.registerTileEntity(TileEntityAltarBlockEntity.class, "tileEntityAltarBlock");
                GameRegistry.registerBlock(TileEntityAltarBlock, "TileEntityAltarBlock");
                LanguageRegistry.addName(TileEntityAltarBlock, "TileEntityAltarBlock");
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.