Jump to content

[1.10.2][Solved] Custom block model and collision boxes


ReArmedHalo

Recommended Posts

Forge: 1.10.2-12.18.1.2063

Workspace: Eclipse

Git Repo: https://github.com/CellverLimited/JADE

Issue Images: http://imgur.com/a/4K6ZG

 

Hi everyone,

 

Finally getting into some serious modding and am learning from MrCrayFish's tutorials on YT at the moment.

 

I'm trying to create a solar panel, mostly to play with custom models and such, and so far most things are going well. The bounding box is correct but the collision box is not. In the first image, you can see my player shadow is full block height over the right solar panel (the left is an EnderIO photovoltaic cell). As you can see in the second image, the bounding box is in the correct location (speaking of bounding boxes, is there a recommendation for if there should be any padding around the block or not? The EnderIO photovoltaic cell has zero padding, I have a little bit extra on the top right now)

 

When I attempt to stand on the solar panel, it pushes me off the edges and I cannot walk over it. As I am fairly new to Forge modding, I would appreciate all feedback you guys can offer me here. Copying relevant code snippets for convenience but you can view all the code in the linked github repo.

 

private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0f, 0f, 0f, 1.0f, 0.15f, 1.0f);

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

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BOUNDING_BOX;
}

@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn) {
super.addCollisionBoxToList(pos, entityBox, collidingBoxes, BOUNDING_BOX);
}

Dustin / ReArmedHalo

Link to comment
Share on other sites

I believe there is another method you need to override, I know in 1.7.10 it was:

getBlocksMovement

 

I am not sure if the name has changed.

 

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

Thanks for the link @diesieben07, I believe I am accurately doing what you are talking about but no effect. Again the bounding box looks fine but the collision box is not.

 

I removed addCollisionBoxToList method and replaced it with the getCollisionBoundingBox method; my block only has the one collision box.

 

@Draco18s, I haven't found any such method (or similar) unfortunately.

 

public class BlockSolarPanel extends Block {

private static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0f, 0f, 0f, 1.0f, 0.15f, 1.0f);

public BlockSolarPanel() {
	super(Material.ANVIL);
	setUnlocalizedName(Reference.ModBlocks.SOLAR_PANEL.getUnlocalizedName());
	setRegistryName(Reference.ModBlocks.SOLAR_PANEL.getRegistryName());
	setHardness(2.5f);
	setHarvestLevel("pickaxe", 2);
	setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.SOUTH));
	setCreativeTab(JADE.CREATIVE_TAB);
}

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

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	return BOUNDING_BOX;
}

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
	return BOUNDING_BOX;
}
//...

Dustin / ReArmedHalo

Link to comment
Share on other sites

Ah! I think I finally figured it out. Was looking through the Block class definition again and noticed two methods:

public boolean isFullBlock(IBlockState state)
public boolean isFullCube(IBlockState state)

Set both of these to false in my block class and then everything was functioning properly!

 

Only thing I noticed is that both of these methods appear to be deprecated... So I guess my question becomes: What is the proper way to handle this?

 

 

 

private static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0f, 0f, 0f, 1.0f, 0.15f, 1.0f);

public BlockSolarPanel() {
	super(Material.ANVIL);
	setUnlocalizedName(Reference.ModBlocks.SOLAR_PANEL.getUnlocalizedName());
	setRegistryName(Reference.ModBlocks.SOLAR_PANEL.getRegistryName());
	setHardness(2.5f);
	setHarvestLevel("pickaxe", 2);
	setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.SOUTH));
	setCreativeTab(JADE.CREATIVE_TAB);
}

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

@Override
public boolean isFullBlock(IBlockState state) {
	return false;
}

@Override
public boolean isFullCube(IBlockState state) {
	return false;
}

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	return BOUNDING_BOX;
}

@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
	return BOUNDING_BOX;
}

 

 

Dustin / ReArmedHalo

Link to comment
Share on other sites

Only thing I noticed is that both of these methods appear to be deprecated... So I guess my question becomes: What is the proper way to handle this?

 

That is the proper way.  @Deprecated means "do not invoke this" not "this is not used."

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

That is the proper way.  @Deprecated means "do not invoke this" not "this is not used."

 

Oh... This might sound stupid but could you explain this a bit more? My Java knowledge isn't that great and most of said knowledge comes from building Bukkit plugins a few years back. I'm more of a web developer... :)

 

I thought that deprecated meant that the method was being phased out (usually in favor of a new/different method) and that it, one day, would be removed from the source? I suppose I don't understand the difference between "do not invoke this" and "this is not used" as that seems to be the same thing to me.

 

If you could, I've been googling this one a bit already with no real answer yet, explain the difference between isFullCube and isFullBlock as the basically sound like they would do the same thing. The source definition doesn't leave any comments sadly.

 

Appreciate your assistance

Dustin / ReArmedHalo

Link to comment
Share on other sites

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

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.