Jump to content

Recommended Posts

Posted

Hello,

 

I'm working on a mod that adds ladders for the different wood variants.

 

To achieve this I've subclassed BlockLadder, by subclass is super simple:

 

public class BlockLadder extends net.minecraft.block.BlockLadder {

public BlockLadder() {
	super();
	setHardness(0.4F);
	setStepSound(Block.soundTypeLadder);

}

}

 

The ladders render fine and I can climb them, but I don't get the normal ladder climbing sound when travelling vertically. I do get the ladder sound if I'm moving horizontally between ladders though.

 

Can anybody tell me how to trigger the ladder climbing sound? The only place I can find soundTypeLadder referenced in the Minecraft code is the Block.registerBlock method, and I'm already doing that in my constructor.

 

Thanks in advance :)

 

Chris

 

 

Posted

Hey, it wouldnt work if you just do "setStepSound()". this will mean you have to actualy walk on top of them. But since you climb a ladder it wouldnt work.

In the vanilla codes, "BlockLadder", I found this. add it to your code and see if it worked out

@Override
    public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
    {
        return true;
    }

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Posted

Hey, it wouldnt work if you just do "setStepSound()". this will mean you have to actualy walk on top of them. But since you climb a ladder it wouldnt work.

In the vanilla codes, "BlockLadder", I found this. add it to your code and see if it worked out

@Override
    public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
    {
        return true;
    }

This wouldn't change anything, because he extends BlockLadder already (he can already climb), but correct me if I am wrong!

Posted

Hey guys, thanks for the replies :)

 

Yeah, as I'm extending BlockLadder, isLadder() already returns true. Just to make 100% certain I've overridden isLadder again inside my subclass, but the result's the same - sound only works when travelling horizontally across ladders but not up and down ladders.

Posted

In the cases where you extend a class but it isn't being recognized as that class in Minecraft code, it is usually due to the fact that the Minecraft code must being doing a comparison with the actual instance (Blocks.ladder) instead of checking for instanceof BlockLadder. Your custom class will never test true against Blocks.ladder.

 

You may have to play the sound yourself by checking if player is moving on it. Might be easy or might be tricky, not sure.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.