mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 05:02:25 +00:00
Comparator refactor and Vacuum Chest logic (#196)
Add comparator logic to the Vacuum Chest and refactor comparator logic for Capacitor Banks and Tanks
This commit is contained in:
1 parent
304fdef5ec
commit
b1f8d99da9
7 files changed
+22
-51
No files matched your search
@@ -523,20 +523,6 @@ public class BlockCapBank extends BlockEio
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int side) {
|
||||
TileEntity te = w.getTileEntity(x, y, z);
|
||||
if (te instanceof TileCapBank) {
|
||||
return ((TileCapBank) te).getComparatorOutput();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.enderio.core.common.interfaces.IComparatorOutput;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.enderio.core.common.util.EntityUtil;
|
||||
import com.enderio.core.common.util.Util;
|
||||
@@ -46,7 +47,7 @@ import crazypants.enderio.power.IPowerStorage;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class TileCapBank extends TileEntityEio
|
||||
implements IInternalPowerReceiver, IInventory, IIoConfigurable, IPowerStorage {
|
||||
implements IInternalPowerReceiver, IInventory, IIoConfigurable, IPowerStorage, IComparatorOutput {
|
||||
|
||||
private Map<ForgeDirection, IoMode> faceModes;
|
||||
private Map<ForgeDirection, InfoDisplayType> faceDisplayTypes;
|
||||
@@ -692,9 +693,10 @@ public class TileCapBank extends TileEntityEio
|
||||
return getIoMode(from) != IoMode.DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput() {
|
||||
double stored = getEnergyStored();
|
||||
return stored == 0 ? 0 : (int) (1 + stored / getMaxEnergyStored() * 14);
|
||||
int stored = getEnergyStored();
|
||||
return stored == 0 ? 0 : 1 + (stored * 14) / getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -330,20 +330,6 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int side) {
|
||||
TileEntity te = w.getTileEntity(x, y, z);
|
||||
if (te instanceof TileCapacitorBank) {
|
||||
return ((TileCapacitorBank) te).getComparatorOutput();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.enderio.core.common.interfaces.IComparatorOutput;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.enderio.core.common.util.Util;
|
||||
import com.enderio.core.common.vecmath.VecmathUtil;
|
||||
@@ -40,7 +41,7 @@ import crazypants.enderio.power.IPowerStorage;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class TileCapacitorBank extends TileEntityEio
|
||||
implements IInternalPowerHandler, IInventory, IIoConfigurable, IPowerStorage {
|
||||
implements IInternalPowerHandler, IInventory, IIoConfigurable, IPowerStorage, IComparatorOutput {
|
||||
|
||||
static final BasicCapacitor BASE_CAP = new BasicCapacitor(
|
||||
Config.capacitorBankMaxIoRF,
|
||||
@@ -273,9 +274,10 @@ public class TileCapacitorBank extends TileEntityEio
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput() {
|
||||
double stored = getEnergyStored();
|
||||
return stored == 0 ? 0 : (int) (1 + stored / getMaxEnergyStored() * 14);
|
||||
int stored = getEnergyStored();
|
||||
return stored == 0 ? 0 : 1 + (stored * 14) / getMaxEnergyStored();
|
||||
}
|
||||
|
||||
public List<GaugeBounds> getGaugeBounds() {
|
||||
|
||||
@@ -184,20 +184,6 @@ public class BlockTank extends AbstractMachineBlock<TileTank> implements IAdvanc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int side) {
|
||||
TileEntity te = w.getTileEntity(x, y, z);
|
||||
if (te instanceof TileTank) {
|
||||
return ((TileTank) te).getComparatorOutput();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.enderio.core.api.common.util.ITankAccess;
|
||||
import com.enderio.core.common.interfaces.IComparatorOutput;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.enderio.core.common.util.FluidUtil;
|
||||
import com.enderio.core.common.util.FluidUtil.FluidAndStackResult;
|
||||
@@ -28,7 +29,7 @@ import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.ArrayMappingTool;
|
||||
import crazypants.enderio.tool.SmartTank;
|
||||
|
||||
public class TileTank extends AbstractMachineEntity implements IFluidHandler, ITankAccess {
|
||||
public class TileTank extends AbstractMachineEntity implements IFluidHandler, ITankAccess, IComparatorOutput {
|
||||
|
||||
private static int IO_MB_TICK = 100;
|
||||
|
||||
@@ -297,13 +298,14 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler, IT
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput() {
|
||||
FluidTankInfo info = getTankInfo(null)[0];
|
||||
if (info == null || info.fluid == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return info.fluid.amount == 0 ? 0 : (int) (1 + ((double) info.fluid.amount / (double) info.capacity) * 14);
|
||||
return info.fluid.amount == 0 ? 0 : 1 + (info.fluid.amount * 14) / info.capacity;
|
||||
}
|
||||
|
||||
private boolean processItems(boolean redstoneCheckPassed) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -16,6 +17,7 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.enderio.core.client.render.BoundingBox;
|
||||
import com.enderio.core.common.interfaces.IComparatorOutput;
|
||||
import com.enderio.core.common.util.ItemUtil;
|
||||
import com.enderio.core.common.vecmath.Vector3d;
|
||||
|
||||
@@ -34,7 +36,7 @@ import crazypants.enderio.machine.ranged.IRanged;
|
||||
import crazypants.enderio.machine.ranged.RangeEntity;
|
||||
|
||||
public class TileVacuumChest extends TileEntityEio
|
||||
implements IEntitySelector, IInventory, IRedstoneModeControlable, IRanged {
|
||||
implements IEntitySelector, IInventory, IRedstoneModeControlable, IRanged, IComparatorOutput {
|
||||
|
||||
public static final int ITEM_ROWS = 3;
|
||||
public static final int ITEM_SLOTS = 9 * ITEM_ROWS;
|
||||
@@ -407,4 +409,9 @@ public class TileVacuumChest extends TileEntityEio
|
||||
}
|
||||
nbtRoot.setInteger("redstoneControlMode", redstoneControlMode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorOutput() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user