Skip to content

Commit

Permalink
Merge pull request Vivecraft#64 from fayer3/fix-scythe
Browse files Browse the repository at this point in the history
fix scythe/hoes opening chest/intractable blocks
  • Loading branch information
fayer3 authored Oct 30, 2022
2 parents cf97296 + f0efead commit e8f05ff
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.*;
import org.vivecraft.ClientDataHolder;
import org.vivecraft.api.BlockTags;
Expand Down Expand Up @@ -253,20 +254,20 @@ else if (!itemstack.isEmpty())
{
int j = 3;

if ((item instanceof HoeItem || itemstack.is(ItemTags.VIVECRAFT_HOES) || itemstack.is(ItemTags.VIVECRAFT_SCYTHES)) && (
blockstate.getBlock() instanceof CropBlock
|| blockstate.getBlock() instanceof StemBlock
|| blockstate.getBlock() instanceof AttachedStemBlock
|| blockstate.is(BlockTags.VIVECRAFT_CROPS)
|| this.mc.gameMode.useItemOn(player, (ClientLevel)player.level, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1).shouldSwing()))
if ((item instanceof HoeItem || itemstack.is(ItemTags.VIVECRAFT_HOES) || itemstack.is(ItemTags.VIVECRAFT_SCYTHES)) && (
blockstate.getBlock() instanceof CropBlock
|| blockstate.getBlock() instanceof StemBlock
|| blockstate.getBlock() instanceof AttachedStemBlock
|| blockstate.is(BlockTags.VIVECRAFT_CROPS)
// check if the item can use the block
|| item.useOn(new UseOnContext(player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1)).shouldSwing()))
{
// don't try to break crops with hoes
if (itemstack.is(ItemTags.VIVECRAFT_SCYTHES)) {
// some scythes need to be used on crops
if (!this.mc.gameMode.useItemOn(player, (ClientLevel) player.level, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1).shouldSwing()) {
// some scythes just need to be used
this.mc.gameMode.useItem(player, player.level, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
}
// actually use the item on the block
boolean useSuccessful = this.mc.gameMode.useItemOn(player, (ClientLevel)player.level, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1).shouldSwing();
if (itemstack.is(ItemTags.VIVECRAFT_SCYTHES) && !useSuccessful) {
// some scythes just need to be used
this.mc.gameMode.useItem(player, player.level, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
}
}
else if (blockstate.getBlock() instanceof NoteBlock || blockstate.is(BlockTags.VIVECRAFT_MUSIC_BLOCKS))
Expand Down

0 comments on commit e8f05ff

Please sign in to comment.