Jump to content

Recommended Posts

Posted

I've recently started to mod with Forge and I want to create my own tree.

After trying to look up some tutorials on youtube, I found that these are outdated due to the way textures are now stored.

 

I also tried the javadocs, but I can't really make sense of it..

 

Could anyone here link me an up to date tutorial on making trees or tell me how I could make one?

 

Much appreciated.

Posted

Are you having trouble adding your custom tree to world gen?

Are you having trouble getting textures to work?

Are you having...some other trouble?

 

What, specifically, is your problem?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Anything really, I couldn't find any recent tutorials on making trees since most of them are made with 1.4.7.

 

Right now I'm trying to make the actual tree items and then I'll read on how to add them into the world gen.

Posted

Adding to worldgen requires extending IWorldGenerator and then registering it with GameRegistry.registerWorldGenerator(...)

 

As for generating the tree shapes, take a look at net.minecraft.world.feature.WorldGenTrees.java

That class is pretty much everything you'd need, you just have to tweak the blockID and metadata values to that of your own blocks.

(Note: there should be a way to register a new wood type, but I don't know how.  Haven't gotten that far! ^..^; )

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well, as far as making blocks go I'm good. But I don't understand how to add the textures for a log since the top and bottom are different to the sides.

 

I'll look into that class, thank you. :)

Posted

Well, as far as making blocks go I'm good. But I don't understand how to add the textures for a log since the top and bottom are different to the sides.

 

Take a look at BlockLog.java....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Take a look at BlockLog.java....

 

I'm looking at it, assuming I also need to extend my block from it.

 

package mods.nl.dabananaboat.projectbanana.common;

import net.minecraft.block.BlockLog;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;

public class BlockBananaLog extends BlockLog
{
public BlockBananaLog(int id)
{
	super(id);
}
}

 

Do I then use this.getBlockTextureFromSide(par1) to set the textures, seeing there is no setter version of it?

Posted

Okay, so I made the textures and after looking around a bit I found that I needed to use

 

public Icon getBlockTextureFromSideAndMetadata(int side, int meta)

 

It now runs perfectly until I want to move to the block itself, at which point it'll crash.

 

Looking at the console, it said it got a NullPointerException.

The error is:

 

java.lang.NullPointerException
at net.minecraft.block.BlockLog.getIcon(BlockLog.java:117)
at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8146)
at net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem(RenderBlocks.java:8095)
at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:367)
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:443)
at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:412)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:128)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:43)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:664)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1021)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:870)
at net.minecraft.client.Minecraft.run(Minecraft.java:759)
at java.lang.Thread.run(Unknown Source)

 

Here is the full log:

https://www.dropbox.com/s/ol9jcqbq8xs0kou/crash-2013-05-17_22.25.46-client.txt

 

 

My log class is:

 

package mods.nl.dabananaboat.projectbanana.common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockLog;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;

public class BlockBananaLog extends BlockLog
{
private Icon sides, top, bottom;

public BlockBananaLog(int id)
{
	super(id);
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg)
{
	this.top = reg.registerIcon("nl/dabananaboat/projectbanana:BananaTreeTop");
	this.sides = reg.registerIcon("nl/dabananaboat/projectbanana:BananaTreeSides");
	this.bottom = reg.registerIcon("nl/dabananaboat/projectbanana:BananaTreeBottom");
}

public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
	if(side == 0)
		return this.bottom;

	else if(side == 1)
		return this.top;

	else
		return this.sides; 
}

}

 

And to load everything in the main class:

 

// LOAD ITEMS
private void loadItems()
{
banana = new ItemBanana(bananaID, 3, 0.3F, false).setUnlocalizedName("Banana");
bananaPeel = new ItemBananaPeel(bananaPeelID).setUnlocalizedName("BananaPeel");
}

// LOAD BLOCKS
private void loadBlocks()
{
bananaLog = new BlockBananaLog(bananaLogID).setUnlocalizedName("BananaLog");
}

// Register languages
private void registerLanguages()
{
// Items
LanguageRegistry.addName(banana, "Banana");
LanguageRegistry.addName(bananaPeel, "Banana Peel");

// Blocks
LanguageRegistry.addName(bananaLog, "Banana Log");
}

// Register items for game
private void registerGame()
{
// Items
GameRegistry.registerItem(banana, "Banana");
GameRegistry.registerItem(bananaPeel, "BananaPeel");

// Blocks
GameRegistry.registerBlock(bananaLog, "BananaLog");
}

 

I truely have no idea what I did wrong.

Posted

You're not registering your icons properly.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You're not registering your icons properly.

 

How do I register them then? I don't understand how to.

 

http://lmgtfy.com/?q=Icons+and+Textures+Forge

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I got it to work-ish.

 

The block is now in the game, but all sides are rendered by the blockIcon

 

LXQem1y.png

 

After following a few links from that search (thanks for the sarcasm btw, I look all over fyi), I got to this:

 

public class BlockBananaLog extends Block
{
private Icon[] textures = new Icon[2];

public BlockBananaLog(int id, Material mat)
{
	super(id, mat);
	this.setCreativeTab(CreativeTabs.tabBlock);
	this.setStepSound(Block.soundWoodFootstep);
	this.setUnlocalizedName("BananaLog");
}

@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IconRegister reg)
{
	textures[0] = reg.registerIcon("nl/dabananaboat/projectbanana:" + this.getUnlocalizedName2() + "Bottom");
	textures[1] = reg.registerIcon("nl/dabananaboat/projectbanana:" + this.getUnlocalizedName2() + "Top");
	this.blockIcon = reg.registerIcon("nl/dabananaboat/projectbanana:" + this.getUnlocalizedName2() + "Sides");
}

public Icon getBlockTextureFromSideAndMetadata(int side, int meta)
{
	if(side == 0)
		return textures[0];
	else if(side == 1)
		return textures[1];
	else
		return this.blockIcon;
}

}

 

I still don't get what I do wrong.

Posted

And for the eleventh time...

Capture.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That's exactly what I did...

 

Still, I get the block in a single texture and not as the log as I want it to be.

 

c6a49f3b37dd175f171d8db3826235f0.png

 

Sorry that I just don't understand, sometimes autism and programming don't match.

Posted

getBlockTextureFromSideAndMetadata

I'm pretty sure that method got renamed. You would have known that if you would use @Override above it.

I think it's called getIcon now

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Following tutorials it seemed to work for everyone else.

 

But changing getBlockTextureFromSideAndMetadata() to getIcon() did it for me.

 

 

Thank you very much and sorry for the bother.

Posted

That's exactly what I did...

 

No it isn't.

 

Compare and contrast

 

"DecayingWorld:green"

and

"nl/dabananaboat/projectbanana:BananaLogBottom"

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.