mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fix tool check (Fixes #1421)
This commit is contained in:
parent
16cd3a6966
commit
e91c1569ee
3 changed files with 8 additions and 4 deletions
|
@ -21,11 +21,13 @@ import net.minecraft.core.HolderLookup;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
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;
|
||||||
|
@ -102,7 +104,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements MenuPr
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork() {
|
private void doWork() {
|
||||||
Direction side = WorldUtil.getDirectionByPistonRotation(this.level.getBlockState(this.worldPosition));
|
Direction side = WorldUtil.getDirectionByPistonRotation(getBlockState());
|
||||||
BlockPos breakCoords = this.worldPosition.relative(side);
|
BlockPos breakCoords = this.worldPosition.relative(side);
|
||||||
BlockState stateToBreak = this.level.getBlockState(breakCoords);
|
BlockState stateToBreak = this.level.getBlockState(breakCoords);
|
||||||
Block blockToBreak = stateToBreak.getBlock();
|
Block blockToBreak = stateToBreak.getBlock();
|
||||||
|
@ -110,6 +112,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements MenuPr
|
||||||
if (!this.isPlacer && blockToBreak != Blocks.AIR && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) {
|
if (!this.isPlacer && blockToBreak != Blocks.AIR && stateToBreak.getDestroySpeed(this.level, breakCoords) >= 0.0F) {
|
||||||
List<ItemStack> drops = Block.getDrops(stateToBreak, (ServerLevel) this.level, breakCoords, this.level.getBlockEntity(breakCoords));
|
List<ItemStack> drops = Block.getDrops(stateToBreak, (ServerLevel) this.level, breakCoords, this.level.getBlockEntity(breakCoords));
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||||
|
fake.getInventory().items.set(fake.getInventory().selected, Items.NETHERITE_PICKAXE.getDefaultInstance());
|
||||||
if (stateToBreak.canHarvestBlock(this.level, breakCoords, fake)) { //TODO might double check this is right mikey
|
if (stateToBreak.canHarvestBlock(this.level, breakCoords, fake)) { //TODO might double check this is right mikey
|
||||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||||
this.level.destroyBlock(breakCoords, false);
|
this.level.destroyBlock(breakCoords, false);
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen
|
||||||
|
|
||||||
private void doWork() {
|
private void doWork() {
|
||||||
if (this.storage.getEnergyStored() >= ENERGY_USE * RANGE) {
|
if (this.storage.getEnergyStored() >= ENERGY_USE * RANGE) {
|
||||||
BlockState state = this.level.getBlockState(this.worldPosition);
|
BlockState state = getBlockState();
|
||||||
Direction sideToManipulate = WorldUtil.getDirectionByPistonRotation(state);
|
Direction sideToManipulate = WorldUtil.getDirectionByPistonRotation(state);
|
||||||
|
|
||||||
for (int i = 0; i < RANGE; i++) {
|
for (int i = 0; i < RANGE; i++) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
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;
|
||||||
|
@ -138,13 +139,13 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
|
||||||
: 1);
|
: 1);
|
||||||
if (this.storage.getEnergyStored() >= actualUse) {
|
if (this.storage.getEnergyStored() >= actualUse) {
|
||||||
BlockPos pos = new BlockPos(this.worldPosition.getX() + this.checkX, this.checkY, this.worldPosition.getZ() + this.checkZ);
|
BlockPos pos = new BlockPos(this.worldPosition.getX() + this.checkX, this.checkY, this.worldPosition.getZ() + this.checkZ);
|
||||||
|
ItemStack fakePickaxe = Items.NETHERITE_PICKAXE.getDefaultInstance();
|
||||||
|
|
||||||
BlockState state = this.level.getBlockState(pos);
|
BlockState state = this.level.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
ItemStack stack = block.getCloneItemStack(state, new BlockHitResult(new Vec3(0, 0, 0), Direction.DOWN, pos, false), this.level, pos, FakePlayerFactory.getMinecraft((ServerLevel) this.level));
|
ItemStack stack = block.getCloneItemStack(state, new BlockHitResult(new Vec3(0, 0, 0), Direction.DOWN, pos, false), this.level, pos, FakePlayerFactory.getMinecraft((ServerLevel) this.level));
|
||||||
if (!state.isAir()) {
|
if (!state.isAir()) {
|
||||||
//block.getHarvestLevel(state) <= DrillItem.HARVEST_LEVEL
|
if (fakePickaxe.isCorrectToolForDrops(state) && state.getDestroySpeed(this.level, pos) >= 0F && this.isMinable(state, stack)) {
|
||||||
if (stack.isCorrectToolForDrops(state) && state.getDestroySpeed(this.level, pos) >= 0F && this.isMinable(state, stack)) {
|
|
||||||
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) this.level, pos, this.level.getBlockEntity(pos));
|
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) this.level, pos, this.level.getBlockEntity(pos));
|
||||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, pos);
|
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, pos);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue