mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fixed AIOT tilling and flattening.
This commit is contained in:
parent
a6f50e2f3a
commit
4d3ba552eb
1 changed files with 16 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.DiggerItem;
|
import net.minecraft.world.item.DiggerItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -8,12 +9,24 @@ import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.item.enchantment.Enchantment;
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.ToolAction;
|
import net.neoforged.neoforge.common.ToolAction;
|
||||||
import net.neoforged.neoforge.common.ToolActions;
|
import net.neoforged.neoforge.common.ToolActions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AllInOneTool extends DiggerItem {
|
public class AllInOneTool extends DiggerItem {
|
||||||
private final Tier tier;
|
private final Tier tier;
|
||||||
|
|
||||||
|
private static List<ToolAction> ACTIONS = List.of(
|
||||||
|
ToolActions.AXE_DIG,
|
||||||
|
ToolActions.HOE_DIG,
|
||||||
|
ToolActions.PICKAXE_DIG,
|
||||||
|
ToolActions.SHOVEL_DIG,
|
||||||
|
ToolActions.HOE_TILL,
|
||||||
|
ToolActions.SHOVEL_FLATTEN
|
||||||
|
);
|
||||||
|
|
||||||
public AllInOneTool(Tier tier) {
|
public AllInOneTool(Tier tier) {
|
||||||
super(
|
super(
|
||||||
4.0f,
|
4.0f,
|
||||||
|
@ -30,7 +43,7 @@ public class AllInOneTool extends DiggerItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
|
public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
|
||||||
if (toolAction == ToolActions.AXE_DIG || toolAction == ToolActions.HOE_DIG || toolAction == ToolActions.PICKAXE_DIG || toolAction == ToolActions.SHOVEL_DIG)
|
if (ACTIONS.contains(toolAction))
|
||||||
return true;
|
return true;
|
||||||
return super.canPerformAction(stack, toolAction);
|
return super.canPerformAction(stack, toolAction);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +57,8 @@ public class AllInOneTool extends DiggerItem {
|
||||||
|
|
||||||
// Player not sneaking? Act as a Hoe to the block, else, Act as a shovel
|
// Player not sneaking? Act as a Hoe to the block, else, Act as a shovel
|
||||||
if (!context.getPlayer().isCrouching()) {
|
if (!context.getPlayer().isCrouching()) {
|
||||||
|
BlockState toolModifiedState = context.getLevel().getBlockState(context.getClickedPos()).getToolModifiedState(context, ToolActions.HOE_TILL, false);
|
||||||
|
ActuallyAdditions.LOGGER.info("Tool Modified State: " + toolModifiedState);
|
||||||
return Items.IRON_HOE.useOn(context);
|
return Items.IRON_HOE.useOn(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue