Compare commits

..

No commits in common. "09fa51e7d40a92d6be5b21f096ab694fdf1fa51e" and "c133f28a52dd391eb77e829a62013c4d72199ff1" have entirely different histories.

13 changed files with 106 additions and 73 deletions

View file

@ -32,6 +32,7 @@ import net.minecraft.world.item.crafting.ShapelessRecipe;
import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.common.Tags; import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.crafting.DataComponentIngredient; import net.neoforged.neoforge.common.crafting.DataComponentIngredient;
import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredItem;

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.ItemInteractionResult;

View file

@ -18,6 +18,7 @@ import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;

View file

@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.WorldData; import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.DrillItem; import de.ellpeck.actuallyadditions.mod.items.DrillItem;
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
import de.ellpeck.actuallyadditions.mod.items.ItemTag; import de.ellpeck.actuallyadditions.mod.items.ItemTag;
import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.items.Sack;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
@ -27,6 +28,7 @@ import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
@ -39,8 +41,11 @@ import net.minecraft.world.entity.monster.Spider;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.common.util.TriState; import net.neoforged.neoforge.common.util.TriState;
import net.neoforged.neoforge.event.AnvilUpdateEvent; import net.neoforged.neoforge.event.AnvilUpdateEvent;
@ -72,9 +77,40 @@ public class CommonEvents {
final BlockPos pos = event.getPos(); final BlockPos pos = event.getPos();
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (stack.getItem() instanceof DrillItem drillItem) { if (stack.getItem() instanceof DrillItem drillItem) {
boolean toReturn = drillItem.onBreakBlock(stack, pos, player); boolean toReturn = false;
if (toReturn) { int use = drillItem.getEnergyUsePerBlock(stack);
event.setCanceled(true); if (drillItem.getEnergyStored(stack) >= use) {
//Enchants the Drill depending on the Upgrades it has
if (drillItem.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) {
ItemUtil.addEnchantment(stack, level.holderOrThrow(Enchantments.SILK_TOUCH), 1, level.registryAccess());
}
else {
if (drillItem.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) {
ItemUtil.addEnchantment(stack, level.holderOrThrow(Enchantments.FORTUNE),
drillItem.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ? 3 : 1,
level.registryAccess());
}
}
//Block hit
HitResult ray = player.pick(Util.getReachDistance(player), 1f, false);
if (ray instanceof BlockHitResult trace) {
//Breaks the Blocks
if (!player.isShiftKeyDown() && drillItem.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) {
if (drillItem.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) {
toReturn = drillItem.breakBlocks(stack, 2, player.level(), pos, trace.getDirection(), player);
}
else {
toReturn = drillItem.breakBlocks(stack, 1, player.level(), pos, trace.getDirection(), player);
}
}
else {
toReturn = drillItem.breakBlocks(stack, 0, player.level(), pos, trace.getDirection(), player);
}
//Removes Enchantments added above
ItemUtil.removeEnchantment(stack, level.holderOrThrow(Enchantments.SILK_TOUCH), level.registryAccess());
ItemUtil.removeEnchantment(stack, level.holderOrThrow(Enchantments.FORTUNE), level.registryAccess());
}
} }
} }
} }

View file

@ -6,6 +6,7 @@ import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.data.worldgen.features.FeatureUtils; import net.minecraft.data.worldgen.features.FeatureUtils;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;

View file

@ -27,6 +27,7 @@ import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.UUID;
public class SackContainer extends AbstractContainerMenu implements IButtonReactor { public class SackContainer extends AbstractContainerMenu implements IButtonReactor {

View file

@ -17,8 +17,6 @@ import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -40,12 +38,10 @@ import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.component.ItemAttributeModifiers;
import net.minecraft.world.item.component.ItemContainerContents; import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ItemAbilities;
import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.ItemAbility;
import net.neoforged.neoforge.items.IItemHandler; import net.neoforged.neoforge.items.IItemHandler;
@ -53,10 +49,7 @@ import net.neoforged.neoforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID;
public class DrillItem extends ItemEnergy { public class DrillItem extends ItemEnergy {
public static final int HARVEST_LEVEL = 4; public static final int HARVEST_LEVEL = 4;
@ -184,6 +177,7 @@ public class DrillItem extends ItemEnergy {
public InteractionResultHolder<ItemStack> use(Level world, @Nonnull Player player, @Nonnull InteractionHand hand) { public InteractionResultHolder<ItemStack> use(Level world, @Nonnull Player player, @Nonnull InteractionHand hand) {
if (!world.isClientSide && player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND) { if (!world.isClientSide && player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND) {
player.openMenu(new SimpleMenuProvider((id, inv, p) -> new ContainerDrill(id, inv), Component.translatable("container.actuallyadditions.drill"))); player.openMenu(new SimpleMenuProvider((id, inv, p) -> new ContainerDrill(id, inv), Component.translatable("container.actuallyadditions.drill")));
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
} }
return new InteractionResultHolder<>(InteractionResult.PASS, player.getItemInHand(hand)); return new InteractionResultHolder<>(InteractionResult.PASS, player.getItemInHand(hand));
} }
@ -194,7 +188,7 @@ public class DrillItem extends ItemEnergy {
int use = this.getEnergyUsePerBlock(stack); int use = this.getEnergyUsePerBlock(stack);
if (!(entityHit instanceof Player) || !((Player) entityHit).isCreative()) { if (!(entityHit instanceof Player) || !((Player) entityHit).isCreative()) {
if (this.getEnergyStored(stack) >= use) { if (this.getEnergyStored(stack) >= use) {
this.extractEnergy(stack, use, false); this.extractEnergyInternal(stack, use, false);
} }
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
@ -218,49 +212,42 @@ public class DrillItem extends ItemEnergy {
: 0.1F; : 0.1F;
} }
private Set<UUID> breakers = new HashSet<>(); // @Override TODO: Check if CommonEvents.onBlockBreaking works
// public boolean onBlockStartBreak(@Nonnull ItemStack stack, @Nonnull BlockPos pos, @Nonnull Player player) {
public boolean onBreakBlock(@Nonnull ItemStack stack, @Nonnull BlockPos pos, @Nonnull Player player) { // boolean toReturn = false;
if (!breakers.add(player.getUUID())) return false; // Prevent multiple break operations from cascading, and don't execute when sneaking. (Borrowed from Apotheosis) // int use = this.getEnergyUsePerBlock(stack);
Level level = player.level(); // if (this.getEnergyStored(stack) >= use) {
boolean toReturn = false; // //Enchants the Drill depending on the Upgrades it has
int use = this.getEnergyUsePerBlock(stack); // if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) {
if (getEnergyStored(stack) >= use) { // ItemUtil.addEnchantment(stack, Enchantments.SILK_TOUCH, 1);
//Enchants the Drill depending on the Upgrades it has // } else {
if (getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) { // if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) {
ItemUtil.addEnchantment(stack, level.holderOrThrow(Enchantments.SILK_TOUCH), 1, level.registryAccess()); // ItemUtil.addEnchantment(stack, Enchantments.BLOCK_FORTUNE, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)
} // ? 3
else { // : 1);
if (getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { // }
ItemUtil.addEnchantment(stack, level.holderOrThrow(Enchantments.FORTUNE), // }
getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ? 3 : 1, // //Block hit
level.registryAccess()); // HitResult ray = player.pick(Util.getReachDistance(player), 1f, false);
} // if (ray instanceof BlockHitResult trace) {
} // //Breaks the Blocks
//Block hit // if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) {
HitResult ray = player.pick(Util.getReachDistance(player), 1f, false); // if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) {
if (ray instanceof BlockHitResult trace) { // toReturn = this.breakBlocks(stack, 2, player.level(), pos, trace.getDirection(), player);
//Breaks the Blocks // } else {
if (!player.isShiftKeyDown() && getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { // toReturn = this.breakBlocks(stack, 1, player.level(), pos, trace.getDirection(), player);
if (getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { // }
toReturn = breakBlocks(stack, 2, player.level(), pos, trace.getDirection(), player); // } else {
} // toReturn = this.breakBlocks(stack, 0, player.level(), pos, trace.getDirection(), player);
else { // }
toReturn = breakBlocks(stack, 1, player.level(), pos, trace.getDirection(), player); //
} // //Removes Enchantments added above
} // ItemUtil.removeEnchantment(stack, Enchantments.SILK_TOUCH);
else { // ItemUtil.removeEnchantment(stack, Enchantments.BLOCK_FORTUNE);
toReturn = breakBlocks(stack, 0, player.level(), pos, trace.getDirection(), player); // }
} // }
// return toReturn;
//Removes Enchantments added above // }
ItemUtil.removeEnchantment(stack, level.holderOrThrow(Enchantments.SILK_TOUCH), level.registryAccess());
ItemUtil.removeEnchantment(stack, level.holderOrThrow(Enchantments.FORTUNE), level.registryAccess());
}
}
breakers.remove(player.getUUID());
return toReturn;
}
/* @Override //TODO old one /* @Override //TODO old one
public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) { public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) {
@ -541,23 +528,24 @@ public class DrillItem extends ItemEnergy {
* Breaks the Block, drops Particles etc. * Breaks the Block, drops Particles etc.
* Has to be called on both Server and Client * Has to be called on both Server and Client
* *
* @param level The Level * @param world The World
* @param isExtra If the Block is the Block that was looked at when breaking or an additional Block * @param isExtra If the Block is the Block that was looked at when breaking or an additional Block
* @param stack The Drill * @param stack The Drill
* @param player The Player breaking the Blocks * @param player The Player breaking the Blocks
* @param use The Energy that should be extracted per Block * @param use The Energy that should be extracted per Block
*/ */
private boolean tryHarvestBlock(Level level, BlockPos pos, boolean isExtra, ItemStack stack, Player player, int use) { private boolean tryHarvestBlock(Level world, BlockPos pos, boolean isExtra, ItemStack stack, Player player, int use) {
BlockState state = level.getBlockState(pos); BlockState state = world.getBlockState(pos);
float hardness = state.getDestroySpeed(level, pos); Block block = state.getBlock();
float hardness = state.getDestroySpeed(world, pos);
boolean canHarvest = (player.hasCorrectToolForDrops(state) || this.isCorrectToolForDrops(stack, state)) && (!isExtra || this.getDestroySpeed(stack, level.getBlockState(pos)) > 1.0F); boolean canHarvest = (player.hasCorrectToolForDrops(state) || this.isCorrectToolForDrops(stack, state)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F);
if (hardness >= 0.0F && (!isExtra || canHarvest && !state.hasBlockEntity())) { if (hardness >= 0.0F && (!isExtra || canHarvest && !state.hasBlockEntity())) {
if (!player.isCreative()) { if (!player.isCreative()) {
this.extractEnergy(stack, use, false); this.extractEnergyInternal(stack, use, false);
} }
//Break the Block //Break the Block
return WorldUtil.breakExtraBlock(stack, level, player, pos); return WorldUtil.breakExtraBlock(stack, world, player, pos);
} }
return false; return false;
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents; import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;

View file

@ -103,7 +103,7 @@ public abstract class ItemEnergy extends ItemBase {
.orElse(0); .orElse(0);
} }
public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate) { //TODO: Check why this method doesn't work public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate) {
return Optional.ofNullable(stack.getCapability(Capabilities.EnergyStorage.ITEM)) return Optional.ofNullable(stack.getCapability(Capabilities.EnergyStorage.ITEM))
.map(cap -> cap instanceof EnergyStorage .map(cap -> cap instanceof EnergyStorage
? cap.extractEnergy(maxExtract, simulate) ? cap.extractEnergy(maxExtract, simulate)
@ -140,17 +140,7 @@ public abstract class ItemEnergy extends ItemBase {
return stack.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0); return stack.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0);
} }
@Override // @Override TODO: Register Energy cap/attachment
public int getMaxDamage(ItemStack stack) {
return getEnergyStorage(stack);
}
@Override
public boolean isDamageable(ItemStack stack) {
return false;
}
// @Override TODO: Register Energy cap/attachment
// public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) { // public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag nbt) {
// return new EnergyCapabilityProvider(stack, this); // return new EnergyCapabilityProvider(stack, this);
// } // }

View file

@ -1,7 +1,13 @@
package de.ellpeck.actuallyadditions.mod.material; package de.ellpeck.actuallyadditions.mod.material;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.Util;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ArmorMaterial;
@ -10,8 +16,10 @@ import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier;
/** /**
* Complete copy paste from {@link net.minecraft.world.item.ArmorMaterial} * Complete copy paste from {@link net.minecraft.world.item.ArmorMaterial}

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer;
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer; import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -28,6 +29,7 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.StemBlock; import net.minecraft.world.level.block.StemBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;

View file

@ -15,6 +15,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.neoforged.fml.loading.FMLLoader; import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.neoforge.common.NeoForgeMod;
public final class Util { public final class Util {

View file

@ -328,6 +328,8 @@ public final class WorldUtil {
if (block.onDestroyedByPlayer(state, level, pos, player, true, state.getFluidState())) { if (block.onDestroyedByPlayer(state, level, pos, player, true, state.getFluidState())) {
block.destroy(level, pos, state); block.destroy(level, pos, state);
} }
// callback to the tool
stack.mineBlock(level, state, pos, player);
// send an update to the server, so we get an update back // send an update to the server, so we get an update back