Formatted EnergyMeter PR, merged Energy Cube comparator support
This commit is contained in:
parent
3ea43f6f64
commit
ce09a8225f
6 changed files with 63 additions and 15 deletions
|
@ -45,6 +45,8 @@ public class BlockEnergyCube extends BlockContainer
|
|||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister register)
|
||||
|
@ -313,4 +315,17 @@ public class BlockEnergyCube extends BlockContainer
|
|||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z);
|
||||
return tileEntity.getRedstoneLevel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -196,6 +195,7 @@ public class EnergyNetwork
|
|||
public void merge(EnergyNetwork network)
|
||||
{
|
||||
EnergyNetworkRegistry registry = EnergyNetworkRegistry.getInstance();
|
||||
|
||||
if(network != null && network != this)
|
||||
{
|
||||
EnergyNetwork newNetwork = new EnergyNetwork();
|
||||
|
@ -234,18 +234,22 @@ public class EnergyNetwork
|
|||
{
|
||||
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, Object3D.get(connectedBlockA), Object3D.get((TileEntity)splitPoint));
|
||||
List<Object3D> partNetwork = finder.findNetwork();
|
||||
|
||||
for(int countTwo = countOne + 1; countTwo < connectedBlocks.length; countTwo++)
|
||||
{
|
||||
TileEntity connectedBlockB = connectedBlocks[countTwo];
|
||||
|
||||
if(connectedBlockB instanceof IUniversalCable && !dealtWith[countTwo])
|
||||
{
|
||||
if (partNetwork.contains(Object3D.get(connectedBlockB)))
|
||||
if(partNetwork.contains(Object3D.get(connectedBlockB)))
|
||||
{
|
||||
dealtWith[countTwo] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnergyNetwork newNetwork = new EnergyNetwork();
|
||||
|
||||
for(Object3D node : finder.iterated)
|
||||
{
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
|
||||
|
@ -258,9 +262,11 @@ public class EnergyNetwork
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
newNetwork.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
EnergyNetworkRegistry.getInstance().removeNetwork(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,30 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
|
||||
public class EnergyNetworkRegistry implements ITickHandler
|
||||
{
|
||||
|
||||
private static EnergyNetworkRegistry INSTANCE = new EnergyNetworkRegistry();
|
||||
|
||||
private Set<EnergyNetwork> networks = new HashSet<EnergyNetwork>();
|
||||
|
||||
public EnergyNetworkRegistry()
|
||||
{
|
||||
TickRegistry.registerTickHandler(this, Side.SERVER);
|
||||
}
|
||||
static private EnergyNetworkRegistry INSTANCE = new EnergyNetworkRegistry();
|
||||
|
||||
static public EnergyNetworkRegistry getInstance()
|
||||
public static EnergyNetworkRegistry getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Set<EnergyNetwork> networks = new HashSet<EnergyNetwork>();
|
||||
|
||||
public void registerNetwork(EnergyNetwork network)
|
||||
{
|
||||
networks.add(network);
|
||||
|
@ -36,7 +32,7 @@ public class EnergyNetworkRegistry implements ITickHandler
|
|||
|
||||
public void removeNetwork(EnergyNetwork network)
|
||||
{
|
||||
if (networks.contains(network))
|
||||
if(networks.contains(network))
|
||||
{
|
||||
networks.remove(network);
|
||||
}
|
||||
|
@ -51,7 +47,7 @@ public class EnergyNetworkRegistry implements ITickHandler
|
|||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
for (EnergyNetwork net : networks)
|
||||
for(EnergyNetwork net : networks)
|
||||
{
|
||||
net.clearJoulesTransmitted();
|
||||
}
|
||||
|
@ -69,7 +65,9 @@ public class EnergyNetworkRegistry implements ITickHandler
|
|||
return "Mekanism Energy Networks";
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return networks.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
|
@ -43,6 +44,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
/** This Energy Cube's tier. */
|
||||
public EnergyCubeTier tier = EnergyCubeTier.BASIC;
|
||||
|
||||
/** The redstone level this Energy Cube is outputting at. */
|
||||
public int currentRedstoneLevel;
|
||||
|
||||
/**
|
||||
* A block used to store and transfer electricity.
|
||||
* @param energy - maximum energy this block can hold.
|
||||
|
@ -432,4 +436,24 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
{
|
||||
return side == ForgeDirection.getOrientation(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
super.setEnergy(energy);
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
|
||||
if(newRedstoneLevel != currentRedstoneLevel)
|
||||
{
|
||||
onInventoryChanged();
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRedstoneLevel()
|
||||
{
|
||||
double fractionFull = getEnergy()/getMaxEnergy();
|
||||
return MathHelper.floor_float((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer
|
|||
GL11.glRotatef(180, 0F, 0F, 1F);
|
||||
|
||||
if(!Mekanism.proxy.isPaused() &&
|
||||
tileEntity.checkBounds() &&
|
||||
tileEntity.worldObj.canBlockSeeTheSky(tileEntity.xCoord, tileEntity.yCoord+4, tileEntity.zCoord))
|
||||
{
|
||||
tileEntity.angle = (tileEntity.angle+((int)tileEntity.getMultiplier())) % 360;
|
||||
|
|
|
@ -213,6 +213,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank
|
|||
{
|
||||
return bioFuelSlot.liquidStored*i / bioFuelSlot.MAX_LIQUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartInventorySide(ForgeDirection side)
|
||||
|
|
Loading…
Reference in a new issue