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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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