the de-genericizing

This commit is contained in:
Boblet 2025-02-20 16:55:46 +01:00
parent e6e11a3a1c
commit d20c190c3e
6 changed files with 52 additions and 38 deletions

View File

@ -1,9 +1,12 @@
## Changed ## Changed
* Updated russian localization
* Large deposits (hematite, malachite, bauxite) and caves (sulfur, asbestos) can now be toggled in the config * Large deposits (hematite, malachite, bauxite) and caves (sulfur, asbestos) can now be toggled in the config
* Removed recipes for most old particle accelerator parts * Removed recipes for most old particle accelerator parts
* Dense coils no longer have recipes either for the most part, all coils with no recipes can be recycled back into dense wires * Dense coils no longer have recipes either for the most part, all coils with no recipes can be recycled back into dense wires
* Natural gas can now be processed in a pyrolysis oven, 12k of gas yields 8k hydrogen and one graphite ingot * Natural gas can now be processed in a pyrolysis oven, 12k of gas yields 8k hydrogen and one graphite ingot
* Saturnite now has an alternate recipe, adding one pile of borax for doubled output
## Fixed ## Fixed
* Fixed an issue where `/ntmreload` would load fluids after recipes, meaning that recipes using newly added fluids would not work correctly, as the fluids don't exist by the time the recipe is loaded * Fixed an issue where `/ntmreload` would load fluids after recipes, meaning that recipes using newly added fluids would not work correctly, as the fluids don't exist by the time the recipe is loaded
* Fixed bedrock coltan being way too common, drowning out almost all other bedrock ores * Fixed bedrock coltan being way too common, drowning out almost all other bedrock ores
* Fixed rotary furnace not saving its output stack

View File

@ -47,6 +47,7 @@ public class RotaryFurnaceRecipes extends SerializableRecipe {
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_GUNMETAL, INGOT.q(4)), 200, 100, new OreDictStack(CU.ingot(), 3), new OreDictStack(AL.ingot(), 1))); recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_GUNMETAL, INGOT.q(4)), 200, 100, new OreDictStack(CU.ingot(), 3), new OreDictStack(AL.ingot(), 1)));
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_WEAPONSTEEL, INGOT.q(1)), 200, 400, new FluidStack(Fluids.GAS_COKER, 100), new OreDictStack(STEEL.ingot(), 1), new ComparableStack(ModItems.powder_flux, 2))); recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_WEAPONSTEEL, INGOT.q(1)), 200, 400, new FluidStack(Fluids.GAS_COKER, 100), new OreDictStack(STEEL.ingot(), 1), new ComparableStack(ModItems.powder_flux, 2)));
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_SATURN, INGOT.q(2)), 200, 400, new FluidStack(Fluids.REFORMGAS, 250), new OreDictStack(DURA.dust(), 4), new OreDictStack(CU.dust()))); recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_SATURN, INGOT.q(2)), 200, 400, new FluidStack(Fluids.REFORMGAS, 250), new OreDictStack(DURA.dust(), 4), new OreDictStack(CU.dust())));
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_SATURN, INGOT.q(4)), 200, 300, new FluidStack(Fluids.REFORMGAS, 250), new OreDictStack(DURA.dust(), 4), new OreDictStack(CU.dust()), new OreDictStack(BORAX.dust())));
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_ALUMINIUM, INGOT.q(2)), 100, 400, new FluidStack(Fluids.SODIUM_ALUMINATE, 150))); recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_ALUMINIUM, INGOT.q(2)), 100, 400, new FluidStack(Fluids.SODIUM_ALUMINATE, 150)));
recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_ALUMINIUM, INGOT.q(3)), 40, 200, new FluidStack(Fluids.SODIUM_ALUMINATE, 150), new ComparableStack(ModItems.powder_flux, 2))); recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_ALUMINIUM, INGOT.q(3)), 40, 200, new FluidStack(Fluids.SODIUM_ALUMINATE, 150), new ComparableStack(ModItems.powder_flux, 2)));
} }

View File

@ -3,26 +3,26 @@ package com.hbm.uninos;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
public class GenNode<T extends INetworkProvider> { public class GenNode {
public BlockPos[] positions; public BlockPos[] positions;
public DirPos[] connections; public DirPos[] connections;
public NodeNet<T> net; public NodeNet net;
public boolean expired = false; public boolean expired = false;
public boolean recentlyChanged = true; public boolean recentlyChanged = true;
public T networkProvider; public INetworkProvider networkProvider;
public GenNode(T provider, BlockPos... positions) { public GenNode(INetworkProvider provider, BlockPos... positions) {
this.networkProvider = provider; this.networkProvider = provider;
this.positions = positions; this.positions = positions;
} }
public GenNode<T> setConnections(DirPos... connections) { public GenNode setConnections(DirPos... connections) {
this.connections = connections; this.connections = connections;
return this; return this;
} }
public GenNode<T> addConnection(DirPos connection) { public GenNode addConnection(DirPos connection) {
DirPos[] newCons = new DirPos[this.connections.length + 1]; DirPos[] newCons = new DirPos[this.connections.length + 1];
for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i]; for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i];
newCons[newCons.length - 1] = connection; newCons[newCons.length - 1] = connection;
@ -34,7 +34,7 @@ public class GenNode<T extends INetworkProvider> {
return this.net != null && this.net.isValid(); return this.net != null && this.net.isValid();
} }
public void setNet(NodeNet<T> net) { public void setNet(NodeNet net) {
this.net = net; this.net = net;
this.recentlyChanged = true; this.recentlyChanged = true;
} }

View File

@ -7,60 +7,60 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
public abstract class NodeNet<T extends INetworkProvider> { public abstract class NodeNet {
public static Random rand = new Random(); public static Random rand = new Random();
public boolean valid = true; public boolean valid = true;
public Set<GenNode<T>> links = new HashSet(); public Set<GenNode> links = new HashSet();
public abstract HashMap<IGenReceiver<T>, Long> receiverEntries(); public abstract HashMap<IGenReceiver, Long> receiverEntries();
public abstract HashMap<IGenProvider<T>, Long> providerEntries(); public abstract HashMap<IGenProvider, Long> providerEntries();
public NodeNet() { public NodeNet() {
UniNodespace.activeNodeNets.add(this); UniNodespace.activeNodeNets.add(this);
} }
/// SUBSCRIBER HANDLING /// /// SUBSCRIBER HANDLING ///
public boolean isSubscribed(IGenReceiver<T> receiver) { return this.receiverEntries().containsKey(receiver); } public boolean isSubscribed(IGenReceiver receiver) { return this.receiverEntries().containsKey(receiver); }
public void addReceiver(IGenReceiver<T> receiver) { this.receiverEntries().put(receiver, System.currentTimeMillis()); } public void addReceiver(IGenReceiver receiver) { this.receiverEntries().put(receiver, System.currentTimeMillis()); }
public void removeReceiver(IGenReceiver<T> receiver) { this.receiverEntries().remove(receiver); } public void removeReceiver(IGenReceiver receiver) { this.receiverEntries().remove(receiver); }
/// PROVIDER HANDLING /// /// PROVIDER HANDLING ///
public boolean isProvider(IGenProvider<T> provider) { return this.providerEntries().containsKey(provider); } public boolean isProvider(IGenProvider provider) { return this.providerEntries().containsKey(provider); }
public void addProvider(IGenProvider<T> provider) { this.providerEntries().put(provider, System.currentTimeMillis()); } public void addProvider(IGenProvider provider) { this.providerEntries().put(provider, System.currentTimeMillis()); }
public void removeProvider(IGenProvider<T> provider) { this.providerEntries().remove(provider); } public void removeProvider(IGenProvider provider) { this.providerEntries().remove(provider); }
/** Combines two networks into one */ /** Combines two networks into one */
public void joinNetworks(NodeNet<T> network) { public void joinNetworks(NodeNet network) {
if(network == this) return; if(network == this) return;
List<GenNode<T>> oldNodes = new ArrayList(network.links.size()); List<GenNode> oldNodes = new ArrayList(network.links.size());
oldNodes.addAll(network.links); oldNodes.addAll(network.links);
for(GenNode<T> conductor : oldNodes) forceJoinLink(conductor); for(GenNode conductor : oldNodes) forceJoinLink(conductor);
network.links.clear(); network.links.clear();
for(IGenReceiver<T> connector : network.receiverEntries().keySet()) this.addReceiver(connector); for(IGenReceiver connector : network.receiverEntries().keySet()) this.addReceiver(connector);
for(IGenProvider<T> connector : network.providerEntries().keySet()) this.addProvider(connector); for(IGenProvider connector : network.providerEntries().keySet()) this.addProvider(connector);
network.destroy(); network.destroy();
} }
/** Adds the node as part of this network's links */ /** Adds the node as part of this network's links */
public NodeNet<T> joinLink(GenNode<T> node) { public NodeNet joinLink(GenNode node) {
if(node.net != null) node.net.leaveLink(node); if(node.net != null) node.net.leaveLink(node);
return forceJoinLink(node); return forceJoinLink(node);
} }
/** Adds the node as part of this network's links, skips the part about removing it from existing networks */ /** Adds the node as part of this network's links, skips the part about removing it from existing networks */
public NodeNet<T> forceJoinLink(GenNode<T> node) { public NodeNet forceJoinLink(GenNode node) {
this.links.add(node); this.links.add(node);
node.setNet(this); node.setNet(this);
return this; return this;
} }
/** Removes the specified node */ /** Removes the specified node */
public void leaveLink(GenNode<T> node) { public void leaveLink(GenNode node) {
node.setNet(null); node.setNet(null);
this.links.remove(node); this.links.remove(node);
} }
@ -73,7 +73,7 @@ public abstract class NodeNet<T extends INetworkProvider> {
public void destroy() { public void destroy() {
this.invalidate(); this.invalidate();
for(GenNode<T> link : this.links) if(link.net == this) link.setNet(null); for(GenNode link : this.links) if(link.net == this) link.setNet(null);
this.links.clear(); this.links.clear();
this.receiverEntries().clear(); this.receiverEntries().clear();
this.providerEntries().clear(); this.providerEntries().clear();

View File

@ -38,7 +38,7 @@ public class UniNodespace {
public static class UniNodeWorld { public static class UniNodeWorld {
public HashMap<Pair<BlockPos, INetworkProvider>, GenNode<INetworkProvider>> nodes = new HashMap(); public HashMap<Pair<BlockPos, INetworkProvider>, GenNode> nodes = new HashMap();
/** Adds a node at all its positions to the nodespace */ /** Adds a node at all its positions to the nodespace */
public void pushNode(GenNode node) { public void pushNode(GenNode node) {

View File

@ -6,31 +6,41 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.hbm.uninos.IGenProvider;
import com.hbm.uninos.IGenReceiver;
import com.hbm.uninos.NodeNet; import com.hbm.uninos.NodeNet;
import com.hbm.uninos.networkproviders.PowerProvider;
import com.hbm.util.Tuple.Pair; import com.hbm.util.Tuple.Pair;
import api.hbm.energymk2.IEnergyProviderMK2; import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority; import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
public class PowerNetwork extends NodeNet<PowerProvider> { public class PowerNetwork extends NodeNet {
/*
* the original idea was to have every part have a generic type <? extends INetworkProvider> so that once you get down to the level of nodes, you can
* still easily create new networks using the generic type. however:
* - having generics everywhere means that some overrides don't work due to "not being castable" (my ass)
* - most of the time, having generics there didn't really do anything, since the interface is already universally usable, and the type that is provided doesn't actually matter
* - for any case where network type does matter, any node handling instance (cable TEs for example) can just do handling separately, worst case it's just one extra cast
* my balls hurt
*/
public HashMap<IEnergyReceiverMK2, Long> receiverEntries = new HashMap(); public HashMap<IEnergyReceiverMK2, Long> receiverEntries = new HashMap();
public HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap(); public HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap();
public long energyTracker = 0L; public long energyTracker = 0L;
@Override // this was all fun and games but let's take a few steps back: this generics stuff is kinda breaking shit, and as it turns out, apparently nothing even uses the type @Override
public HashMap<IGenReceiver<PowerProvider>, Long> receiverEntries() { public HashMap receiverEntries() {
return null; return receiverEntries;
// generic type erasure seems susipcious here - this either works because the types should be castable anyway,
// or this doesn't work because the compiler has an aneurysm and dies instantly
// technically, generics are obliterated when compiling, and the types are assignable, so i see no issue,
// but then again, HashMap *technically* isn't castable to HashMap<T>, and the compiler might scream about it
} }
@Override // therefore i should probably consider scrapping the majority of the generic types - they seem to be kinda useless with the current approach @Override
public HashMap<IGenProvider<PowerProvider>, Long> providerEntries() { public HashMap providerEntries() {
return null; return providerEntries;
} }
protected static int timeout = 3_000; protected static int timeout = 3_000;