mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
everything is falling the fuck apart
This commit is contained in:
parent
b1e2fbbbbc
commit
c9c6549340
@ -1,160 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For compatible cables with no buffer, using the IPowertNet. You can make your own cables with IEnergyConnector as well, but they won't join their power network.
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IEnergyConductor extends IEnergyConnector {
|
||||
|
||||
public IPowerNet getPowerNet();
|
||||
|
||||
public void setPowerNet(IPowerNet network);
|
||||
|
||||
/**
|
||||
* A unique identifier for every conductor tile. Used to prevent duplicates when loading previously persistent unloaded tiles.
|
||||
* @return
|
||||
*/
|
||||
public default int getIdentity() {
|
||||
return getIdentityFromTile((TileEntity) this);
|
||||
}
|
||||
|
||||
public static int getIdentityFromTile(TileEntity te) {
|
||||
return getIdentityFromPos(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
public static int getIdentityFromPos(int x, int y, int z) {
|
||||
final int prime = 27644437; // must be this large to minimize localized collisions
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the link should be part of reeval when the network is changed.
|
||||
* I.e. if this link should join any of the new networks (FALSE for switches that are turned off for example)
|
||||
* @return
|
||||
*/
|
||||
public default boolean canReevaluate() {
|
||||
return !((TileEntity) this).isInvalid();
|
||||
}
|
||||
|
||||
/**
|
||||
* When a link leaves the network, the net has to manually calculate the resulting networks.
|
||||
* Each link has to decide what other links will join the same net.
|
||||
* @param copy
|
||||
*/
|
||||
public default void reevaluate(HashMap<Integer, IEnergyConductor> copy, HashMap<Integer, Integer> proxies) {
|
||||
|
||||
for(int[] pos : getConnectionPoints()) {
|
||||
int newX = pos[0];
|
||||
int newY = pos[1];
|
||||
int newZ = pos[2];
|
||||
int id = IEnergyConductor.getIdentityFromPos(newX, newY, newZ);
|
||||
|
||||
IEnergyConductor neighbor = copy.get(id);
|
||||
|
||||
if(neighbor == null) {
|
||||
Integer newId = proxies.get(id);
|
||||
|
||||
if(newId != null) {
|
||||
neighbor = copy.get(newId);
|
||||
}
|
||||
}
|
||||
|
||||
if(neighbor != null && this.canReevaluate() && neighbor.canReevaluate()) {
|
||||
|
||||
if(neighbor.getPowerNet() != null) {
|
||||
|
||||
//neighbor net and no self net
|
||||
if(this.getPowerNet() == null) {
|
||||
neighbor.getPowerNet().joinLink(this);
|
||||
//neighbor net and self net
|
||||
} else {
|
||||
this.getPowerNet().joinNetworks(neighbor.getPowerNet());
|
||||
}
|
||||
|
||||
//bidirectional re-eval, experimental and technically optional, only useful as a fallback
|
||||
} /*else {
|
||||
|
||||
//no neighbor net and no self net
|
||||
if(this.getPowerNet() == null) {
|
||||
this.setPowerNet(new PowerNet().joinLink(this));
|
||||
neighbor.setPowerNet(this.getPowerNet().joinLink(neighbor));
|
||||
//no neighbor net and self net
|
||||
} else {
|
||||
neighbor.setPowerNet(this.getPowerNet().joinLink(neighbor));
|
||||
}
|
||||
}*/
|
||||
|
||||
//extensive debugging has shown that bidirectional re-eval is complete shit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list of positions for the re-eval process. In short - what positions should be considered as connected.
|
||||
* Also used by pylons to quickly figure out what positions to connect to.
|
||||
* DEFAULT: Connects to all six neighboring blocks.
|
||||
* @return
|
||||
*/
|
||||
public default List<int[]> getConnectionPoints() {
|
||||
|
||||
List<int[]> pos = new ArrayList();
|
||||
TileEntity tile = (TileEntity) this;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int newX = tile.xCoord + dir.offsetX;
|
||||
int newY = tile.yCoord + dir.offsetY;
|
||||
int newZ = tile.zCoord + dir.offsetZ;
|
||||
|
||||
pos.add(new int[] {newX, newY, newZ});
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since isLoaded is only currently used for weeding out unwanted subscribers, and cables shouldn't (although technically can) be
|
||||
* subscribers, we just default to true because I don't feel like wasting time implementing things that we don't actually need.
|
||||
* Perhaps this indicates a minor flaw in the new API, but I physically lack the ability to worry about it.
|
||||
*/
|
||||
@Override
|
||||
public default boolean isLoaded() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO: check if this standard implementation doesn't break anything (it shouldn't but right now it's a bit redundant) also: remove duplicate implementations
|
||||
@Override
|
||||
public default long transferPower(long power) {
|
||||
|
||||
if(this.getPowerNet() == null)
|
||||
return power;
|
||||
|
||||
return this.getPowerNet().transferPower(power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the conductor has mutliblock proxies which need to be taken into consideration for re-eval.
|
||||
* @return
|
||||
*/
|
||||
public default boolean hasProxies() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identities (position-based) of proxies which resolve into the conductor's own identity.
|
||||
* @return
|
||||
*/
|
||||
public default List<Integer> getProxies() {
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
@ -1,128 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For anything that connects to power and can be transferred power to, the bottom-level interface.
|
||||
* This is mean for TILE ENTITIES
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IEnergyConnector extends ILoadedTile {
|
||||
|
||||
/**
|
||||
* Returns the amount of power that remains in the source after transfer
|
||||
* @param power
|
||||
* @return
|
||||
*/
|
||||
public long transferPower(long power);
|
||||
|
||||
/**
|
||||
* Whether the given side can be connected to
|
||||
* dir refers to the side of this block, not the connecting block doing the check
|
||||
* @param dir
|
||||
* @return
|
||||
*/
|
||||
public default boolean canConnect(ForgeDirection dir) {
|
||||
return dir != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current power of either the machine or an entire network
|
||||
* @return
|
||||
*/
|
||||
public long getPower();
|
||||
|
||||
/**
|
||||
* The capacity of either the machine or an entire network
|
||||
* @return
|
||||
*/
|
||||
public long getMaxPower();
|
||||
|
||||
public default long getTransferWeight() {
|
||||
return Math.max(getMaxPower() - getPower(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic implementation of subscribing to a nearby power grid
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean red = false;
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
|
||||
if(!con.canConnect(dir.getOpposite()))
|
||||
return;
|
||||
|
||||
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this))
|
||||
con.getPowerNet().subscribe(this);
|
||||
|
||||
if(con.getPowerNet() != null)
|
||||
red = true;
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "power");
|
||||
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public default void tryUnsubscribe(World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
|
||||
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this))
|
||||
con.getPowerNet().unsubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static final boolean particleDebug = false;
|
||||
|
||||
public default Vec3 getDebugParticlePos() {
|
||||
TileEntity te = (TileEntity) this;
|
||||
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
|
||||
return vec;
|
||||
}
|
||||
|
||||
/** Shortcut for adding energy data to tiles that implement IInfoProviderEC, should NOT be used externally for compat! Use IInfoProviderEC.provideInfo() instead! */
|
||||
public default void provideInfoForEC(NBTTagCompound data) {
|
||||
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
|
||||
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
|
||||
}
|
||||
|
||||
public default ConnectionPriority getPriority() {
|
||||
return ConnectionPriority.NORMAL;
|
||||
}
|
||||
|
||||
public enum ConnectionPriority {
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
public interface IEnergyGenerator extends IEnergyUser {
|
||||
|
||||
/**
|
||||
* Standard implementation for machines that can only send energy but never receive it.
|
||||
* @param power
|
||||
*/
|
||||
@Override
|
||||
public default long transferPower(long power) {
|
||||
return power;
|
||||
}
|
||||
|
||||
/* should stop making non-receivers from interfering by applying their weight which doesn't even matter */
|
||||
@Override
|
||||
public default long getTransferWeight() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1,114 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For machines and things that have an energy buffer and are affected by EMPs
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IEnergyUser extends IEnergyConnector {
|
||||
|
||||
/**
|
||||
* Not to be used for actual energy transfer, rather special external things like EMPs and sync packets
|
||||
*/
|
||||
public void setPower(long power);
|
||||
|
||||
/**
|
||||
* Standard implementation for power transfer.
|
||||
* Turns out you can override interfaces to provide a default implementation. Neat.
|
||||
* @param long power
|
||||
*/
|
||||
@Override
|
||||
public default long transferPower(long power) {
|
||||
|
||||
if(this.getPower() + power > this.getMaxPower()) {
|
||||
|
||||
long overshoot = this.getPower() + power - this.getMaxPower();
|
||||
this.setPower(this.getMaxPower());
|
||||
return overshoot;
|
||||
}
|
||||
|
||||
if(this.getPower() + power < 0) return 0; //safeguard for negative energy or overflows
|
||||
|
||||
this.setPower(this.getPower() + power);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard implementation of sending power
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param dir
|
||||
*/
|
||||
public default void sendPower(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean wasSubscribed = false;
|
||||
boolean red = false;
|
||||
|
||||
// first we make sure we're not subscribed to the network that we'll be supplying
|
||||
if(te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
|
||||
if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) {
|
||||
con.getPowerNet().unsubscribe(this);
|
||||
wasSubscribed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//then we add energy
|
||||
if(te instanceof IEnergyConnector) {
|
||||
IEnergyConnector con = (IEnergyConnector) te;
|
||||
|
||||
if(con.canConnect(dir.getOpposite())) {
|
||||
long oldPower = this.getPower();
|
||||
long transfer = oldPower - con.transferPower(oldPower);
|
||||
this.setPower(oldPower - transfer);
|
||||
red = true;
|
||||
}
|
||||
}
|
||||
|
||||
//then we subscribe if possible
|
||||
if(wasSubscribed && te instanceof IEnergyConductor) {
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
|
||||
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this)) {
|
||||
con.getPowerNet().subscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "power");
|
||||
double posX = x + 0.5 - dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posY = y + 0.5 - dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
double posZ = z + 0.5 - dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
|
||||
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mY", dir.offsetY * (red ? 0.025 : 0.1));
|
||||
data.setDouble("mZ", dir.offsetZ * (red ? 0.025 : 0.1));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
|
||||
}
|
||||
}
|
||||
|
||||
public default void updateStandardConnections(World world, TileEntity te) {
|
||||
updateStandardConnections(world, te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
|
||||
public default void updateStandardConnections(World world, int x, int y, int z) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Not mandatory to use, but making your cables IPowerNet-compliant will allow them to connect to NTM cables.
|
||||
* Cables will still work without it as long as they implement IEnergyConductor (or even IEnergyConnector) + self-built network code
|
||||
* @author hbm
|
||||
*/
|
||||
public interface IPowerNet {
|
||||
|
||||
public void joinNetworks(IPowerNet network);
|
||||
|
||||
public IPowerNet joinLink(IEnergyConductor conductor);
|
||||
public void leaveLink(IEnergyConductor conductor);
|
||||
|
||||
public void subscribe(IEnergyConnector connector);
|
||||
public void unsubscribe(IEnergyConnector connector);
|
||||
public boolean isSubscribed(IEnergyConnector connector);
|
||||
|
||||
public void destroy();
|
||||
|
||||
/**
|
||||
* When a link is removed, instead of destroying the network, causing it to be recreated from currently loaded conductors,
|
||||
* we re-evaluate it, creating new nets based on the previous links.
|
||||
*/
|
||||
public void reevaluate();
|
||||
|
||||
public boolean isValid();
|
||||
|
||||
public List<IEnergyConductor> getLinks();
|
||||
public List<IEnergyConnector> getSubscribers();
|
||||
|
||||
public long transferPower(long power);
|
||||
public BigInteger getTotalTransfer();
|
||||
}
|
||||
@ -1,257 +0,0 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.config.GeneralConfig;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector.ConnectionPriority;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* Basic IPowerNet implementation. The behavior of this demo might change inbetween releases, but the API remains the same.
|
||||
* For more consistency please implement your own IPowerNet.
|
||||
* @author hbm
|
||||
*/
|
||||
public class PowerNet implements IPowerNet {
|
||||
|
||||
private boolean valid = true;
|
||||
private HashMap<Integer, IEnergyConductor> links = new HashMap();
|
||||
private HashMap<Integer, Integer> proxies = new HashMap();
|
||||
private List<IEnergyConnector> subscribers = new ArrayList();
|
||||
|
||||
public static List<PowerNet> trackingInstances = null;
|
||||
protected BigInteger totalTransfer = BigInteger.ZERO;
|
||||
|
||||
@Override
|
||||
public void joinNetworks(IPowerNet network) {
|
||||
|
||||
if(network == this)
|
||||
return; //wtf?!
|
||||
|
||||
for(IEnergyConductor conductor : network.getLinks()) {
|
||||
joinLink(conductor);
|
||||
}
|
||||
network.getLinks().clear();
|
||||
|
||||
for(IEnergyConnector connector : network.getSubscribers()) {
|
||||
this.subscribe(connector);
|
||||
}
|
||||
|
||||
network.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPowerNet joinLink(IEnergyConductor conductor) {
|
||||
|
||||
if(conductor.getPowerNet() != null)
|
||||
conductor.getPowerNet().leaveLink(conductor);
|
||||
|
||||
conductor.setPowerNet(this);
|
||||
int identity = conductor.getIdentity();
|
||||
this.links.put(identity, conductor);
|
||||
|
||||
if(conductor.hasProxies()) {
|
||||
for(Integer i : conductor.getProxies()) {
|
||||
this.proxies.put(i, identity);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leaveLink(IEnergyConductor conductor) {
|
||||
conductor.setPowerNet(null);
|
||||
int identity = conductor.getIdentity();
|
||||
this.links.remove(identity);
|
||||
|
||||
if(conductor.hasProxies()) {
|
||||
for(Integer i : conductor.getProxies()) {
|
||||
this.proxies.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(IEnergyConnector connector) {
|
||||
this.subscribers.add(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe(IEnergyConnector connector) {
|
||||
this.subscribers.remove(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubscribed(IEnergyConnector connector) {
|
||||
return this.subscribers.contains(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnergyConductor> getLinks() {
|
||||
List<IEnergyConductor> linkList = new ArrayList();
|
||||
linkList.addAll(this.links.values());
|
||||
return linkList;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> getProxies() {
|
||||
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
|
||||
return proxyCopy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IEnergyConnector> getSubscribers() {
|
||||
return this.subscribers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.valid = false;
|
||||
this.subscribers.clear();
|
||||
|
||||
for(IEnergyConductor link : this.links.values()) {
|
||||
link.setPowerNet(null);
|
||||
}
|
||||
|
||||
this.links.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getTotalTransfer() {
|
||||
return this.totalTransfer;
|
||||
}
|
||||
|
||||
public long lastCleanup = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
/*if(lastCleanup + 45 < System.currentTimeMillis()) {
|
||||
cleanup(this.subscribers);
|
||||
lastCleanup = System.currentTimeMillis();
|
||||
}*/
|
||||
|
||||
List<PowerNet> cache = new ArrayList();
|
||||
if(trackingInstances != null && !trackingInstances.isEmpty()) {
|
||||
cache.addAll(trackingInstances);
|
||||
}
|
||||
|
||||
trackingInstances = new ArrayList();
|
||||
trackingInstances.add(this);
|
||||
long result = fairTransfer(this.subscribers, power);
|
||||
trackingInstances.addAll(cache);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void cleanup(List<IEnergyConnector> subscribers) {
|
||||
|
||||
subscribers.removeIf(x ->
|
||||
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
|
||||
);
|
||||
}
|
||||
|
||||
public static long fairTransfer(List<IEnergyConnector> subscribers, long power) {
|
||||
|
||||
if(power <= 0) return 0;
|
||||
|
||||
if(subscribers.isEmpty())
|
||||
return power;
|
||||
|
||||
cleanup(subscribers);
|
||||
|
||||
ConnectionPriority[] priorities = new ConnectionPriority[] {ConnectionPriority.HIGH, ConnectionPriority.NORMAL, ConnectionPriority.LOW};
|
||||
|
||||
long totalTransfer = 0;
|
||||
|
||||
for(ConnectionPriority p : priorities) {
|
||||
|
||||
List<IEnergyConnector> subList = new ArrayList();
|
||||
subscribers.forEach(x -> {
|
||||
if(x.getPriority() == p) {
|
||||
subList.add(x);
|
||||
}
|
||||
});
|
||||
|
||||
if(subList.isEmpty())
|
||||
continue;
|
||||
|
||||
List<Long> weight = new ArrayList();
|
||||
long totalReq = 0;
|
||||
|
||||
for(IEnergyConnector con : subList) {
|
||||
long req = con.getTransferWeight();
|
||||
weight.add(req);
|
||||
totalReq += req;
|
||||
}
|
||||
|
||||
if(totalReq == 0)
|
||||
continue;
|
||||
|
||||
long totalGiven = 0;
|
||||
|
||||
for(int i = 0; i < subList.size(); i++) {
|
||||
IEnergyConnector con = subList.get(i);
|
||||
long req = weight.get(i);
|
||||
double fraction = (double)req / (double)totalReq;
|
||||
|
||||
long given = (long) Math.floor(fraction * power);
|
||||
|
||||
totalGiven += (given - con.transferPower(given));
|
||||
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
|
||||
}
|
||||
}
|
||||
|
||||
power -= totalGiven;
|
||||
totalTransfer += totalGiven;
|
||||
}
|
||||
|
||||
if(trackingInstances != null) {
|
||||
|
||||
for(int i = 0; i < trackingInstances.size(); i++) {
|
||||
PowerNet net = trackingInstances.get(i);
|
||||
net.totalTransfer = net.totalTransfer.add(BigInteger.valueOf(totalTransfer));
|
||||
}
|
||||
|
||||
trackingInstances.clear();
|
||||
}
|
||||
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reevaluate() {
|
||||
|
||||
if(!GeneralConfig.enableReEval) {
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<Integer, IEnergyConductor> copy = new HashMap(links);
|
||||
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
|
||||
|
||||
for(IEnergyConductor link : copy.values()) {
|
||||
this.leaveLink(link);
|
||||
}
|
||||
|
||||
for(IEnergyConductor link : copy.values()) {
|
||||
|
||||
link.setPowerNet(null);
|
||||
link.reevaluate(copy, proxyCopy);
|
||||
|
||||
if(link.getPowerNet() == null) {
|
||||
link.setPowerNet(new PowerNet().joinLink(link));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package api.hbm.energy;
|
||||
package api.hbm.energymk2;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -1,4 +1,4 @@
|
||||
package api.hbm.energy;
|
||||
package api.hbm.energymk2;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -1,14 +1,8 @@
|
||||
package api.hbm.energymk2;
|
||||
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import api.hbm.energy.ILoadedTile;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyConnectorMK2 extends ILoadedTile {
|
||||
public interface IEnergyConnectorMK2 {
|
||||
|
||||
/**
|
||||
* Whether the given side can be connected to
|
||||
@ -19,24 +13,4 @@ public interface IEnergyConnectorMK2 extends ILoadedTile {
|
||||
public default boolean canConnect(ForgeDirection dir) {
|
||||
return dir != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public long getPower();
|
||||
public long getMaxPower();
|
||||
|
||||
public default long getConnectionSpeed() {
|
||||
return this.getMaxPower();
|
||||
}
|
||||
|
||||
public static final boolean particleDebug = false;
|
||||
|
||||
public default Vec3 getDebugParticlePosMK2() {
|
||||
TileEntity te = (TileEntity) this;
|
||||
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
|
||||
return vec;
|
||||
}
|
||||
|
||||
public default void provideInfoForECMK2(NBTTagCompound data) {
|
||||
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
|
||||
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
|
||||
}
|
||||
}
|
||||
|
||||
33
src/main/java/api/hbm/energymk2/IEnergyHandlerMK2.java
Normal file
33
src/main/java/api/hbm/energymk2/IEnergyHandlerMK2.java
Normal file
@ -0,0 +1,33 @@
|
||||
package api.hbm.energymk2;
|
||||
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import api.hbm.tile.ILoadedTile;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
/** DO NOT USE DIRECTLY! This is simply the common ancestor to providers and receivers, because all this behavior has to be excluded from conductors! */
|
||||
public interface IEnergyHandlerMK2 extends IEnergyConnectorMK2, ILoadedTile {
|
||||
|
||||
public long getPower();
|
||||
public void setPower(long power);
|
||||
public long getMaxPower();
|
||||
|
||||
public default long getConnectionSpeed() {
|
||||
return this.getMaxPower();
|
||||
}
|
||||
|
||||
public static final boolean particleDebug = false;
|
||||
|
||||
public default Vec3 getDebugParticlePosMK2() {
|
||||
TileEntity te = (TileEntity) this;
|
||||
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
|
||||
return vec;
|
||||
}
|
||||
|
||||
public default void provideInfoForECMK2(NBTTagCompound data) {
|
||||
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
|
||||
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
|
||||
}
|
||||
}
|
||||
@ -10,15 +10,14 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyProviderMK2 extends IEnergyConnectorMK2 {
|
||||
/** If it sends energy, use this */
|
||||
public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
|
||||
|
||||
/** Uses up available power, default implementation has no sanity checking, make sure that the requested power is lequal to the current power */
|
||||
public default void usePower(long power) {
|
||||
this.setPower(this.getPower() - power);
|
||||
}
|
||||
|
||||
public void setPower(long power);
|
||||
|
||||
public default void tryProvide(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
@ -10,7 +10,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
||||
/** If it receives energy, use this */
|
||||
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
|
||||
|
||||
public default long transferPower(long power) {
|
||||
if(power + this.getPower() <= this.getMaxPower()) {
|
||||
@ -23,8 +24,6 @@ public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
|
||||
return overshoot;
|
||||
}
|
||||
|
||||
public void setPower(long power);
|
||||
|
||||
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
package api.hbm.energymk2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import api.hbm.energy.ILoadedTile;
|
||||
import api.hbm.tile.ILoadedTile;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package api.hbm.energy;
|
||||
package api.hbm.tile;
|
||||
|
||||
public interface ILoadedTile {
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.blocks.BlockBase;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.blocks.generic;
|
||||
import com.hbm.items.armor.ArmorFSB;
|
||||
import com.hbm.items.armor.ArmorFSBPowered;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.interfaces.IMultiblock;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import api.hbm.fluid.IFluidConnectorBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
||||
@ -8,7 +8,7 @@ import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityFWatzCore;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import api.hbm.fluid.IFluidConnectorBlock;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@ -17,7 +17,8 @@ import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IEnergyProviderMK2;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -145,7 +146,7 @@ public class MachineCapacitor extends BlockContainer implements ILookOverlay, IP
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
public static class TileEntityCapacitor extends TileEntityLoadedBase implements IEnergyUser, INBTPacketReceiver, IPersistentNBT {
|
||||
public static class TileEntityCapacitor extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyReceiverMK2, INBTPacketReceiver, IPersistentNBT {
|
||||
|
||||
public long power;
|
||||
protected long maxPower;
|
||||
@ -190,7 +191,7 @@ public class MachineCapacitor extends BlockContainer implements ILookOverlay, IP
|
||||
long preSend = power;
|
||||
if(pos != null && last != null) {
|
||||
this.tryUnsubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ());
|
||||
this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), last);
|
||||
this.tryProvide(worldObj, pos.getX(), pos.getY(), pos.getZ(), last);
|
||||
}
|
||||
long sent = preSend - power;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@ -10,9 +10,7 @@ import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energy.IEnergyConnector.ConnectionPriority;
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.entity.train;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.inventory.gui.GuiInfoContainer;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@ -31,7 +31,7 @@ import com.hbm.lib.Library;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.util.ArmorUtil;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
|
||||
public class ExplosionNukeGeneric {
|
||||
@ -425,12 +425,9 @@ public class ExplosionNukeGeneric {
|
||||
Block b = world.getBlock(x,y,z);
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof IEnergyUser) {
|
||||
|
||||
((IEnergyUser)te).setPower(0);
|
||||
|
||||
if(random.nextInt(5) < 1)
|
||||
world.setBlock(x, y, z, ModBlocks.block_electrical_scrap);
|
||||
if (te != null && te instanceof IEnergyHandlerMK2) {
|
||||
((IEnergyHandlerMK2)te).setPower(0);
|
||||
if(random.nextInt(5) < 1) world.setBlock(x, y, z, ModBlocks.block_electrical_scrap);
|
||||
}
|
||||
if (te != null && te instanceof IEnergyProvider) {
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineCentrifuge;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineCombustionEngine;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.inventory.container;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineCompressor;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineCrystallizer;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -6,7 +6,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineElectricFurnace;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -6,7 +6,7 @@ import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityElectrolyser;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityElectrolyser;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.inventory.SlotTakeOnly;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.bomb.TileEntityLaunchPadBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.item.IDesignatorItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@ -4,7 +4,7 @@ import com.hbm.inventory.SlotSmelting;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcFurnace;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcWelder;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.oil.TileEntityMachineCatalyticReformer;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -9,7 +9,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineCyclotron;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.items.machine.ItemStamp;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineEPress;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -4,7 +4,7 @@ import com.hbm.inventory.SlotTakeOnly;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineExcavator;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -6,7 +6,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineExposureChamber;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.oil.TileEntityMachineGasFlare;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.oil.TileEntityMachineHydrotreater;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -3,7 +3,7 @@ package com.hbm.inventory.container;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineRadarNT;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -5,7 +5,7 @@ import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.items.machine.ItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineTurbineGas;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -4,7 +4,7 @@ import com.hbm.inventory.SlotTakeOnly;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineWoodBurner;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -4,7 +4,7 @@ import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineMixer;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.armor.ArmorFSB;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -12,7 +12,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@ -6,7 +6,7 @@ import com.hbm.items.armor.ArmorFSB;
|
||||
import com.hbm.items.armor.ArmorFSBPowered;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -19,7 +19,7 @@ import com.hbm.render.util.RenderScreenOverlay.Crosshair;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.ChatBuilder;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@ -17,9 +17,9 @@ import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.TileEntityProxyInventory;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyConnectorMK2;
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
import api.hbm.fluid.IFluidConnectorBlock;
|
||||
import net.minecraft.block.Block;
|
||||
@ -118,8 +118,8 @@ public class Library {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof IEnergyConnector) {
|
||||
IEnergyConnector con = (IEnergyConnector) te;
|
||||
if(te instanceof IEnergyConnectorMK2) {
|
||||
IEnergyConnectorMK2 con = (IEnergyConnectorMK2) te;
|
||||
|
||||
if(con.canConnect(dir.getOpposite() /* machine's connecting side */))
|
||||
return true;
|
||||
|
||||
@ -15,7 +15,6 @@ import com.hbm.tileentity.machine.TileEntitySoyuzLauncher;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector.ConnectionPriority;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.tileentity;
|
||||
|
||||
import com.hbm.sound.AudioWrapper;
|
||||
|
||||
import api.hbm.energy.ILoadedTile;
|
||||
import api.hbm.tile.ILoadedTile;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
@ -1,87 +1,11 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import api.hbm.energymk2.IEnergyConnectorMK2;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energy.IPowerNet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityProxyConductor extends TileEntityProxyBase implements IEnergyConductor {
|
||||
public class TileEntityProxyConductor extends TileEntityProxyBase implements IEnergyConnectorMK2 {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
return ((IEnergyConductor)te).transferPower(power);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
|
||||
TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
return ((IEnergyConductor)te).getPower();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
|
||||
TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
return ((IEnergyConductor)te).getMaxPower();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPowerNet getPowerNet() {
|
||||
|
||||
TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
return ((IEnergyConductor)te).getPowerNet();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerNet(IPowerNet network) {
|
||||
|
||||
TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
((IEnergyConductor)te).setPowerNet(network);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<int[]> getConnectionPoints() {
|
||||
|
||||
/*TileEntity te = this.getTE();
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
return ((IEnergyConductor)te).getConnectionPoints();
|
||||
}*/
|
||||
|
||||
/* Proxy TE doesn't need to implement proxying here because the conductor main TE already has a network-specific proxying system */
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@ -7,8 +7,8 @@ import java.util.Random;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@ -12,8 +12,8 @@ import com.hbm.packet.TEFFPacket;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -20,7 +20,7 @@ import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@ -21,8 +21,8 @@ import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@ -22,8 +22,8 @@ import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -25,8 +25,8 @@ import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachinePolluting;
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyGenerator;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@ -14,8 +14,8 @@ import com.hbm.tileentity.IUpgradeInfoProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@ -12,8 +12,8 @@ import com.hbm.sound.AudioWrapper;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@ -25,8 +25,8 @@ import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyGenerator;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@ -10,8 +10,8 @@ import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.Random;
|
||||
import com.hbm.packet.AuxElectricityPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@ -16,8 +16,8 @@ import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.CompatEnergyControl;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyGenerator;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@ -24,7 +24,7 @@ import com.hbm.util.Tuple;
|
||||
import com.hbm.util.Tuple.Triplet;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -35,7 +35,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileEntityOilDrillBase extends TileEntityMachineBase implements IEnergyUser, IFluidSource, IFluidStandardTransceiver, IConfigurableMachine, IPersistentNBT, IGUIProvider, IUpgradeInfoProvider {
|
||||
public abstract class TileEntityOilDrillBase extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidSource, IFluidStandardTransceiver, IConfigurableMachine, IPersistentNBT, IGUIProvider, IUpgradeInfoProvider {
|
||||
|
||||
public int indicator = 0;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.tileentity.machine.storage;
|
||||
|
||||
import api.hbm.energy.*;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
|
||||
import com.hbm.blocks.machine.MachineBattery;
|
||||
|
||||
@ -1,34 +1,18 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energy.IPowerNet;
|
||||
import api.hbm.energy.PowerNet;
|
||||
import api.hbm.energymk2.IEnergyConductorMK2;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityCableBaseNT extends TileEntity implements IEnergyConductor, IEnergyConductorMK2 {
|
||||
public class TileEntityCableBaseNT extends TileEntity implements IEnergyConductorMK2 {
|
||||
|
||||
protected IPowerNet network;
|
||||
protected PowerNode node;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote && canUpdate()) {
|
||||
|
||||
//we got here either because the net doesn't exist or because it's not valid, so that's safe to assume
|
||||
this.setPowerNet(null);
|
||||
|
||||
this.connect();
|
||||
|
||||
if(this.getPowerNet() == null) {
|
||||
this.setPowerNet(new PowerNet().joinLink(this));
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
@ -45,86 +29,20 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
||||
public void onNodeDestroyedCallback() {
|
||||
this.node = null;
|
||||
}
|
||||
|
||||
protected void connect() {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(!conductor.canConnect(dir.getOpposite()))
|
||||
continue;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(this.network != null) {
|
||||
this.network.reevaluate();
|
||||
this.network = null;
|
||||
}
|
||||
|
||||
if(this.node != null) {
|
||||
Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only update until a power net is formed, in >99% of the cases it should be the first tick. Everything else is handled by neighbors and the net itself.
|
||||
*/
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return (this.network == null || !this.network.isValid()) && !this.isInvalid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection dir) {
|
||||
return dir != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowerNet(IPowerNet network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
|
||||
if(this.network == null)
|
||||
return power;
|
||||
|
||||
return this.network.transferPower(power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPowerNet getPowerNet() {
|
||||
return this.network;
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ import com.hbm.tileentity.machine.TileEntityMachineGasCent;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGasCent.PseudoFluidTank;
|
||||
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import api.hbm.tile.IInfoProviderEC;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -47,8 +47,8 @@ public class CompatEnergyControl {
|
||||
|
||||
data.setString(KEY_EUTYPE, "HE");
|
||||
|
||||
if(tile instanceof IEnergyUser) {
|
||||
IEnergyUser user = (IEnergyUser) tile;
|
||||
if(tile instanceof IEnergyHandlerMK2) {
|
||||
IEnergyHandlerMK2 user = (IEnergyHandlerMK2) tile;
|
||||
data.setDouble(L_ENERGY_HE, user.getPower());
|
||||
data.setDouble(L_CAPACITY_HE, user.getMaxPower());
|
||||
}
|
||||
|
||||
@ -12,7 +12,8 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.turret.TileEntityTurretSentry;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import api.hbm.energymk2.IEnergyHandlerMK2;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidUser;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
@ -67,8 +68,8 @@ public class CompatExternal {
|
||||
*/
|
||||
public static long getBufferedPowerFromTile(TileEntity tile) {
|
||||
|
||||
if(tile instanceof IEnergyUser) {
|
||||
return ((IEnergyUser) tile).getPower();
|
||||
if(tile instanceof IEnergyHandlerMK2) {
|
||||
return ((IEnergyHandlerMK2) tile).getPower();
|
||||
}
|
||||
|
||||
return 0L;
|
||||
@ -81,8 +82,8 @@ public class CompatExternal {
|
||||
*/
|
||||
public static long getMaxPowerFromTile(TileEntity tile) {
|
||||
|
||||
if(tile instanceof IEnergyUser) {
|
||||
return ((IEnergyUser) tile).getMaxPower();
|
||||
if(tile instanceof IEnergyHandlerMK2) {
|
||||
return ((IEnergyHandlerMK2) tile).getMaxPower();
|
||||
}
|
||||
|
||||
return 0L;
|
||||
@ -95,8 +96,8 @@ public class CompatExternal {
|
||||
*/
|
||||
public static int getEnergyPriorityFromTile(TileEntity tile) {
|
||||
|
||||
if(tile instanceof IEnergyUser) {
|
||||
return ((IEnergyUser) tile).getPriority().ordinal();
|
||||
if(tile instanceof IEnergyReceiverMK2) {
|
||||
return ((IEnergyReceiverMK2) tile).getPriority().ordinal();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user