i can taste colors

This commit is contained in:
Bob 2024-03-20 21:07:13 +01:00
parent 33e6237377
commit b65abb526f
6 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package api.hbm.energymk2;
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
public PowerNetMK2 getPowerNet();
public void setPowerNet(PowerNetMK2 network);
}

View File

@ -0,0 +1,27 @@
package api.hbm.energymk2;
import com.hbm.util.CompatEnergyControl;
import api.hbm.energy.ILoadedTile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyConnectorMK2 extends ILoadedTile {
/**
* 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;
}
public long getPower();
public long getMaxPower();
public default void provideInfoForEC(NBTTagCompound data) {
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
}
}

View File

@ -0,0 +1,79 @@
package api.hbm.energymk2;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import api.hbm.energy.IEnergyConductor;
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;
public interface IEnergyReceiverMK2 extends IEnergyConnectorMK2 {
public long transferPower(long power);
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;
}
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
public enum ConnectionPriority {
LOW,
NORMAL,
HIGH
}
}

View File

@ -0,0 +1,6 @@
package api.hbm.energymk2;
public class Nodespace {
//we're gonna figure this shit out as we go along
}

View File

@ -0,0 +1,21 @@
package api.hbm.energymk2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class PowerNetMK2 {
private boolean valid = true;
private HashMap<Integer, IEnergyConductorMK2> links = new HashMap();
private HashMap<Integer, Integer> proxies = new HashMap();
private List<IEnergyConnectorMK2> subscribers = new ArrayList();
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
return false; //TBI
}
public void subscribe(IEnergyReceiverMK2 receiver) {
//TBI
}
}

View File

@ -0,0 +1,33 @@
/**
*
*/
/**
* @author hbm
*
*/
package api.hbm.energymk2;
// i have snorted two lines of pure caffeine and taken one large paracetamol laced with even more caffine, let's fucking go
//most of the new classes are just copy pasted mashed up shit from yesteryear, what a productive segment that was
/*
before my caffine high ends entirely and i black out, here's the gist:
* diodes are handled like energy receiver and simply chain-load the power net they output into in a recursive function, this might be a bit laggy compared to the rest of the system, but it's still way less laggy than the old one
* instead of power nets being bound to tile entities directly, tiles spawn ethereal "nodes" similar to the drone waypoints which can be saved using world data, meaning that breaking cables will delete nodes, but unloading them will keep them alive in "node space" which is what's actually used to check for connections
* power nets may cache some positional info in order to limit the amount of nodes, this should prevent horrific freezes in the unlikely event that some retard makes a superflat world out of cables
* general energy transmission will work in a similar fashion as martin explained his, but somewhat simplified; the system will determine supply and demand and then split those evenly if possible, retrying within one operation is only necessary for minor restrictions like priority, any leftovers from rounding don't have to be re-tried because the next tick will already take care of that
* invest funds in more coal mare nudes
* battery "fair share" transfer will most likely no longer work, but that's not really as relevant these days considering there's capacitors and because batteries have transfer speed limits anyway
* most of the machine's functions will be repurposed, the "sendPower" method will no longer send power directly but register the machine to the network as a power source
* if all else fails and martin still hasn't surrendered his code, i will beg greg for his wisdom (but without loss or tiering because fuck that)
*
* | | ||
* ____|____
* |
* || | |_
*
* ...i said WITHOUT loss
*/