Got multimeter working with IC2 and BuildCraft machines
This commit is contained in:
parent
02c44613d4
commit
1b8ed1d8b8
4 changed files with 24 additions and 5 deletions
|
@ -596,7 +596,7 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
||||||
@Override
|
@Override
|
||||||
public float getRequest(ForgeDirection direction)
|
public float getRequest(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return this.getMaxEnergyStored() - this.getEnergyStored();
|
return Math.min(this.getMaxEnergyStored() - this.getEnergyStored(), this.transferThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemBlock for the Multimeter
|
* ItemBlock for the Multimeter
|
||||||
|
@ -49,7 +50,7 @@ public class ItemBlockMultimeter extends ItemBlock
|
||||||
{
|
{
|
||||||
// if (!world.isRemote)
|
// if (!world.isRemote)
|
||||||
{
|
{
|
||||||
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(world.getBlockTileEntity(x, y, z)) + " J");
|
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(ForgeDirection.getOrientation(par7), world.getBlockTileEntity(x, y, z)) + " J");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
*/
|
*/
|
||||||
package resonantinduction.multimeter;
|
package resonantinduction.multimeter;
|
||||||
|
|
||||||
|
import ic2.api.tile.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -22,6 +24,7 @@ import universalelectricity.core.grid.IElectricityNetwork;
|
||||||
import universalelectricity.prefab.tile.IRotatable;
|
import universalelectricity.prefab.tile.IRotatable;
|
||||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||||
import universalelectricity.prefab.tile.TileEntityElectrical;
|
import universalelectricity.prefab.tile.TileEntityElectrical;
|
||||||
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
@ -157,10 +160,10 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements IPacketR
|
||||||
{
|
{
|
||||||
ForgeDirection direction = this.getDirection();
|
ForgeDirection direction = this.getDirection();
|
||||||
TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
|
TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.xCoord + direction.offsetX, this.yCoord + direction.offsetY, this.zCoord + direction.offsetZ);
|
||||||
return getDetectedEnergy(tileEntity);
|
return getDetectedEnergy(direction.getOpposite(), tileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getDetectedEnergy(TileEntity tileEntity)
|
public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof TileEntityElectrical)
|
if (tileEntity instanceof TileEntityElectrical)
|
||||||
{
|
{
|
||||||
|
@ -179,6 +182,21 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements IPacketR
|
||||||
return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network);
|
return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (tileEntity instanceof IEnergyStorage)
|
||||||
|
{
|
||||||
|
return ((IEnergyStorage) tileEntity).getStored();
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof IEnergyStorage)
|
||||||
|
{
|
||||||
|
return ((IEnergyStorage) tileEntity).getStored();
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof IPowerReceptor)
|
||||||
|
{
|
||||||
|
if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
|
||||||
|
{
|
||||||
|
return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class BlockWire extends BlockConductor
|
||||||
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID)
|
else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated)
|
||||||
{
|
{
|
||||||
tileEntity.setInsulated();
|
tileEntity.setInsulated();
|
||||||
tileEntity.setDye(BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage()));
|
tileEntity.setDye(BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage()));
|
||||||
|
|
Loading…
Reference in a new issue