mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1117 from BallOfEnergy1/ocshit
Added OC compatibility to yet another block (more coming soon)
This commit is contained in:
commit
0efb99b78c
@ -12,6 +12,7 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
|||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.IPersistentNBT;
|
import com.hbm.tileentity.IPersistentNBT;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
||||||
|
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
@ -164,6 +165,23 @@ public class BlockFluidBarrel extends BlockContainer implements ITooltipProvider
|
|||||||
player.addExhaustion(0.025F);
|
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
|
@Override
|
||||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
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.IPersistentNBT;
|
||||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBAT9000;
|
import com.hbm.tileentity.machine.storage.TileEntityMachineBAT9000;
|
||||||
|
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
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);
|
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
|
@Override
|
||||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
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.IPersistentNBT;
|
||||||
import com.hbm.tileentity.IRepairable;
|
import com.hbm.tileentity.IRepairable;
|
||||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||||
|
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
import com.hbm.tileentity.machine.storage.TileEntityMachineFluidTank;
|
||||||
import com.hbm.util.I18nUtil;
|
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
|
@Override
|
||||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,13 @@ import com.hbm.tileentity.network.TileEntityPipeBaseNT;
|
|||||||
import com.hbm.util.I18nUtil;
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import api.hbm.fluid.IPipeNet;
|
import api.hbm.fluid.IPipeNet;
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
|
import li.cil.oc.api.network.SimpleComponent;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
@ -100,8 +105,9 @@ public class FluidDuctGauge extends FluidDuctBase implements IBlockMultiPass, IL
|
|||||||
public int getRenderType(){
|
public int getRenderType(){
|
||||||
return IBlockMultiPass.getRenderType();
|
return IBlockMultiPass.getRenderType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TileEntityPipeGauge extends TileEntityPipeBaseNT implements INBTPacketReceiver {
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public static class TileEntityPipeGauge extends TileEntityPipeBaseNT implements INBTPacketReceiver, SimpleComponent {
|
||||||
|
|
||||||
private BigInteger lastMeasurement = BigInteger.valueOf(10);
|
private BigInteger lastMeasurement = BigInteger.valueOf(10);
|
||||||
private long deltaTick = 0;
|
private long deltaTick = 0;
|
||||||
@ -144,5 +150,34 @@ public class FluidDuctGauge extends FluidDuctBase implements IBlockMultiPass, IL
|
|||||||
this.deltaTick = Math.max(nbt.getLong("deltaT"), 0);
|
this.deltaTick = Math.max(nbt.getLong("deltaT"), 0);
|
||||||
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
|
this.deltaLastSecond = Math.max(nbt.getLong("deltaS"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "ntm_fluid_gauge";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 16)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getTick(Context context, Arguments args) {
|
||||||
|
return new Object[] {deltaTick};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 16)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getSecond(Context context, Arguments args) {
|
||||||
|
return new Object[] {deltaSecond};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 16)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getType(Context context, Arguments args) {
|
||||||
|
return new Object[] {I18nUtil.resolveKey(getType().getUnlocalizedName())};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 16)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getInfo(Context context, Arguments args) {
|
||||||
|
return new Object[] {deltaTick, deltaSecond, I18nUtil.resolveKey(getType().getUnlocalizedName()), xCoord, yCoord, zCoord};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import com.hbm.saveddata.TomSaveData;
|
|||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.tileentity.IPersistentNBT;
|
import com.hbm.tileentity.IPersistentNBT;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
import cpw.mods.fml.common.Optional;
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@ -31,6 +32,7 @@ import net.minecraft.inventory.Container;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.EnumSkyBlock;
|
import net.minecraft.world.EnumSkyBlock;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
|||||||
public int age = 0;
|
public int age = 0;
|
||||||
public List<IFluidAcceptor> list = new ArrayList();
|
public List<IFluidAcceptor> list = new ArrayList();
|
||||||
protected boolean sendingBrake = false;
|
protected boolean sendingBrake = false;
|
||||||
|
public byte lastRedstone = 0;
|
||||||
|
|
||||||
public TileEntityBarrel() {
|
public TileEntityBarrel() {
|
||||||
super(6);
|
super(6);
|
||||||
@ -64,11 +67,22 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
|||||||
return "container.barrel";
|
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
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
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.setType(0, 1, slots);
|
||||||
tank.loadTank(2, 3, slots);
|
tank.loadTank(2, 3, slots);
|
||||||
tank.unloadTank(4, 5, slots);
|
tank.unloadTank(4, 5, slots);
|
||||||
@ -375,12 +389,12 @@ public class TileEntityBarrel extends TileEntityMachineBase implements IFluidAcc
|
|||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getTypeStored(Context context, Arguments args) {
|
public Object[] getTypeStored(Context context, Arguments args) {
|
||||||
return new Object[] {tank.getTankType().getName()};
|
return new Object[] {tank.getTankType().getUnlocalizedName()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getInfo(Context context, Arguments args) {
|
public Object[] getInfo(Context context, Arguments args) {
|
||||||
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getName()};
|
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getUnlocalizedName()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ import com.hbm.tileentity.IOverpressurable;
|
|||||||
import com.hbm.tileentity.IPersistentNBT;
|
import com.hbm.tileentity.IPersistentNBT;
|
||||||
import com.hbm.tileentity.IRepairable;
|
import com.hbm.tileentity.IRepairable;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
import com.hbm.util.ParticleUtil;
|
import com.hbm.util.ParticleUtil;
|
||||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||||
import cpw.mods.fml.common.Optional;
|
import cpw.mods.fml.common.Optional;
|
||||||
@ -49,6 +50,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.Explosion;
|
import net.minecraft.world.Explosion;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
@ -66,7 +68,7 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
|||||||
public boolean hasExploded = false;
|
public boolean hasExploded = false;
|
||||||
protected boolean sendingBrake = false;
|
protected boolean sendingBrake = false;
|
||||||
public boolean onFire = false;
|
public boolean onFire = false;
|
||||||
|
public byte lastRedstone = 0;
|
||||||
public Explosion lastExplosion = null;
|
public Explosion lastExplosion = null;
|
||||||
|
|
||||||
public int age = 0;
|
public int age = 0;
|
||||||
@ -81,7 +83,13 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "container.fluidtank";
|
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
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
|
|
||||||
@ -119,7 +127,12 @@ public class TileEntityMachineFluidTank extends TileEntityMachineBase implements
|
|||||||
tank.loadTank(2, 3, slots);
|
tank.loadTank(2, 3, slots);
|
||||||
tank.setType(0, 1, 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.getFill() > 0) {
|
||||||
if(tank.getTankType().isAntimatter()) {
|
if(tank.getTankType().isAntimatter()) {
|
||||||
new ExplosionVNT(worldObj, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 5F).makeAmat().setBlockAllocator(null).setBlockProcessor(null).explode();
|
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)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getTypeStored(Context context, Arguments args) {
|
public Object[] getTypeStored(Context context, Arguments args) {
|
||||||
return new Object[] {tank.getTankType().getName()};
|
return new Object[] {tank.getTankType().getUnlocalizedName()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getInfo(Context context, Arguments args) {
|
public Object[] getInfo(Context context, Arguments args) {
|
||||||
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getName()};
|
return new Object[]{tank.getFill(), tank.getMaxFill(), tank.getTankType().getUnlocalizedName()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user