mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Fix TransporterStack home locations & DM inventory interaction (#5335)
* Fix DM charge slot inventory interaction, fixed TransporterStack home paths * Added clarification comment to JavaDoc for canBeCharged/Discharged
This commit is contained in:
1 parent
b0f9e1b2ee
commit
17708ce587
5 files changed
+53
-78
No files matched your search
@@ -11,7 +11,6 @@ import mekanism.common.integration.MekanismHooks;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
@@ -27,12 +26,6 @@ public interface IAdvancedBoundingBlock extends ICapabilityProvider, IBoundingBl
|
||||
IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IComputerIntegration,
|
||||
ISpecialConfigData, ISecurityTile, IOffsetCapability {
|
||||
|
||||
int[] getBoundSlots(BlockPos location, EnumFacing side);
|
||||
|
||||
boolean canBoundInsert(BlockPos location, int i, ItemStack itemstack);
|
||||
|
||||
boolean canBoundExtract(BlockPos location, int i, ItemStack itemstack, EnumFacing side);
|
||||
|
||||
boolean canBoundReceiveEnergy(BlockPos location, EnumFacing side);
|
||||
|
||||
void onPower();
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
@@ -24,7 +25,6 @@ import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public final class TransporterPathfinder {
|
||||
|
||||
@@ -453,7 +453,9 @@ public final class TransporterPathfinder {
|
||||
neighbors[direction.ordinal()] = neighbor;
|
||||
TileEntity neighborEntity = neighbor.getTileEntity(worldObj);
|
||||
neighborEntities[direction.ordinal()] = neighborEntity;
|
||||
if (currentNodeTransporter == null || currentNodeTransporter.canEmitTo(neighborEntity, direction)) {
|
||||
if ((currentNodeTransporter == null || currentNodeTransporter.canEmitTo(neighborEntity, direction)) ||
|
||||
(neighbor.equals(finalNode) && destChecker
|
||||
.isValid(transportStack, direction, neighborEntities[direction.ordinal()]))) {
|
||||
directionsToCheck.add(direction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
return false;
|
||||
}
|
||||
|
||||
return inv.canBoundInsert(getPos(), i, itemstack);
|
||||
return inv.isItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -202,12 +202,17 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
return InventoryUtils.EMPTY;
|
||||
}
|
||||
|
||||
return inv.getBoundSlots(getPos(), side);
|
||||
return inv.getSlotsForFace(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) {
|
||||
return isItemValidForSlot(i, itemstack);
|
||||
IAdvancedBoundingBlock inv = getInv();
|
||||
if (inv == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return inv.canInsertItem(i, itemstack, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,7 +222,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||
return false;
|
||||
}
|
||||
|
||||
return inv.canBoundExtract(getPos(), i, itemstack, side);
|
||||
return inv.canExtractItem(i, itemstack, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -11,6 +10,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nonnull;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
@@ -81,7 +81,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IUpgradeTile, IRedstoneControl,
|
||||
IActiveState, ISustainedData, IChunkLoader, IAdvancedBoundingBlock {
|
||||
|
||||
private static final int[] INV_SLOTS = IntStream.range(0, 27).toArray();
|
||||
private static final int[] INV_SLOTS = IntStream.range(0, 28).toArray();
|
||||
|
||||
public static int[] EJECT_INV;
|
||||
public final double BASE_ENERGY_USAGE = usage.digitalMinerUsage;
|
||||
@@ -985,54 +985,26 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getBoundSlots(BlockPos location, EnumFacing side) {
|
||||
EnumFacing dir = facing.getOpposite();
|
||||
|
||||
BlockPos pull = getPos().up();
|
||||
BlockPos eject = pull.offset(dir);
|
||||
|
||||
if ((location.equals(eject) && side == dir) || (location.equals(pull) && side == EnumFacing.UP)) {
|
||||
if (EJECT_INV == null) {
|
||||
EJECT_INV = new int[27];
|
||||
|
||||
for (int i = 0; i < EJECT_INV.length; i++) {
|
||||
EJECT_INV[i] = i;
|
||||
}
|
||||
public boolean canInsertItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) {
|
||||
if (side == EnumFacing.UP) {
|
||||
if (slotID == 27) {
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
} else {
|
||||
return !itemstack.isEmpty() && isReplaceStack(itemstack);
|
||||
}
|
||||
|
||||
return EJECT_INV;
|
||||
}
|
||||
|
||||
return InventoryUtils.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBoundInsert(BlockPos location, int i, ItemStack itemstack) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
|
||||
BlockPos pull = getPos().up();
|
||||
BlockPos eject = pull.offset(side);
|
||||
|
||||
if (location.equals(eject)) {
|
||||
return false;
|
||||
} else if (location.equals(pull)) {
|
||||
return !itemstack.isEmpty() && isReplaceStack(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBoundExtract(BlockPos location, int i, ItemStack itemstack, EnumFacing dir) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
|
||||
BlockPos pull = getPos().up();
|
||||
BlockPos eject = pull.offset(side);
|
||||
|
||||
if (location.equals(eject)) {
|
||||
return itemstack.isEmpty() || !isReplaceStack(itemstack);
|
||||
} else if (location.equals(pull)) {
|
||||
return false;
|
||||
public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) {
|
||||
if (side == facing.getOpposite()) {
|
||||
if (slotID == 27) {
|
||||
return !ChargeUtils.canBeDischarged(itemstack);
|
||||
} else {
|
||||
return itemstack.isEmpty() || !isReplaceStack(itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -118,41 +118,44 @@ public final class ChargeUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a defined ItemStack can be discharged for energy in some way.
|
||||
* Whether or not a defined ItemStack can be discharged for energy in some way. Note: The ItemStack must also have
|
||||
* energy to discharge.
|
||||
*
|
||||
* @param itemstack - ItemStack to check
|
||||
* @return if the ItemStack can be discharged
|
||||
*/
|
||||
public static boolean canBeDischarged(ItemStack itemstack) {
|
||||
return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem) itemstack
|
||||
.getItem()).canProvideEnergy(itemstack)) ||
|
||||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem) itemstack.getItem())
|
||||
.canSend(itemstack)) ||
|
||||
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem
|
||||
&& ((IEnergyContainerItem) itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
|
||||
(MekanismUtils.useTesla() && itemstack.hasCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null)
|
||||
&& itemstack.getCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null).takePower(1, true) > 0) ||
|
||||
(MekanismUtils.useForge() && itemstack.hasCapability(CapabilityEnergy.ENERGY, null) && itemstack
|
||||
.getCapability(CapabilityEnergy.ENERGY, null).canExtract()) ||
|
||||
itemstack.getItem() == Items.REDSTONE;
|
||||
return MekanismUtils.useIC2() && ElectricItem.manager.discharge(itemstack, 1, 0, true, true, true) > 0 || (
|
||||
itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem) itemstack.getItem()).canSend(itemstack)
|
||||
&& ((IEnergizedItem) itemstack.getItem()).getEnergy(itemstack) > 0) || (MekanismUtils.useRF()
|
||||
&& itemstack.getItem() instanceof IEnergyContainerItem
|
||||
&& ((IEnergyContainerItem) itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) || (
|
||||
MekanismUtils.useTesla() && itemstack.hasCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null)
|
||||
&& itemstack.getCapability(Capabilities.TESLA_PRODUCER_CAPABILITY, null).takePower(1, true) > 0)
|
||||
|| (MekanismUtils.useForge() && itemstack.hasCapability(CapabilityEnergy.ENERGY, null)
|
||||
&& itemstack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(1, true) > 0)
|
||||
|| itemstack.getItem() == Items.REDSTONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a defined ItemStack can be charged with energy in some way.
|
||||
* Whether or not a defined ItemStack can be charged with energy in some way. Note: The ItemStack must also have
|
||||
* room for more energy.
|
||||
*
|
||||
* @param itemstack - ItemStack to check
|
||||
* @return if the ItemStack can be discharged
|
||||
*/
|
||||
public static boolean canBeCharged(ItemStack itemstack) {
|
||||
return (MekanismUtils.useIC2() && ElectricItem.manager.getTier(itemstack) > 0) ||
|
||||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem) itemstack.getItem())
|
||||
.canReceive(itemstack)) ||
|
||||
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem
|
||||
&& ((IEnergyContainerItem) itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0) ||
|
||||
(MekanismUtils.useTesla() && itemstack.hasCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null)
|
||||
&& itemstack.getCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null).givePower(1, true) > 0) ||
|
||||
(MekanismUtils.useForge() && itemstack.hasCapability(CapabilityEnergy.ENERGY, null) && itemstack
|
||||
.getCapability(CapabilityEnergy.ENERGY, null).canReceive());
|
||||
return (MekanismUtils.useIC2() && ElectricItem.manager.charge(itemstack, 1, 0, true, true) > 0) || (
|
||||
itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem) itemstack.getItem())
|
||||
.canReceive(itemstack)
|
||||
&& ((IEnergizedItem) itemstack.getItem()).getMaxEnergy(itemstack) < ((IEnergizedItem) itemstack
|
||||
.getItem()).getEnergy(itemstack)) || (MekanismUtils.useRF() && itemstack
|
||||
.getItem() instanceof IEnergyContainerItem
|
||||
&& ((IEnergyContainerItem) itemstack.getItem()).receiveEnergy(itemstack, 1, true) > 0) || (
|
||||
MekanismUtils.useTesla() && itemstack.hasCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null)
|
||||
&& itemstack.getCapability(Capabilities.TESLA_CONSUMER_CAPABILITY, null).givePower(1, true) > 0)
|
||||
|| (MekanismUtils.useForge() && itemstack.hasCapability(CapabilityEnergy.ENERGY, null)
|
||||
&& itemstack.getCapability(CapabilityEnergy.ENERGY, null).receiveEnergy(1, true) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user