Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

When I right-click on my object it is meant to change the block's model to be open (it's a wardrobe with doors that open). But instead my hand does the interaction animation to indicate that I have right-clicked the block yet the model doesn't change to 'oak_wardrobe_closed'.

 

In the blockstate of the wardrobe I have the 3 different possible situations: the open variable is true, false or does not exist/work for some reason and therefore resorts to the normal tag.  I know that the problem is due to the blockstate not being able to read the open variable's value and therefore resorting to the normal tag. This is confirmed by the fact that I receieve an error when I don't have that tag, and also because the default model in-game is always the same as the tag. 

 

 

{
    "variants": {
        "normal": { "model": "odm:oak_wardrobe_closed" },
        "open=false": { "model": "odm:oak_wardrobe_closed" },
        "open=true": { "model": "odm:oak_wardrobe_open" }
    }
}

 

 

Then in the BlockWardrobe class I have created a public boolean called open which is what I want the blockstate to be checking for the value of.

 

public class BlockWardrobe extends Block {

public boolean open = false;

public BlockWardrobe(Material materialIn) {
	super(materialIn);
	this.setCreativeTab(OddmentsMod.tabOddments);
}

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

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

public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
	if (open == true) open = false; else open = true;
	return true;
}
}

 

I don't know whether this is a problem with my lack of Java knowledge or Minecraft method knowledge - or perhaps both.

 

I am aware that I'm not making the open variable unique for each instance and am pretty sure that I should be doing that in the constructor. But for now I'm just trying to get something basic working.

 

You shouldn't have any variables inside the

Block

class which you don't want to be shared. You'd want to use a

PropertyBool

.

 

You should read this to get a better understanding of block states and how to use them.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Look at the vanilla fence-gate for an example of open and close (but ignore the in-wall property). You will need to override several methods pertaining to properties.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.