Jump to content

Recommended Posts

Posted

Hey,

 

I am making a custom grass block for my dimension, I have it all working apart from the top side texture.

 

I am wondering how to solve this

 

here is the code for the Frosted Grass:

 

package assassinhero.parallelworlds.common.blocks;

import java.util.Random;

import assassinhero.parallelworlds.ParallelWorldsMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockFrostedGrassBlock extends Block{

public BlockFrostedGrassBlock(int par1, Material par2Material) {
	super(par1, par2Material);
	setCreativeTab(CreativeTabs.tabBlock);
	setHardness(5.0F);
}

public void registerIcons(IconRegister par1iconregister){
	this.blockIcon = par1iconregister.registerIcon("ParallelWorlds:FrostedGrass");
}

public int idDropped(int par1, Random par2Random, int par3){
	return ParallelWorldsMain.FrostedDirt.blockID;


}

public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (!par1World.isRemote)
        {
            if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
            {
                par1World.setBlock(par2, par3, par4, ParallelWorldsMain.FrostedDirt.blockID);
            }
            else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
            {
                for (int l = 0; l < 4; ++l)
                {
                    int i1 = par2 + par5Random.nextInt(3) - 1;
                    int j1 = par3 + par5Random.nextInt(5) - 3;
                    int k1 = par4 + par5Random.nextInt(3) - 1;
                    int l1 = par1World.getBlockId(i1, j1 + 1, k1);

                    if (par1World.getBlockId(i1, j1, k1) == ParallelWorldsMain.FrostedDirt.blockID && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)
                    {
                        par1World.setBlock(i1, j1, k1, ParallelWorldsMain.FrostedGrass.blockID);
                    }
                }
            }
        }
    }

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return ParallelWorldsMain.FrostedGrass;
        }
        else if (par5 == 0)
        {
            return ParallelWorldsMain.FrostedGrass.getBlockTextureFromSide(par5);
        }

}
}

 

I don't know what to return on this line

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return ParallelWorldsMain.FrostedGrass;

 

STOP CRUCIFYING NEW MODDERS!!!!

Posted

Well.  What you're doing is if the side == 1 (the top face) you return the texture.

 

But if it isn't 1, you then call that function again passing the same side value, causing an infinite recursion loop (if side isn't top, repeat).

 

If you look at the regular grass, you'll see that it returns a top face, a side face, or it references BlockDirt for the last (bottom) face.

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

So how would I use a custom grass top?

 

Use a second icon?

 

Look at TNT or pumpkins.

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

what do you have for the code so far?

 

package assassinhero.parallelworlds.common.blocks;

import java.util.Random;

import assassinhero.parallelworlds.ParallelWorldsMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockFrostedGrassBlock extends Block{

public BlockFrostedGrassBlock(int par1, Material par2Material) {
	super(par1, par2Material);
	setCreativeTab(CreativeTabs.tabBlock);
	setHardness(5.0F);
}

public void registerIcons(IconRegister par1iconregister){
	this.blockIcon = par1iconregister.registerIcon("ParallelWorlds:FrostedGrass");
	 this.blockIcon = par1iconregister.registerIcon("ParallelWorlds:FrostedGrassTop");
}

public int idDropped(int par1, Random par2Random, int par3){
	return ParallelWorldsMain.FrostedDirt.blockID;


}

public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (!par1World.isRemote)
        {
            if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
            {
                par1World.setBlock(par2, par3, par4, ParallelWorldsMain.FrostedDirt.blockID);
            }
            else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
            {
                for (int l = 0; l < 4; ++l)
                {
                    int i1 = par2 + par5Random.nextInt(3) - 1;
                    int j1 = par3 + par5Random.nextInt(5) - 3;
                    int k1 = par4 + par5Random.nextInt(3) - 1;
                    int l1 = par1World.getBlockId(i1, j1 + 1, k1);

                    if (par1World.getBlockId(i1, j1, k1) == ParallelWorldsMain.FrostedDirt.blockID && par1World.getBlockLightValue(i1, j1 + 1, k1) >= 4 && par1World.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)
                    {
                        par1World.setBlock(i1, j1, k1, ParallelWorldsMain.FrostedGrass.blockID);
                    }
                }
            }
        }
    }

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
        	
        }
        else if (par5 == 0)
        {
            return ParallelWorldsMain.FrostedGrass.getBlockTextureFromSide(par5);
        }

}
}

STOP CRUCIFYING NEW MODDERS!!!!

Posted

package assassinhero.parallelworlds.common.blocks;

public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
        	return TOP_OF_BLOCK
        }
        else if (par5 == 0)
        {
            return ParallelWorldsMain.FrostedGrass.getBlockTextureFromSide(par5); // <-- is this the texture for the bottom of the block?
        }
        return SIDE_OF_BLOCK

}

Posted
	this.blockIcon = par1iconregister.registerIcon("ParallelWorlds:FrostedGrass");
	 this.blockIcon = par1iconregister.registerIcon("ParallelWorlds:FrostedGrassTop");

 

int a;

a = 5;

a = 10;

 

What is the value of a?

 

(Hint: you need two variables)

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

Still in need of help here

 

Try reading my last post.

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

I did read it and it really didn't help

 

Answer the question.

 

What is the value of a?

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

I really dont know

 

Then I cannot help you.

What the fuck is a variable and how do I use it?  Java basics.

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

it would be nice if you didnt constantly drop hints, it would be better if you told me how to do it then i can implement it

 

I will not write your code for you.  I pointed out where the issue was, if you don't know why it's wrong, then you have to go back to the basics, or you'll be asking the same question again later.

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 need basic java knowledge to atleast get going on modding, its tough for people to help you out if you cannot figure out that int a cannot be 5 and 10 at the same time

Posted

If I am right you want to get grass like in vanilia (Top Grass, Bottom Dirt, Side Grass-Drit).

Here is how you do it: (how I done it)

1. In the beginning you add:

@SideOnly(Side.CLIENT)
private Icon TextureTop; //Top of grass
@SideOnly(Side.CLIENT)
private Icon TextureBottom; //Bottom of grass

Since extending Block alredy gives you Side Texture you don't need to create it.

2. Now you register icons:

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	this.blockIcon = par1IconRegister.registerIcon("YourMod:Block_Side");
	this.TextureTop = par1IconRegister.registerIcon("YourMod:Block_Top");
	this.TextureBottom = par1IconRegister.registerIcon("YourMod:Block_Bottom");
}

I don't know if it can be more clear...

3. Now you actually getIcon:

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	return par1 == 1 ? this.TextureTop : par1 == 0 ? this.TextureBottom : this.blockIcon; // 1 - Top, 0 - Bottom, else: Side
}

If you cannot understand this, I don't know if any coder on the world can help you...

Hope you use your brain next time - just look into files, or do researches, there are sooooo many open sources!

Best regards,

Ernio

 

1.7.10 is no longer supported by forge, you are on your own.

Posted

If I am right you want to get grass like in vanilia (Top Grass, Bottom Dirt, Side Grass-Drit).

Here is how you do it: (how I done it)

1. In the beginning you add:

@SideOnly(Side.CLIENT)
private Icon TextureTop; //Top of grass
@SideOnly(Side.CLIENT)
private Icon TextureBottom; //Bottom of grass

Since extending Block alredy gives you Side Texture you don't need to create it.

2. Now you register icons:

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
	this.blockIcon = par1IconRegister.registerIcon("YourMod:Block_Side");
	this.TextureTop = par1IconRegister.registerIcon("YourMod:Block_Top");
	this.TextureBottom = par1IconRegister.registerIcon("YourMod:Block_Bottom");
}

I don't know if it can be more clear...

3. Now you actually getIcon:

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2)
{
	return par1 == 1 ? this.TextureTop : par1 == 0 ? this.TextureBottom : this.blockIcon; // 1 - Top, 0 - Bottom, else: Side
}

If you cannot understand this, I don't know if any coder on the world can help you...

Hope you use your brain next time - just look into files, or do researches, there are sooooo many open sources!

Best regards,

Ernio

 

Ahhh Right, Now i see :)

STOP CRUCIFYING NEW MODDERS!!!!

Posted

Now you copy paste again, I bet you don't "see" anything!

That's why I say: don't post complete code.

that's why I tend to give out pseudo-complete code, where I leave the coder to finish the stuff that requires their code, but I give them the main part. But that's a last resort, I try not to do that.

Posted

Ahhh Right, Now i see :)

Now you copy paste again, I bet you don't "see" anything!

That's why I say: don't post complete code.

 

That's fucking funny NOT. I actually did see what to do and I actually learnt something, this is how I learn, Now get a fucking grip

STOP CRUCIFYING NEW MODDERS!!!!

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.