Jump to content

Recommended Posts

Posted

Hi! I am trying to make a streetcar track as a part of my European cities mod (basically the track is a whole block instead of on top of another block). I have tried a LOT of stuff and finally succesfully changed the collision box BUT, It still doesn't render correctly. I use the code I usually use for multi-textured blocks. The issue is just that the game STILL thinks it is a normal track. (I have changed the renderType to zero). The reason I have set isOpaqueCube() and renderAsNormalBlock() false is because otherwise it looks even more messed up. I guess I will just change that back if I get this working.


public class Test extends BlockRailBase {

@SideOnly(Side.CLIENT)
    private Icon theIcon;
@SideOnly(Side.CLIENT)
private int renderType = 0;

@SideOnly(Side.CLIENT) 
    public static Icon topIcon;
    @SideOnly(Side.CLIENT)
    public static Icon bottomIcon;
    @SideOnly(Side.CLIENT)
    public static Icon sideIcon;
    

@Override
@SideOnly(Side.CLIENT)
public void setRenderType(int value)
    {
        setRenderType(0);
    }

public boolean isBlockSolid() {
	return true;
}


@Override
    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
        int l = par1IBlockAccess.getBlockMetadata(1, 1, 1);
        if (l >= 2 && l <= 5)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
        else
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        }
    }
protected Test(int par1)
    {
        super(3512, false);
       setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

public Icon getIcon(int par1, int par2)
    {	
	if(par1 == 0) {
	return bottomIcon;
	} else if(par1 == 1) {
	return topIcon;
	} else {
	return sideIcon;
	}
    }
 public void registerIcons(IconRegister par1IconRegister)
    {
        super.registerIcons(par1IconRegister);
        this.theIcon = par1IconRegister.registerIcon(this.getTextureName() + "curve");
        topIcon = par1IconRegister.registerIcon(Path);
        	bottomIcon = par1IconRegister.registerIcon(Path);
        	sideIcon = par1IconRegister.registerIcon(Path);
    }
   protected void func_94358_a(World par1World, int par2, int par3, int par4, int par5, int par6, int par7)
    {
        if (par7 > 0 && Block.blocksList[par7].canProvidePower() && (new BlockBaseRailLogic(this, par1World, par2, par3, par4)).getNumberOfAdjacentTracks() == 3)
        {
            this.refreshTrackShape(par1World, par2, par3, par4, false);
        }
    }
 public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z)
    {
        return 0.4f;
    }

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

}

 

Posted

hi

 

Since I've just started modding I'm not sure how right I am.

 

On the other hand I am coding in java for a long time now my eyes've been catched by the following:

 

public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
        int l = par1IBlockAccess.getBlockMetadata(1, 1, 1);
        if (l >= 2 && l <= 5)

 

Why do you use the blockAccess.getBlockMetadata(1,1,1) since the getBlockMetadata(x,y,z) method returns the metadata of the block at the given coordinates.

 

(Additional tip: if you override a method, you can change the name of each argument, so

getBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)

would be much easier to read, don't you think? )

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

Hi! I am trying to make a streetcar track as a part of my European cities mod (basically the track is a whole block instead of on top of another block). I have tried a LOT of stuff and finally succesfully changed the collision box BUT, It still doesn't render correctly. I use the code I usually use for multi-textured blocks. The issue is just that the game STILL thinks it is a normal track. (I have changed the renderType to zero). The reason I have set isOpaqueCube() and renderAsNormalBlock() false is because otherwise it looks even more messed up. I guess I will just change that back if I get this working.

Hi

 

A couple of questions that will help us

1) What do you expect to see?

2) What are you actually seeing? (Screenshot?)

 

-TGG

 

Posted

Pictures would be very helpfull. 

 

If you want something very unique here, why don't you just make a custom block model and render using tecne or something else as a basis? 

 

If you really just want a sided block texture, you might need to render for this type of block to the typical one.  That is a guess though.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I also started thinking of making a custom render class and so on, but that would be really hard with rotation. I may try it later though.

Posted

For a block?  Generally you don't need to rotate it.

 

In your case, you are making rail, so I assume you need east/west vs north/south.  That is just rotating the 7 90deg.  Easy.

 

Where it gets complicated is deciding on joined tracks but you already need to figure that out.  You would probably need a unique model for a few of those scenarios depending on how you handel.  Then just pass it your variable you decided which 'case' it is.

 

Of course you could just make one model and decide which parts to show based upon the case.  That is what I have done in the past.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

This is less an answer than a suggestion but - given as you are making rail, check out the vanilla handling for minecart rail. If you set the curve rules to be the same as "regular" rail then players will have an idea of how it works. You may even wish to extend the minecart rail class and just overwrite the texture assignment!

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.