Posted June 24, 20196 yr Hi, I made a custom scaffolding block and a corresponding item class that you can have a look at here: https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/blocks/WoodenScaffoldingBlock.java https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/items/WoodenScaffoldingItem.java My issue is the following: https://imgur.com/jdwOKtN Basically when I try to place a scaffolding block that is not of the same wood type as the block I aimed at, the autostacking feature doesn't work. I tracked it down to the following issue: When I use the "appropiate" scaffolding the "getBlockItemUseContext" method of my custom item is called with a BlockItemUseContext that has the position of the scaffolding block I aimed at. But if I use another wood type the function gets called with a context that contains the block that is one block off in the direction of the face I was aiming at, e.g. in the video that's an air block. This causes my "instanceof" checks in the "getBlockItemUseContext" method to fail. But I can't figure out why it's not passing the scaffolding block position in the context when it's a different wood type. Does BlockItem somehow change the logic of chosing the forwarded block position depending on whether or not the used item corresponds to the block that was registered to the BlockItem? Edited June 24, 20196 yr by Yamahari
June 24, 20196 yr https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/items/WoodenScaffoldingItem.java#L28 Oh geezus effing christ. If you're going to copy-paste vanilla code at least refactor all of the local variables so the code is fucking legible. 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.
June 24, 20196 yr Author Normally I wait until mapping catch up, but I want help so I updated the names as far as I could without intentionally changing the meaning ( I hope )
June 24, 20196 yr I think the problem is here: https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/items/WoodenScaffoldingItem.java#L57-L59 That call invokes: https://github.com/Yamahari/ILikeWood/blob/master/src/main/java/yamahari/ilikewood/blocks/WoodenScaffoldingBlock.java#L84-L86 Different wood types have different items. 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.
June 24, 20196 yr Author Omg this actually fixed it, thanks! ( You have no idea how hard I tried to fix this, I think I lost 50% of my hair ) @Override public boolean isReplaceable(BlockState blockStateIn, BlockItemUseContext blockItemUseContextIn) { //return blockItemUseContextIn.getItem().getItem() == this.asItem(); for(Block block : Constants.SCAFFOLDINGS) { if(blockItemUseContextIn.getItem().getItem() == Item.getItemFromBlock(block)) return true; } return false; } My question now is, why did this fix this, I don't get it
June 24, 20196 yr I already explained why. The item instances are different. 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.
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.