How to make Custom Ladders?

Started by Aksumite on

Topic category: Help with Minecraft modding (Java Edition)

Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make Custom Ladders?

I have the model and texture working, but the placement doesn't work how I want it to. As you know, a normal ladder can only be placed on the side of a solid block, how would I recreate this? Also, when holding the ladder it looks really weird even though I am using the official Minecraft ladder model.

Help would be appreciated :D

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Simply, I would just detect…
Sun, 05/31/2020 - 01:05

Simply, I would just detect block collision and set the entities velocity. Here is an example (I CAME UP WITH THIS CODE ON THE FLY SO TEST FOR YOURSELF)

    public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
        //System.out.println("COLLIDED");
        entityIn.setVelocity(entityIn.getMotion().x, entityIn.getMotion().y + 0.2D, entityIn.getMotion().z);
}

onEntityCollision is actually a deprecated method so this isn't really "good" code. But it still works and I am sure you could find a better method.

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am confused now? Do you…
Sun, 05/31/2020 - 01:11

I am confused now? Do you already have the method to set velocity. If you need help with the placement look below.

THIS IS A SNIPPET FROM THE LADDER BLOCK CODE AS YOU CAN SEE THE LADDER BLOCK HAS 4 COLLISON BOXES FOR EACH DIRECTION.

   protected static final VoxelShape LADDER_EAST_AABB = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);
   protected static final VoxelShape LADDER_WEST_AABB = Block.makeCuboidShape(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
   protected static final VoxelShape LADDER_SOUTH_AABB = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D);
   protected static final VoxelShape LADDER_NORTH_AABB = Block.makeCuboidShape(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D);

FOR LADDER "ATTACHING" TO A SIDE OF A BLOCK. SIMPLY THIS CHECKS IF THE BLOCK IS SOLID AND NOT LIKE REDSTONE FOR EXAMPLE.

   private boolean canAttachTo(IBlockReader p_196471_1_, BlockPos p_196471_2_, Direction p_196471_3_) {
      BlockState blockstate = p_196471_1_.getBlockState(p_196471_2_);
      return !blockstate.canProvidePower() && blockstate.isSolidSide(p_196471_1_, p_196471_2_, p_196471_3_);
   }

AND THAT METHOD IS USED HERE

   public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
      Direction direction = state.get(FACING);
      return this.canAttachTo(worldIn, pos.offset(direction.getOpposite()), direction);
   }

To end, there is a lot of other methods that LadderBlock uses. So I would look at the code yourself. But this should be a start if there isn't a method in MCreator