Jump to content

1.12.2 How to make a block face a certain direction based on how you place it


8-Bit KitKat

Recommended Posts

Hello, I have been searching everywhere for info on how to do this, I've tried several things similar to this in my blocks blockstate json

 
 
 
Spoiler

{
    "variants": {
        "facing=north": { "model": "modid:model" },
        "facing=south": { "model": "modid:model", "y": 180 },
        "facing=west":  { "model": "modid:model", "y": 270 },
        "facing=east":  { "model": "modid:model", "y": 90 }
    }
}

 

Several posts have suggested looking at the Minecraft source code but I really have only had one idea on how to do that, it being that "It's a library in eclipse". I've tried my best looking for it but can't find it.

Another thing I've tried is adding this override to my block's code:

 
 
 
Spoiler

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

 

But could not get FACING to work. I later found this when trying to fix the facing issue:

 
 
 
Spoiler

protected BlockState createBlockState()
{
	return new BlockState(this, new IProperty[]{FACING});
}

 

But none of this has worked, so I've come here to ask for help.

Link to comment
Share on other sites

1 hour ago, 8-Bit KitKat said:

Several posts have suggested looking at the Minecraft source code but I really have only had one idea on how to do that, it being that "It's a library in eclipse". I've tried my best looking for it but can't find it.

Controlling how blocks face are configured in blockstates and model [JSON] files,

In the Eclipse "Package Explorer" view, look for Referenced Libraries -> Forge Src 1.12 ... -> assets.minecraft.blockstates --> 'birch_log.json' for an Example (Birch Logs)

The models listed can be found in assets.minecraft.models.block

 

The base Class for logs is in net.minecraft.block.BlockLog . which you can probably use natively or extend to get the effect you are after.

 

Basic concepts are covered here: https://mcforge.readthedocs.io/en/latest/blocks/states/ 

  • Thanks 1
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.