mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Fixed vertical miner and phantom breaker not breaking / harvesting blocks. Fixes #1425
This commit is contained in:
parent
6596a8e6f9
commit
902e806443
4 changed files with 11 additions and 5 deletions
|
@ -214,7 +214,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
||||||
int trans = 0;
|
int trans = 0;
|
||||||
int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true);
|
int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true);
|
||||||
if (theoreticalReceived > 0) {
|
if (theoreticalReceived > 0) {
|
||||||
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
|
int deduct = this.calcDeduction(theoreticalReceived, highestLoss); // TODO maybe we do a minimum threshold before losses occur?
|
||||||
if (deduct >= theoreticalReceived) { //Happens with small numbers
|
if (deduct >= theoreticalReceived) { //Happens with small numbers
|
||||||
deduct = 0;
|
deduct = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDirectionalBreaker;
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDirectionalBreaker;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
@ -104,7 +105,7 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen
|
||||||
Block blockToBreak = breakState.getBlock();
|
Block blockToBreak = breakState.getBlock();
|
||||||
if (blockToBreak != null && !this.level.isEmptyBlock(coordsBlock) && this.level.getBlockState(coordsBlock).getDestroySpeed(this.level, coordsBlock) > -1.0F) {
|
if (blockToBreak != null && !this.level.isEmptyBlock(coordsBlock) && this.level.getBlockState(coordsBlock).getDestroySpeed(this.level, coordsBlock) > -1.0F) {
|
||||||
List<ItemStack> drops = Block.getDrops(breakState, (ServerLevel) this.level, coordsBlock, this.level.getBlockEntity(coordsBlock));
|
List<ItemStack> drops = Block.getDrops(breakState, (ServerLevel) this.level, coordsBlock, this.level.getBlockEntity(coordsBlock));
|
||||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, coordsBlock);
|
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, this.level, coordsBlock);
|
||||||
|
|
||||||
if (chance > 0 && this.level.random.nextFloat() <= chance) {
|
if (chance > 0 && this.level.random.nextFloat() <= chance) {
|
||||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
|
@ -139,7 +140,7 @@ 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();
|
ItemStack fakePickaxe = new ItemStack(ActuallyItems.NETHERITE_AIOT.get());
|
||||||
|
|
||||||
BlockState state = this.level.getBlockState(pos);
|
BlockState state = this.level.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
@ -147,7 +148,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
|
||||||
if (!state.isAir()) {
|
if (!state.isAir()) {
|
||||||
if (fakePickaxe.isCorrectToolForDrops(state) && state.getDestroySpeed(this.level, pos) >= 0F && this.isMinable(state, stack)) {
|
if (fakePickaxe.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, this.level, pos);
|
||||||
|
|
||||||
if (chance > 0 && this.level.random.nextFloat() <= chance) {
|
if (chance > 0 && this.level.random.nextFloat() <= chance) {
|
||||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditionsClient;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditionsClient;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -257,9 +258,12 @@ public final class WorldUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
//I think something is up with this, but I'm not entirely certain what.
|
//I think something is up with this, but I'm not entirely certain what.
|
||||||
public static float fireFakeHarvestEventsForDropChance(BlockEntity caller, List<ItemStack> drops, Level level, BlockPos pos) {
|
// TODO We really need to refactor this out of existence... -Flanks
|
||||||
|
public static float fireFakeHarvestEventsForDropChance(BlockEntity caller, Level level, BlockPos pos) {
|
||||||
if (level instanceof ServerLevel) {
|
if (level instanceof ServerLevel) {
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
||||||
|
ItemStack fakeTool = new ItemStack(ActuallyItems.NETHERITE_AIOT.get());
|
||||||
|
fake.getInventory().items.set(fake.getInventory().selected, fakeTool);
|
||||||
BlockPos tePos = caller.getBlockPos();
|
BlockPos tePos = caller.getBlockPos();
|
||||||
fake.setPos(tePos.getX() + 0.5, tePos.getY() + 0.5, tePos.getZ() + 0.5);
|
fake.setPos(tePos.getX() + 0.5, tePos.getY() + 0.5, tePos.getZ() + 0.5);
|
||||||
BlockState state = level.getBlockState(pos);
|
BlockState state = level.getBlockState(pos);
|
||||||
|
|
Loading…
Reference in a new issue