Jump to content

[1.8.9] Custom ladder?


DuckCreeper

Recommended Posts

Hello! I'm currently trying to make a custom ladder, and well, I can get 90% of it to work. The only part I cant do is actually making it function as a ladder. In the

Block Ladder

class of minecraft. It has the override method of

isLadder

. But when I try to apply it in my block class. It doesn't work. Also extending my class to BlockLadder causes my block to have the same properties as a ladder. The placement rules, block bound, etc. I just want the isLadder method to work in my class.

 

isLadder method

    @Override public boolean isLadder(IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return true; }

 

If more code is needed. Please feel free to ask.

Link to comment
Share on other sites

Don't have access to the code right now, but you may want to take a look at the other methods in the BlockLadder class, specifically the two #onEntityCollidedWithBlock methods. I believe that is where motionY is added the climbing entity, but if not, then you can use your IDE's search function to find the locations of BlockLadder and Blocks.ladder (or whatever it is called) in the code and inspect those to find out how ladders function.

Link to comment
Share on other sites

So now I'm trying to make a custom ladder model when the ladder is by itself and one when its connected to another texture. I've looked at the cobblestone wall code and did pretty much what it said. But in the blockstates file for it. It had this

{
    "variants": {
        "east=false,north=false,south=false,up=false,west=false": { "model": "cobblestone_wall_post" },
        "east=false,north=true,south=false,up=false,west=false":  { "model": "cobblestone_wall_n" },
        "east=true,north=false,south=false,up=false,west=false":  { "model": "cobblestone_wall_n", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=false,west=false":  { "model": "cobblestone_wall_n", "y": 180, "uvlock": true },
        "east=false,north=false,south=false,up=false,west=true":  { "model": "cobblestone_wall_n", "y": 270, "uvlock": true },
        "east=true,north=true,south=false,up=false,west=false":   { "model": "cobblestone_wall_ne" },
        "east=true,north=false,south=true,up=false,west=false":   { "model": "cobblestone_wall_ne", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=false,west=true":   { "model": "cobblestone_wall_ne", "y": 180, "uvlock": true },
        "east=false,north=true,south=false,up=false,west=true":   { "model": "cobblestone_wall_ne", "y": 270, "uvlock": true },
        "east=false,north=true,south=true,up=false,west=false":   { "model": "cobblestone_wall_ns" },
        "east=true,north=false,south=false,up=false,west=true":   { "model": "cobblestone_wall_ns", "y": 90, "uvlock": true },
        "east=true,north=true,south=true,up=false,west=false":    { "model": "cobblestone_wall_nse" },
        "east=true,north=false,south=true,up=false,west=true":    { "model": "cobblestone_wall_nse", "y": 90, "uvlock": true },
        "east=false,north=true,south=true,up=false,west=true":    { "model": "cobblestone_wall_nse", "y": 180, "uvlock": true },
        "east=true,north=true,south=false,up=false,west=true":    { "model": "cobblestone_wall_nse", "y": 270, "uvlock": true },
        "east=true,north=true,south=true,up=false,west=true":     { "model": "cobblestone_wall_nsew" },
        "east=false,north=false,south=false,up=true,west=false":  { "model": "cobblestone_wall_post" },
        "east=false,north=true,south=false,up=true,west=false":   { "model": "cobblestone_wall_n" },
        "east=true,north=false,south=false,up=true,west=false":   { "model": "cobblestone_wall_n", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=true,west=false":   { "model": "cobblestone_wall_n", "y": 180, "uvlock": true },
        "east=false,north=false,south=false,up=true,west=true":   { "model": "cobblestone_wall_n", "y": 270, "uvlock": true },
        "east=true,north=true,south=false,up=true,west=false":    { "model": "cobblestone_wall_ne" },
        "east=true,north=false,south=true,up=true,west=false":    { "model": "cobblestone_wall_ne", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=true,west=true":    { "model": "cobblestone_wall_ne", "y": 180, "uvlock": true },
        "east=false,north=true,south=false,up=true,west=true":    { "model": "cobblestone_wall_ne", "y": 270, "uvlock": true },
        "east=false,north=true,south=true,up=true,west=false":    { "model": "cobblestone_wall_ns_above" },
        "east=true,north=false,south=false,up=true,west=true":    { "model": "cobblestone_wall_ns_above", "y": 90, "uvlock": true },
        "east=true,north=true,south=true,up=true,west=false":     { "model": "cobblestone_wall_nse" },
        "east=true,north=false,south=true,up=true,west=true":     { "model": "cobblestone_wall_nse", "y": 90, "uvlock": true },
        "east=false,north=true,south=true,up=true,west=true":     { "model": "cobblestone_wall_nse", "y": 180, "uvlock": true },
        "east=true,north=true,south=false,up=true,west=true":     { "model": "cobblestone_wall_nse", "y": 270, "uvlock": true },
        "east=true,north=true,south=true,up=true,west=true":      { "model": "cobblestone_wall_nsew" }
    }
}

So I tried this for myself. But the in-game model wont load. Here is the error I get.

[16:11:25] [Client thread/ERROR] [FML]: Model definition for location scm:scaffolding_ladderr#east=false,facing=west,north=true,south=true,up=false,west=false not found
[16:11:25] [Client thread/ERROR] [FML]: Model definition for location scm:scaffolding_ladderr#east=false,facing=south,north=true,south=false,up=false,west=true not found
[16:11:25] [Client thread/ERROR] [FML]: Model definition for location scm:scaffolding_ladderr#east=true,facing=east,north=false,south=true,up=false,west=true not found
[16:11:25] [Client thread/ERROR] [FML]: Model definition for location scm:scaffolding_ladderr#east=true,facing=south,north=false,south=true,up=false,west=false not found

 

 

Here is my blockstate code.

{
    "variants":  {
    "east=false,north=false,south=true,up=false,west=false": { "model": "scm:scaffolding_ladderr_regular", "y": 90},
    "east=false,north=false,south=false,up=false,west=true": { "model": "scm:scaffolding_ladderr_regular", "y": 180},
    "east=false,north=true,south=false,up=false,west=false": { "model": "scm:scaffolding_ladderr_regular", "y": 270},  
    "east=false,north=false,south=false,up=false,west=false": { "model": "scm:scaffolding_ladderr_regular"},
    "east=true,north=false,south=false,up=false,west=false": { "model": "scm:scaffolding_ladderr_regular"}, 
    "east=false,north=false,south=false,up=true,west=false": {"model": "scm:scaffolding_ladderr"},
    "east=true,north=false,south=false,up=true,west=false": {"model": "scm:scaffolding_ladderr"},
    "east=false,north=false,south=true,up=true,west=false": { "model": "scm:scaffolding_ladderr", "y": 90},
    "east=false,north=false,south=false,up=true,west=true": { "model": "scm:scaffolding_ladderr", "y": 180},
    "east=false,north=true,south=false,up=true,west=false": { "model": "scm:scaffolding_ladderr", "y": 270}  
    }
}

 

I don't know what to do!

Link to comment
Share on other sites

And your BlockState enum?

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.

Link to comment
Share on other sites

And your BlockState enum?

 

What is that? :P I'm having a huge brainfart right now :P

 

Here is my block class for the custom ladder:

 

public class scaffolding_ladderr extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool WEST = PropertyBool.create("west");



public scaffolding_ladderr(Material materialIn) {
	super(Material.wood);
	this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
//		this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.2F, 1.0F);
	this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.4F);

}

@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
	IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer);
	state = state.withProperty(FACING, placer.getHorizontalFacing());
	return state;
}

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return state.withProperty(UP, Boolean.valueOf(!world.isAirBlock(pos.up()))).withProperty(NORTH, Boolean.valueOf(isScaffoldingLadder(world, pos.north()))).withProperty(EAST, Boolean.valueOf(isScaffoldingLadder(world, pos.east()))).withProperty(SOUTH, Boolean.valueOf(isScaffoldingLadder(world, pos.south()))).withProperty(WEST, Boolean.valueOf(isScaffoldingLadder(world, pos.west())));
}


@Override
protected BlockState createBlockState()
{
	return new BlockState(this, new IProperty[] { NORTH, EAST, SOUTH, WEST, FACING, UP });
}

public boolean isScaffoldingLadder(IBlockAccess world, BlockPos pos)
{
	return world.getBlockState(pos).getBlock() == this;
}

 public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this)
        {
            float f = 0.125F;

            switch ((EnumFacing)iblockstate.getValue(FACING))
            {
                case NORTH:
                    this.setBlockBounds(0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.2F);
                    break;
                case SOUTH:
            		this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.2F);
//	                    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
                    break;
                case WEST:
                    this.setBlockBounds(0.8F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
                    break;
                case EAST:
                default:
                    this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.2F, 1.0F, 1.0F);
            }
        }
    }


@Override
public int getMetaFromState(IBlockState state)
{
	return ((EnumFacing) state.getValue(FACING)).getHorizontalIndex();
}

  @Override
public boolean isOpaqueCube() {
	  return false;
}
  
  @Override
public boolean isFullCube() {
	  return false;
}
  
  @Override
public boolean isLadder(IBlockAccess world, BlockPos pos,
		EntityLivingBase entity) {
	return true;
}

}

Link to comment
Share on other sites

You might be having issues because you created your own Boolean values for each of the directions, when those already exist as EnumFacing. Delete these lines:

public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool WEST = PropertyBool.create("west");

And change any references to them to use EnumFacing.WHATEVER_DIRECTION instead.

Link to comment
Share on other sites

ladders don't work as you might expect.

 

what you need to do is to override isLadder method on the block and return true, and then your block will behave like vanilla ladder.... if it is so small that the player is inside the block space. that lame thing is hardcoded into mc code. by inside i mean player's x,z coordinate being the same as the block's.

 

you said "this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.4F);"... that's almost half the block. maybe that's small enough, i don't know... but you can't climb from sides...

 

you can even do full side ladder - i made a 0.8 wide tree log climbable from all 4 sides with no code except the isLadder override  - but the thing is, user needs to enable that behavior in forge settings (it can be done in game (from the main menu -> mods button), no need to edit config files). oh well.

Link to comment
Share on other sites

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.