Jump to content

[1.8.9] How to check if an item can be placed?


Hawpe

Recommended Posts

I'm trying to check if an item can be placed. I started out by checking if the ItemStack is a block but it misses some items such as sugar cane, nether wart, etc. I haven't been able to find a function isPlaceable or any Interface that could be used with instanceof.

 

My code right now:

 

BlockPos blockPos = mc.objectMouseOver.getBlockPos();
ItemStack itemInUse = mc.thePlayer.getHeldItem();

if (itemInUse != null) {
    Block resultBlock = Block.getBlockFromItem(itemInUse.getItem());

    if (mc.theWorld.getBlockState(blockPos).getBlock().getMaterial() == Material.air || resultBlock == null) {
        return;
    }
}

 

Is there any function that can do what I'm trying to achieve?

Link to comment
Share on other sites

1.8 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

1 hour ago, Novârch said:

1.8 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.

I can't, this is a mod for a 1.8.9 server. Furthermore, it's not my mod, I'm adding functionality to someone's mod.

Edited by Hawpe
Link to comment
Share on other sites

Unfortunately, Forge no longer supports old version, because they are old and we can't maintain every version in perpetuity.

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

I'm not asking for you to maintain old versions though, just asking if you are aware of a way to do what I'm trying to achieve with what's currently available in 1.8.9. I don't want you to add anything new.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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