Jump to content

[1.3.2]Custom Block Rendering just stays invisible.


Recommended Posts

Posted

I having a custom block renderer and when i place it ingame it will show nothing Here is the code:

 

 

Main File:

package net.minecraft.projectnavitas;

import net.minecraft.src.BaseMod;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Item;
import net.minecraft.src.ModLoader;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntityRenderer;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="ProjectNavitas",name="Project Navitas",version="0.1")

@NetworkMod(clientSideRequired=true, serverSideRequired=false,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"ProjectNavitas" }, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"ProjectNavitas" }, packetHandler = ServerPacketHandler.class))



public class ProjectNavitas{

@Instance("ProjectNavitas")
public static ProjectNavitas instance = new ProjectNavitas();

@SidedProxy(clientSide="net.minecraft.projectnavitas.ClientProxy", serverSide= "net.minecraft.projectnavitas.CommonProxy")
public static CommonProxy proxy;

public static GuiHandler guiHandler = new GuiHandler();

public static final Item WhiteCrystalShard = new ItemWhiteCrystalShard(4000, CreativeTabs.tabMaterials, 0, "WhiteCrystalShard");

public static final Block WhiteCrystal = new BlockWhiteCrystal(3000, 0);

@Init
public void Init(FMLInitializationEvent event){

	GameRegistry.registerBlock(WhiteCrystal);

	proxy.init();

	LanguageRegistry.addName(WhiteCrystalShard, "White Crystal Shard");
	LanguageRegistry.addName(WhiteCrystal, "White Crystal");

	NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
}

public void renderInvBlock(RenderBlocks var1, Block var2, int var3, int var4){
        if (var4 == WhiteCrystal.getRenderType())
        {
        	TileEntityRenderer.instance.renderTileEntityAt(new TileEntityCrystal(), 0.0D, 0.0D, 0.0D, 0.0F);
        }
}


@PreInit
public void PreInit(FMLPreInitializationEvent event){

}

@PostInit
public void PostInit(FMLPostInitializationEvent event){

}

}

 

BlockWhiteCrystal:

package net.minecraft.projectnavitas;

import java.util.Random;

import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;

public class BlockWhiteCrystal extends Block{

public BlockWhiteCrystal(int id, int texture) {
	super(id, texture, Material.rock);
	setHardness(1.0F);
	setResistance(2.0F);
	setCreativeTab(CreativeTabs.tabBlock);
}

public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return -1;
}

public TileEntity getBlockEntity()
{
try{
return (TileEntity)TileEntityCrystal.class.newInstance();
}
catch(Exception exception){
throw new RuntimeException(exception);
}
}

public TileEntity TileEntity(){
	return new TileEntityCrystal();
}
}

ClientProxy

package net.minecraft.projectnavitas;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


public class ClientProxy extends CommonProxy{

public void init(){
	initTileEntities();
	LanguageRegistry.instance().addNameForObject(ProjectNavitas.WhiteCrystal, "en_US", "White Crystal");
}

public void initTileEntities(){
	GameRegistry.registerTileEntity(TileEntityCrystal.class, "tileCrystal");
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystal.class, new TileEntityCrystalRenderer());
}
}

CommonProxy

import java.util.Objects;

import net.minecraft.src.EnumRarity;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

public class CommonProxy{

public void preInit()
{
	registerGuiHandler();
}

public void init()
{
	initRenderingAndTextures();
	initCustomRarityTypes();
	initTileEntities();
}

/**
 * Post-Initialization event handler method. Everything within this method is called after all
 * mods are done loading.
 */
public void postInit()
{
}

public void registerRenderInformation() {}

public void initRenderingAndTextures() {}

public void initCustomRarityTypes() {}

public void initTileEntities()
{

	GameRegistry.registerTileEntity(TileEntityCrystal.class, "tileCrystal");
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrystal.class, new TileEntityCrystalRenderer());
}

public EnumRarity getCustomRarityType(String customRarity) {
	return null;
}

public void registerGuiHandler() {}

}

Model

package net.minecraft.projectnavitas;

import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;

public class ModelProjector extends ModelBase{

//fields
    ModelRenderer Shape1;
    ModelRenderer Piece1;
    private int xyzz;
    ModelRenderer rendermap[] = new ModelRenderer[4096];
  
  public ModelProjector()
  {
  textureWidth = 64;
  textureHeight = 32;
  xyzz = 0;
  for(float i = -8F; i<8F; i++){
	  for(float j = 8F; j<24F; j++){
		  for(float k = -8F; k<8F; k++){
			  rendermap[xyzz] = new ModelRenderer(this, 0, 0);
			  rendermap[xyzz].addBox(i, j, k, 1, 1, 1);
			  rendermap[xyzz].setRotationPoint(0F, 0F, 0F);
			  rendermap[xyzz].setTextureSize(64, 32);
			  setRotation(rendermap[xyzz], 0F, 0F, 0F);
			  xyzz++;
		  }
	  }
  }
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(-8F, -8F, -8F, 16, 15, 16);
      Shape1.setRotationPoint(0F, 0F, 0F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      
      
      
      Piece1 = new ModelRenderer(this, "Piece1");
      Piece1.setRotationPoint(0F, 0F, 0F);
      setRotation(Piece1, 0F, 0F, 0F);
      Piece1.mirror = true;
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Shape1.render(f5);
    for(int i = 0;i< 4096; i++){
		  rendermap[i].render(f5);
  }
    Piece1.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void renderModel(float f1)
  {
  Shape1.render(f1);
  for(int i = 0;i< 4096; i++){
	  rendermap[i].render(f1);
  }
  	Piece1.render(f1);
  }

  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5);
  }

}

TileEntityCrystalRenderer

package net.minecraft.projectnavitas;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import net.minecraft.src.Tessellator;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;

public class TileEntityCrystalRenderer extends TileEntitySpecialRenderer{

public TileEntityCrystalRenderer(){
	model = new ModelProjector();
}

public void renderAModelAt(TileEntityCrystal tile, double d, double d1, double d2, float f) {
	GL11.glPushMatrix();
	GL11.glTranslatef((float)d + 0.5F, (float)d1 + 0.5F, (float)d2 + 0.5F);
	bindTextureByName("/projectnavitas/Projector.png");
	GL11.glPushMatrix();
	model.renderModel(0.625F);
	GL11.glPopMatrix();
	GL11.glPopMatrix();

}

public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) {
	renderAModelAt((TileEntityCrystal) tileentity, d, d1, d2, f); //where to render
}

private ModelProjector model;
}

 

TileEntityCrystal

package net.minecraft.projectnavitas;

import net.minecraft.src.TileEntity;

public class TileEntityCrystal extends TileEntity{

public TileEntityCrystal(){

}

}

 

 

Thanks in befor hand :)

 

//Hirvio

 

  • 2 weeks later...
Posted

BlockWhiteCrystal:

package net.minecraft.projectnavitas;

import java.util.Random;

import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;

public class BlockWhiteCrystal extends Block{

public BlockWhiteCrystal(int id, int texture) {
	super(id, texture, Material.rock);
	setHardness(1.0F);
	setResistance(2.0F);
	setCreativeTab(CreativeTabs.tabBlock);
}

public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return -1;
}

public TileEntity getBlockEntity()
{
try{
return (TileEntity)TileEntityCrystal.class.newInstance();
}
catch(Exception exception){
throw new RuntimeException(exception);
}
}

public TileEntity TileEntity(){
	return new TileEntityCrystal();
}
}

 

You should add methods: public boolean hasTileEntity(int metadata)

and public TileEntity createTileEntity(World world, int metadata). I've had the same problem, because i hadn't second one added, don't know why is it so important.

 

Also I guess that you should override methods onBlockAdded and breakBlock to make sure that there's creating and destroying tile entity to your block.

 

And sorry for my English:)

If you see a mistake in my post please tell me about it. Thanks and sorry for my English.

  • 2 weeks later...
Posted

I am just wondering if you have found a resolution to this issue? I have now been working three days trying to get this working and I am also getting only a bounding box and nothing inside it rendering.  I have been looking at open source code and I have been looking at out dated videos for mod loader as they are the only ones I can see.

 

did you find the missing step that was making it invisible or did you find any good tutorials?

 

thanks for any help you can provide

Neoublie

Author of Codename: Project Shadow

 

if you do models and textures pm me. looking for some assistance.

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

    • Sorry for the late response, but the game opened and I made a world but it's stuck at 0% Here's the latest.log https://mclo.gs/peEb1R8 I disabled The Factory Must Grow and soulsweapons
    • Hey everyone! Two of my friends downloaded this modpack and are having an issue with the blocks loading in correctly. Grass looks like bamboo, waystones look like two barrels stacked on eachother, and wheat looks like water and stairs. What is this problem? How can we fix it? Neither of my other friends or myself had this issue. 
    • I removed Yung's cave biome mod and It wasnt in one of those biomes however the log file said the same line (([25Apr2025 21:20:15.500] [Flywheel Task Executor #5/WARN] [Embeddium-MixinTaintDetector/]: Mod(s) [oculus] are modifying Embeddium class me.jellysquid.mods.sodium.client.render.vertex.serializers.VertexSerializerRegistryImpl, which may cause instability.))
    • Note: i had a couple of ideas, but i just don't know how to execute them. The main idea was to make the new block (let's exemplify with a mixer) be essentially a clone of the mechanical mixer (different texture tho) that would have a different recipe type (instead of mixing, advanced_mixing) and i would copy all the create mod recipes and edit the processing time while also adding the tier dependent ones.
    • Hi! Before everything, thank you for even reading. I'm coming here in need of help making a few aspects for a create mod addon. It's an addon that aims to add almost the full periodic table with realistic ways of obtaining all the elements and capability of almost full automation. For what purpose? A techy armor and to go to the moon and rocky planets of the solar system. It'll have 3 different tiers of machines (mixer, millstone, crushing wheels): basic (just the normal create mod machines but renamed), advanced (25% faster and has recipes only possible for this tier and above) end elite (75% faster than basic and recipes only available for this tier). The problem is, I'm not a coder. I know less than the basics. I know how to do everything else but these machine tiers and i need some help if you can.
  • Topics

×
×
  • Create New...

Important Information

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