mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
there you got your damn comparator support for tanks
This commit is contained in:
parent
91e52dc665
commit
3041e68896
@ -12,6 +12,7 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@ -164,6 +165,23 @@ public class BlockFluidBarrel extends BlockContainer implements ITooltipProvider
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityBarrel))
|
||||
return 0;
|
||||
|
||||
TileEntityBarrel barrel = (TileEntityBarrel) te;
|
||||
return barrel.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
|
||||
@ -12,6 +12,7 @@ import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBAT9000;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
@ -98,6 +99,23 @@ public class MachineBigAssTank9000 extends BlockDummyable implements IPersistent
|
||||
return IPersistentNBT.getDrops(world, x, y, z, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityMachineBAT9000))
|
||||
return 0;
|
||||
|
||||
TileEntityMachineBAT9000 tank = (TileEntityMachineBAT9000) te;
|
||||
return tank.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
|
||||
@ -14,6 +14,7 @@ import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.IRepairable;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
@ -135,6 +136,23 @@ public class MachineFluidTank extends BlockDummyable implements IPersistentInfoP
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityMachineFluidTank))
|
||||
return 0;
|
||||
|
||||
TileEntityMachineFluidTank tank = (TileEntityMachineFluidTank) te;
|
||||
return tank.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
|
||||
@ -151,7 +151,6 @@ public class FluidDuctGauge extends FluidDuctBase implements IBlockMultiPass, IL
|
||||
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "ntm_fluid_gauge";
|
||||
|
||||
@ -16,6 +16,7 @@ import com.hbm.saveddata.TomSaveData;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -31,6 +32,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -48,6 +50,7 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
||||
public int age = 0;
|
||||
public List<IFluidAcceptor> list = new ArrayList();
|
||||
protected boolean sendingBrake = false;
|
||||
public byte lastRedstone = 0;
|
||||
|
||||
public TileEntityBarrel() {
|
||||
super(6);
|
||||
@ -64,11 +67,22 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
||||
return "container.barrel";
|
||||
}
|
||||
|
||||
public byte getComparatorPower() {
|
||||
if(tank.getFill() == 0) return 0;
|
||||
double frac = (double) tank.getFill() / (double) tank.getMaxFill() * 15D;
|
||||
return (byte) (MathHelper.clamp_int((int) frac + 1, 0, 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
byte comp = this.getComparatorPower(); //do comparator shenanigans
|
||||
if(comp != this.lastRedstone)
|
||||
this.markDirty();
|
||||
this.lastRedstone = comp;
|
||||
|
||||
tank.setType(0, 1, slots);
|
||||
tank.loadTank(2, 3, slots);
|
||||
tank.unloadTank(4, 5, slots);
|
||||
@ -375,12 +389,12 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
||||
@Callback(direct = true, limit = 4)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getTypeStored(Context context, Arguments args) {
|
||||
return new Object[] {tank.getTankType().getName()};
|
||||
return new Object[] {I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName())};
|
||||
}
|
||||
|
||||
@Callback(direct = true, limit = 4)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getInfo(Context context, Arguments args) {
|
||||
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getName()};
|
||||
return new Object[]{tank.getFill(), tank.getMaxFill(), I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName())};
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ import com.hbm.tileentity.IOverpressurable;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.IRepairable;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.ParticleUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
@ -49,6 +50,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -66,7 +68,7 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
public boolean hasExploded = false;
|
||||
protected boolean sendingBrake = false;
|
||||
public boolean onFire = false;
|
||||
|
||||
public byte lastRedstone = 0;
|
||||
public Explosion lastExplosion = null;
|
||||
|
||||
public int age = 0;
|
||||
@ -81,7 +83,13 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
public String getName() {
|
||||
return "container.fluidtank";
|
||||
}
|
||||
|
||||
|
||||
public byte getComparatorPower() {
|
||||
if(tank.getFill() == 0) return 0;
|
||||
double frac = (double) tank.getFill() / (double) tank.getMaxFill() * 15D;
|
||||
return (byte) (MathHelper.clamp_int((int) frac + 1, 0, 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
@ -119,7 +127,12 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
tank.loadTank(2, 3, slots);
|
||||
tank.setType(0, 1, slots);
|
||||
}
|
||||
|
||||
|
||||
byte comp = this.getComparatorPower(); //comparator shit
|
||||
if(comp != this.lastRedstone)
|
||||
this.markDirty();
|
||||
this.lastRedstone = comp;
|
||||
|
||||
if(tank.getFill() > 0) {
|
||||
if(tank.getTankType().isAntimatter()) {
|
||||
new ExplosionVNT(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 5F).makeAmat().setBlockAllocator(null).setBlockProcessor(null).explode();
|
||||
@ -474,12 +487,12 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
||||
@Callback(direct = true, limit = 4)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getTypeStored(Context context, Arguments args) {
|
||||
return new Object[] {tank.getTankType().getName()};
|
||||
return new Object[] {I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName())};
|
||||
}
|
||||
|
||||
@Callback(direct = true, limit = 4)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getInfo(Context context, Arguments args) {
|
||||
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getName()};
|
||||
return new Object[]{tank.getFill(), tank.getMaxFill(), I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName())};
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user