Jump to content

Recommended Posts

Posted

Back here again with yet another question: how could I create a 3-block tall door using the similar technique that's used in forge for making the 2-block tall door?

I've looked through the class files and found that there's a relationship between the state.properties packages that involve Half.java and DoubleBlockHalf.java, as well as their respective enums for handling. Inside the DoorBlock.java, there are methods that contain post-placement logic that makes sense in the 2-block tall standard, and should apply theoretically for the next block above for the very top, but upon investigation, it turns out that my only means of creating this door is to create whole new properties and functions that draw out this new door.

 

My plan so far is to make new enums that store both "upper", "middle" and "lower" and top, mid, and bottom in my new package for my mod inside com.[myname].[mymod].states.properties. From there, I'll need to make a blockbase much like the DoorBlock.java that utilizes similar properties, but must also include post-place logic to place 2 more blocks above the bottom piece. How could I go about doing this? Or am I missing other important methods/classes?

Posted
30 minutes ago, shadowdragon625 said:

it turns out that my only means of creating this door is to create whole new properties and functions that draw out this new door.

Correct.

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.

Posted
8 minutes ago, Draco18s said:

Correct.

I figured that was the case. At least I can pinpoint what I need to make this new door; actually implementing that is going to be complicated for me but I'll try.

Thanks for the confirmation.

Posted (edited)

Update:

 

So I have pinpointed possible routes that I can take, but I am unsure of how to modify them.

Right now, I believe that in order for me to create the third texture block on top of the other two (default behavior), I must adjust the onBlockPlacedBy method accordingly to add in the third block. I understand that the issue has something to do with rendering, but I am unsure of how to get it to work as intended (with a transparent top door frame with slits like a regular door, just taller.)

 

Using this code below (as I have included the necessary enums), how could I go about adding the third and final block on top of the other two that have already spawned? I have changed other properties that were more-so important to getting the program to recognize this new block, yet the third block never renders. Not even the purple and black boxes.

 

public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
			TripleBlockThirds tripleblockthirds = stateIn.get(THIRDS);
			if (facing.getAxis() == Direction.Axis.Y && tripleblockthirds == TripleBlockThirds.LOWER == (facing == Direction.UP)) {
				return facingState.getBlock() == this && facingState.get(THIRDS) != tripleblockthirds ? stateIn.with(FACING, facingState.get(FACING)).with(OPEN, facingState.get(OPEN)).with(HINGE, facingState.get(HINGE)).with(POWERED, facingState.get(POWERED)) : Blocks.AIR.getDefaultState();
			} else {
				return tripleblockthirds == TripleBlockThirds.LOWER && facing == Direction.DOWN && !stateIn.isValidPosition(worldIn, currentPos) ? Blocks.AIR.getDefaultState() : super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
			}
		}

@Override
		public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
			worldIn.setBlockState(pos.up(), state.with(THIRDS, TripleBlockThirds.UPPER));
		}


 

2020-12-21_06.21.04.png

Edited by shadowdragon625
Forgot to add another essential method that is an essential candidate for a fix.
  • 2 weeks later...
  • 1 year later...
Posted

react to neighbour change in your block class. check the block below. if it's the same block, set the opened/closed state to the state of the block below.

on use (right click) do not change state right away - iterate down and change state of the bottommost block.

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.