power net: compromise edition

This commit is contained in:
Boblet 2024-04-19 15:21:43 +02:00
parent 3460e8dcef
commit d7664c79da
5 changed files with 72 additions and 33 deletions

View File

@ -104,10 +104,7 @@ One of the most common "performance" mods on 1.7.10, Optifine, achieves an incre
* Entity "optimization" has a tendency to break chunkloading, this is especially noticeable with missiles which rely heavily on chunkloading to work, causing them to freeze mid-air. It's unclear what setting might fix this, and analysis of Optifine's source code (or rather, lack thereof) has not proven useful either.
### Angelica
Like most performance mods, Angelica also does deep-rooted changes to the game's rendering to improve performance, changes which have unintended side effects with mods that otherwise rely on the vanilla functionality that was changed. Unlike with Optifine, Angelica's source code is accessible and the mod is still in active development, so the list of issues might be outdated:
* 3D models in inventories might render with no texture, this issue apparently also breaks font rendering for item tooltips
* 3D models for tile entities have a tendency to render with blend enabled (i.e. semi-transparent), especially models that are separated into multiple parts which use display lists (i.e. an older system for rendering larger models more efficiently)
* Blocks with connected textures once again become invisible (exact fix for Angelica is unknown)
In older versions, Angelica caused issues regarding model rendering, often times making 3D models transparent. Ever since the switch to VBOs, models work fine. Another issue was blocks with connected textures not rendering at all, but this too was fixed, meaning as of time of writing there are no major incompatibilities known with Angelica.
### Skybox chainloader
NTM adds a few small things to the skybox using a custom skybox renderer. Minecraft can only have a single skybox renderer loaded, so setting the skybox to the NTM custom one would break compatibility with other mods' skyboxes. To mend this, NTM employs a **chainloader**. This chainloader will detect if a different skybox is loaded, save a reference to that skybox and then use NTM's skybox, which when used will also make sure to run the previous modded skybox renderer. In the event that NTM's skybox were to cause trouble, it can be disabled with the config option `1.31_enableSkyboxes`.

View File

@ -1,30 +1,2 @@
## Changed
* Large models no longer use display lists, instead their rendering makes use of the more modern VBO system
* Models using VBOs should now render slightly faster
* This also fixes an issue with Angelica where certain parts of the model would render transparently
* All pylons and electrical connectors are now dyeable, using any dye (even modded ones, based on ore dict) to change the color of the cable
* Colors are based on the connecting pylon, not the cables themselves, meaning that using one dye will change all wires connected to that pylon right up to the half way point
* Glyphid behemoths now spew sulfuric acid instead of hydrogen peroxide
* Glyphid brawlers can now leap at nearby players
* The structure config has changed
* Instead of a central toggle for enabling/disabling structures, there's now three possible settings, enabling structures, disabling structures or making structure spawn respect the setting from the world creation menu
* Pressurized gauges like for the vacuum refinery and hydrotreater no longer have slots for item barrels (as those would logically not work), instead they show a pressure symbol
* Auditory geiger counters in armors will now click based on the radiation level *inside* the suit, i.e. the effective exposure for the player
* Diamonds are now a valid crucible material, turning into carbon at a 1:1 ratio (like graphite)
* Emerald is also a valid crucible material now, turning into beryllium at a 4:3 ratio
* Emeralds can now be mined as bedrock ores with a weight of 50 (half as common as iron, as common as redstone)
* Tritium lamps are now substantially cheaper
* Glyphid scouts can now spawn during the day when rampant glyphid spawning is enabled (artificial light however will still prevent them from spawning, keeping them out of bases)
* Balefire now has a much higher ignition radius
* Balefire becomes darker the more it spreads, making it possible to gauge how much further or if at all the balefire will spread
* The comparator output range of the pile fuel rods has been adjusted, allowing rods to be ejected exactly when they turn into bred uranium rods
## Fixed
* Fixed rocket artillery turret not saving loaded ammo type/count
* Fixed crash caused by custom missile launchers operating without designator
* Fixed meltdown elementals rendering their beam in the NEI spawner screen, causing extreme lag or the game to freeze
* Fixed certain incompatibilities with Angelica, like machine models being transparent and connected texture blocks not rendering at all
* (Hopefully) fixed the issue of balefire spreading forever for good
* Fixed stirling engines not outputting into cables
* Power buffers (i.e. things that act as both providers and receivers in the same network) now have the lowest sending priority (sending priority didn't exist until now), preventing them from wasting transfer capacity by ping-ponging before all other relevant parts of the network are done transferring
* Fixed potential issue causing diodes to consume negative energy
* Limited assembler input to up to 10 attempts per ingredient, fixing a rare issue where the assembler freezes the server when pulling items

View File

@ -7,6 +7,9 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import com.hbm.util.Tuple.Pair;
import java.util.Map.Entry;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
@ -119,6 +122,68 @@ public class PowerNetMK2 {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
long timestamp = System.currentTimeMillis();
long transferCap = 100_000_000_000_000_00L;
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
long powerAvailable = 0;
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
while(provIt.hasNext()) {
Entry<IEnergyProviderMK2, Long> entry = provIt.next();
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
providers.add(new Pair(entry.getKey(), src));
if(powerAvailable < transferCap) powerAvailable += src;
}
powerAvailable = Math.min(powerAvailable, transferCap);
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length];
long totalDemand = 0;
Iterator<Entry<IEnergyReceiverMK2, Long>> recIt = receiverEntries.entrySet().iterator();
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
int p = entry.getKey().getPriority().ordinal();
receivers[p].add(new Pair(entry.getKey(), rec));
demand[p] += rec;
totalDemand += rec;
}
long receiveAmount = Math.min(powerAvailable, totalDemand);
long sendAmount = receiveAmount;
double receiveScale = (Math.min(1D, (double) receiveAmount / (double) totalDemand)); //if receiveAmount and totalDemand are not equal, scale the effective demand down (i.e. due to insufficient supply)
for(int i = ConnectionPriority.values().length - 1; i <= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
double priorityDemand = demand[i];
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand * receiveScale);
long toSend = (long) (receiveAmount * weight);
sendAmount -= entry.getKey().transferPower(toSend); //leftovers are subtracted from the intended amount to use up
}
}
for(Pair<IEnergyProviderMK2, Long> entry : providers) {
double weight = (double) entry.getValue() / (double) powerAvailable;
long toUse = (long) (sendAmount * weight);
entry.getKey().usePower(toUse);
}
}
@Deprecated public void transferPowerOld() {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
long timestamp = System.currentTimeMillis();
long transferCap = 100_000_000_000_000_00L; // that ought to be enough
@ -226,6 +291,7 @@ public class PowerNetMK2 {
}
}
//TODO: revise, use new code and hit it with a hammer until it yields
public long sendPowerDiode(long power) {
long timestamp = System.currentTimeMillis();

View File

@ -184,8 +184,12 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
if(recipe != null) {
for(AStack ingredient : recipe) {
int tracker = 0;
outer: while(!InventoryUtil.doesArrayHaveIngredients(slots, indices[0], indices[1], ingredient)) {
if(tracker++ > 10) break;
boolean found = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B