Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi, me and my friend are currently developing a mod called:mod

Basically it's just a framework, we have auto textures (me), and auto-ores-dusts-blocks-ingots-nuggets(by him)

So we were trying to make our version of the treetap. he idea is, you put it on our custom tree(code 70% done) and whack it with a hammer, and it starts spewing out resin, so the problem is, we can't get our model to render.

It's a fairly simple model, like 1 cuboid in techne and thats it.

If you guys could help we would be very greatfull!

If u need more files just say, we'll do anything to make it work.

 

Core

 

package mod;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = Core.modid, name = "CoreMod", version = "Unreleased")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Core {
public static final String modid = "mod";

public static CreativeTabs tabMod = new CreativeTabs("tabMod") {
	public ItemStack getIconItemStack() {
		return new ItemStack(LoadMaterials.block[3], 1, 0);
	}
};

@SidedProxy(clientSide = "mod.ClientProxy", serverSide = "mods.CommonProxy")
public static CommonProxy Proxy;

EventManager eventManager = new EventManager();

public static Item wrench;
public static Block treetap;
public static Block treeRubber;
public static Block leavesRubber;

@EventHandler
public void load(FMLInitializationEvent event) {
	initialize();
        GameRegistry.registerTileEntity(TileEntityTreetap.class, "tileEntityTreetap");
	LanguageRegistry.instance().addStringLocalization("itemGroup.tabMod", "en_US", "Mod Tab");
}

private void initialize() {
	LoadMaterials.loadMaterials();
	initializeBlocks();
	initializeItems();
	registerOther();
}

// BIOMES
private void registerOther() {
	GameRegistry.registerWorldGenerator(eventManager);
}

// BLOCKS
private void initializeBlocks() {
	treetap = new BlockTreetap(901).setUnlocalizedName("treetap");
	treeRubber = new BlockTreeRubber(902).setUnlocalizedName("treeRubber").setHardness(2.0F).setResistance(5.0F);
	leavesRubber = new BlockLeavesRubber(903).setUnlocalizedName("leavesRubber").setHardness(0.2F).setLightOpacity(1);

	registerBlocks();
}

private void registerBlocks() {
	GameRegistry.registerBlock(treetap);
	GameRegistry.registerBlock(treeRubber);
	GameRegistry.registerBlock(leavesRubber);

	registerTileEntity();
	languageRegistryBlocks();
}

private void registerTileEntity() {
}

private void languageRegistryBlocks() {
	LanguageRegistry.addName(treetap, "Treetap");
	LanguageRegistry.addName(treeRubber, "Rubber Tree");
	LanguageRegistry.addName(leavesRubber, "Rubber Tree Leaves");

	oreDictionaryBlocks();
}

private void oreDictionaryBlocks() {
	OreDictionary.registerOre("treetap", treetap);
	OreDictionary.registerOre("treeRubber", treeRubber);
	OreDictionary.registerOre("leavesRubber", leavesRubber);
}

// ITEMS
private void initializeItems() {
	wrench = new itemWrench(13000).setUnlocalizedName("Wrench");

	languageRegistryItems();
}

private void languageRegistryItems() {
	for (int i = 0; i < 16; i++) {
		LanguageRegistry.addName(new ItemStack(wrench, 1, i), "Wrench");
	}

	oreDictionaryItems();
}

private void oreDictionaryItems() {
	OreDictionary.registerOre("wrench", wrench);
}
}

 

 

Tile Entity

 

package mod;

import net.minecraft.tileentity.TileEntity;

public class TileEntityTreetap extends TileEntity {

}

 

 

Renderer

 

package mod;

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;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.FMLClientHandler;

public class TileEntityTreetapRenderer extends TileEntitySpecialRenderer {
ResourceLocation resourceLocation = new ResourceLocation(Core.modid
		+ ":textures/models/Model.png");
// The model of your block
private final ModelTreetap model;

public TileEntityTreetapRenderer() {
	this.model = new ModelTreetap();
}

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) {
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	// as your other blocks here.
	FMLClientHandler.instance().getClient().renderEngine
			.func_110577_a(resourceLocation);
	GL11.glPushMatrix();
	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	this.model
			.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
	GL11.glPopMatrix();
}

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);
}
}

 

 

Block

 

package mod;

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 BlockTreetap extends BlockContainer {

public BlockTreetap(int id) {
	super(id, Material.iron);
	this.setCreativeTab(Core.tabMod);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1F, 1F, 1F);
}

@Override
public TileEntity createNewTileEntity(World world) {
	return new TileEntityTreetap();
}

@Override
public int getRenderType() {
	return -1;
}

@Override
public boolean isOpaqueCube() {
	return false;
}

public boolean renderAsNormalBlock() {
	return false;
}

public void registerIcons(IconRegister icon) {
	this.blockIcon = icon.registerIcon(Core.modid+":TreetapIcon");
}
}

 

 

Client proxy

 

package mod;

import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;

public class ClientProxy extends CommonProxy {
@Override
public void InitRendering() {
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTreetap.class, new TileEntityTreetapRenderer());
}

}

 

 

Model

 

package mod;

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

public class ModelTreetap extends ModelBase
{
  //fields
    ModelRenderer Shape1;
  
  public ModelTreetap()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 2, 2, 16);
      Shape1.setRotationPoint(-1F, 15F, -8F);
      Shape1.setTextureSize(32, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 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);
    Shape1.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) //Add Entity entity here
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); //Add entity here
  }

}

 

I dunno about the rest of the code but the resource location has been declared wrong

 

it needs to be a comma instead of a plus

 

like

	ResourceLocation resourceLocation = new ResourceLocation(Core.modid, ":textures/models/Model.png")

 

I just tested it on my own render and when I used the plus it gave a missing texture

changing it to what it is above gave the right texture

  • Author

Thx for the advice, im currently on my phone but i'll try it for 20 mins when i get home(in the bus)

*facepalm* dont use tile entities for thsi kind of thing, you're just going to make your server lag a lot, use meta please

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

I just noticed the plus in the block icon code in the block code as well, which may need changing

 

but anyway

did the tutorial tell you to put

		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTreetap.class, new TileEntityTreetapRenderer());

 

in initrendering?

 

I only ask because when I've done custom blocks I've put it in the

    public void registerRenderThings()

method

 

I'm not sure if it'll make any difference but you could try it for nothing?

What I mean is you never do InitRendering() anywhere and your registerTileEntity() does nothing.

Learn how to code before doing something like complex rendering.

And if you 'just missed' the unused methods for some reason (although I think GotoLink is right), you can use Call Hierarchy in Eclipse to track where in your program the said method is being called. <3 Eclipse

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

call hierarchy, type hierarchy, breakpoints and your eyez are the 4 most overpowered tools when modding minecraft

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

  • Author

Oh Goto thank you so much, and thank you all. I wasn't calling the InitRendering, somehow my f****** brain thought that it would be called by itself. :)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.