Reborn Core

Reborn Core

91M Downloads

TorchHelper.placeTorch() uses item in main hand

vhd opened this issue ยท 0 comments

commented

This can be easily reproduced with TR omni-tool. If you right click on block it will be voided.
That's because ItemUsageContext constructor set's stack to player.getStackInHand(hand).
Current workaround is to make custom class like this

public class ItemUsageContextCustomStack extends ItemUsageContext {

	public ItemUsageContextCustomStack(World world, @Nullable PlayerEntity player, Hand hand, ItemStack stack, BlockHitResult hit) {
		super(world, player, hand, stack, hit);
	}

}

and use it like that (inside TorchHelper.placeTorch())

ItemUsageContext context = new ItemUsageContextCustomStack(itemUsageContext.getWorld(),player,itemUsageContext.getHand(),torchStack,new BlockHitResult(itemUsageContext.getHitPos(), itemUsageContext.getSide(), itemUsageContext.getBlockPos(), true));

My current dirty fix for TR omnitool
Omni-tool_fix.patch.txt