TechReborn / RebornCore

Reborn Core is a library used for many of the Tech Reborn team's mods, including Tech Reborn, Quantum Storage, Fluxed Redstone, Hardcore Map Reset, and many more.
MIT License
44 stars 51 forks source link

TorchHelper.placeTorch() uses item in main hand #136

Closed vhd closed 4 years ago

vhd commented 4 years ago

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