Jump to content

Recommended Posts

Posted

So im trying to get a custom techne model to render as a block, but it just wont. Heres my code, can someone help me figure this out? The block is in the game its just invisible, and theres particles when i break it.

 

BasicRenderer.java

package com.gtr.progressionplus.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import scala.Console;

import com.gtr.progressionplus.common.References;
import com.gtr.progressionplus.model.ModelExtension;
import com.gtr.progressionplus.model.ObsidianForge;

public class BasicRenderer extends TileEntitySpecialRenderer
{
    private ModelExtension model;
    public static ResourceLocation texture;
    public BasicRenderer(ModelExtension model, ResourceLocation texture)
    {
        this.model = model;
        this.texture = texture;
    }
    @Override
    public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float f1)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
        GL11.glRotatef(180, 0, 0, 1);
        this.bindTexture(texture);
        GL11.glPushMatrix();
        this.model.renderModel(0.0625f);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }
}

 

ModBlocks.java

package com.gtr.progressionplus.common;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;

import com.gtr.progressionplus.ProgressionPlus;
import com.gtr.progressionplus.block.MeteoriteOre;
import com.gtr.progressionplus.block.ObsidianForgeBlock;
import com.gtr.progressionplus.block.SimpleBlock;
import com.gtr.progressionplus.block.SimpleOre;
import com.gtr.progressionplus.block.entity.ObsidianForgeEntity;

import cpw.mods.fml.common.registry.GameRegistry;

public class ModBlocks
{
    
    public static Block compressed_obsidian;
    public static SimpleOre meteorite_ore;
    public static SimpleOre nadium_ore;
    public static Block obsidian_forge;
    
    public static void Add()
    {
        compressed_obsidian = new SimpleBlock(Material.rock, 55.0F, 2250.0F).setBlockName("compressedObsidian").setStepSound(Block.soundTypePiston).setBlockTextureName("obsidian");
        compressed_obsidian.setHarvestLevel("pickaxe", 3);
        
        meteorite_ore = (MeteoriteOre) new MeteoriteOre().setBlockName("oreMeteorite").setHardness(6.0F).setResistance(350.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("progressionplus:meteorite_ore");
        meteorite_ore.setHarvestLevel("pickaxe", 2);
        ((SimpleOre) meteorite_ore).setItemDrop(ModItems.meteorite_chunk);
        
        nadium_ore = (SimpleOre) new SimpleOre().setBlockName("oreNadium").setHardness(4.0F).setResistance(250.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("diamond_ore");
        nadium_ore.setHarvestLevel("pickaxe", 3);
        nadium_ore.setBlockDrop(nadium_ore);
        
        obsidian_forge = new ObsidianForgeBlock(Material.rock).setCreativeTab(ProgressionPlus.tabProgressionPlus);
        
        Register();
    }
    
    public static void Register()
    {
        GameRegistry.registerBlock(compressed_obsidian, "compressed_obsidian");
        GameRegistry.registerBlock(nadium_ore, "nadium_ore");
        GameRegistry.registerBlock(meteorite_ore, "ore_meteorite");
        GameRegistry.registerBlock(obsidian_forge, "obsidian_forge");
        GameRegistry.registerTileEntity(ObsidianForgeEntity.class, "obsidian_forge_entity");
    }
}

 

ObsidianForgeBlock.java

package com.gtr.progressionplus.block;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import com.gtr.progressionplus.block.entity.ObsidianForgeEntity;

public class ObsidianForgeBlock extends Block
{
    public ObsidianForgeBlock(Material material)
    {
        super(material);
        this.setHardness(20f);
        this.setResistance(20f);
    }

    public TileEntity createNewTileEntity(World world, int par2)
    {
        return new ObsidianForgeEntity();
    }
    public int getRenderType()
    {
        return -1;
    }
    public boolean renderAsNormalCube()
    {
        return false;
    }
    public boolean isOpaqueCube()
    {
        return false;
    }
    
}

 

ObsidianForge.java (the model)

package com.gtr.progressionplus.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ObsidianForge extends ModelExtension
{
  //fields
    ModelRenderer Main_Furnace_Body;
    ModelRenderer Shape1;
    ModelRenderer Shape2;
  
  public ObsidianForge()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Main_Furnace_Body = new ModelRenderer(this, 0, 0);
      Main_Furnace_Body.addBox(0F, 14F, 7F, 16, 10, 16);
      Main_Furnace_Body.setRotationPoint(-8F, 0F, -15F);
      Main_Furnace_Body.setTextureSize(64, 64);
      Main_Furnace_Body.mirror = true;
      setRotation(Main_Furnace_Body, 0F, 0F, 0F);
      Shape1 = new ModelRenderer(this, 0, 26);
      Shape1.addBox(-7F, 13F, -15F, 14, 2, 16);
      Shape1.setRotationPoint(0F, -1F, 7F);
      Shape1.setTextureSize(64, 64);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 44);
      Shape2.addBox(-5F, 11F, -8F, 10, 1, 16);
      Shape2.setRotationPoint(0F, 0F, 0F);
      Shape2.setTextureSize(64, 64);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
  }
  
  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,entity);
    Main_Furnace_Body.render(f5);
    Shape1.render(f5);
    Shape2.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 f)
  {
      Main_Furnace_Body.render(f);
      Shape1.render(f);
      Shape2.render(f);
  }
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

and my init method

@EventHandler
public void preInit(FMLInitializationEvent event) {
	OreGeneration ore_gen = new OreGeneration();
	GameRegistry.registerWorldGenerator(ore_gen, 0);

	ModItems.Add();
	ModBlocks.Add();
	ModRecipes.Add();
	GameRegistry.registerFuelHandler(new SimpleFuelHandler());
	proxy.registerRenderers();

	MinecraftForge.EVENT_BUS.register(new IHookContainer());

	System.out.println("Progression Plus has pre-initialized!");
}

thanks in advance to anyone who helps :D

 

EDIT:

And ModelExtension.java

package com.gtr.progressionplus.model;

import net.minecraft.client.model.ModelBase;

public class ModelExtension extends ModelBase
{
    public void renderModel(float f)
    {
        
    }
}

Posted

Myabe I'm missing it, but I don't see where you are registering in your client proxy for minecraft to use your custom render.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

Hi

 

I suggest to put

System.out.println("rendering");

into your renderTileEntityAt()

 

If it prints nothing, you probably have a registration problem

If it prints, you probably have a rendering problem.

 

That will narrow it down a lot.

 

-TGG

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.