From d20c190c3e6fb0b80b28a1d344c05497d8a1571f Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 20 Feb 2025 16:55:46 +0100 Subject: [PATCH] the de-genericizing --- changelog | 5 ++- .../recipes/RotaryFurnaceRecipes.java | 1 + src/main/java/com/hbm/uninos/GenNode.java | 14 +++---- src/main/java/com/hbm/uninos/NodeNet.java | 38 +++++++++---------- .../java/com/hbm/uninos/UniNodespace.java | 2 +- .../com/hbm/uninos/networks/PowerNetwork.java | 30 ++++++++++----- 6 files changed, 52 insertions(+), 38 deletions(-) diff --git a/changelog b/changelog index 46e6eac40..c8853896b 100644 --- a/changelog +++ b/changelog @@ -1,9 +1,12 @@ ## Changed +* Updated russian localization * Large deposits (hematite, malachite, bauxite) and caves (sulfur, asbestos) can now be toggled in the config * 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 * 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 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 \ No newline at end of file +* Fixed bedrock coltan being way too common, drowning out almost all other bedrock ores +* Fixed rotary furnace not saving its output stack \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java b/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java index 8efe4b2ee..981df895e 100644 --- a/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java @@ -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_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(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(3)), 40, 200, new FluidStack(Fluids.SODIUM_ALUMINATE, 150), new ComparableStack(ModItems.powder_flux, 2))); } diff --git a/src/main/java/com/hbm/uninos/GenNode.java b/src/main/java/com/hbm/uninos/GenNode.java index cc7f028c3..b0337c119 100644 --- a/src/main/java/com/hbm/uninos/GenNode.java +++ b/src/main/java/com/hbm/uninos/GenNode.java @@ -3,26 +3,26 @@ package com.hbm.uninos; import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.DirPos; -public class GenNode { +public class GenNode { public BlockPos[] positions; public DirPos[] connections; - public NodeNet net; + public NodeNet net; public boolean expired = false; 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.positions = positions; } - public GenNode setConnections(DirPos... connections) { + public GenNode setConnections(DirPos... connections) { this.connections = connections; return this; } - public GenNode addConnection(DirPos connection) { + public GenNode addConnection(DirPos connection) { DirPos[] newCons = new DirPos[this.connections.length + 1]; for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i]; newCons[newCons.length - 1] = connection; @@ -34,7 +34,7 @@ public class GenNode { return this.net != null && this.net.isValid(); } - public void setNet(NodeNet net) { + public void setNet(NodeNet net) { this.net = net; this.recentlyChanged = true; } diff --git a/src/main/java/com/hbm/uninos/NodeNet.java b/src/main/java/com/hbm/uninos/NodeNet.java index c40d41a3e..34e647196 100644 --- a/src/main/java/com/hbm/uninos/NodeNet.java +++ b/src/main/java/com/hbm/uninos/NodeNet.java @@ -7,60 +7,60 @@ import java.util.List; import java.util.Random; import java.util.Set; -public abstract class NodeNet { +public abstract class NodeNet { public static Random rand = new Random(); public boolean valid = true; - public Set> links = new HashSet(); + public Set links = new HashSet(); - public abstract HashMap, Long> receiverEntries(); - public abstract HashMap, Long> providerEntries(); + public abstract HashMap receiverEntries(); + public abstract HashMap providerEntries(); public NodeNet() { UniNodespace.activeNodeNets.add(this); } /// SUBSCRIBER HANDLING /// - public boolean isSubscribed(IGenReceiver receiver) { return this.receiverEntries().containsKey(receiver); } - public void addReceiver(IGenReceiver receiver) { this.receiverEntries().put(receiver, System.currentTimeMillis()); } - public void removeReceiver(IGenReceiver receiver) { this.receiverEntries().remove(receiver); } + public boolean isSubscribed(IGenReceiver receiver) { return this.receiverEntries().containsKey(receiver); } + public void addReceiver(IGenReceiver receiver) { this.receiverEntries().put(receiver, System.currentTimeMillis()); } + public void removeReceiver(IGenReceiver receiver) { this.receiverEntries().remove(receiver); } /// PROVIDER HANDLING /// - public boolean isProvider(IGenProvider provider) { return this.providerEntries().containsKey(provider); } - public void addProvider(IGenProvider provider) { this.providerEntries().put(provider, System.currentTimeMillis()); } - public void removeProvider(IGenProvider provider) { this.providerEntries().remove(provider); } + public boolean isProvider(IGenProvider provider) { return this.providerEntries().containsKey(provider); } + public void addProvider(IGenProvider provider) { this.providerEntries().put(provider, System.currentTimeMillis()); } + public void removeProvider(IGenProvider provider) { this.providerEntries().remove(provider); } /** Combines two networks into one */ - public void joinNetworks(NodeNet network) { + public void joinNetworks(NodeNet network) { if(network == this) return; - List> oldNodes = new ArrayList(network.links.size()); + List oldNodes = new ArrayList(network.links.size()); oldNodes.addAll(network.links); - for(GenNode conductor : oldNodes) forceJoinLink(conductor); + for(GenNode conductor : oldNodes) forceJoinLink(conductor); network.links.clear(); - for(IGenReceiver connector : network.receiverEntries().keySet()) this.addReceiver(connector); - for(IGenProvider connector : network.providerEntries().keySet()) this.addProvider(connector); + for(IGenReceiver connector : network.receiverEntries().keySet()) this.addReceiver(connector); + for(IGenProvider connector : network.providerEntries().keySet()) this.addProvider(connector); network.destroy(); } /** Adds the node as part of this network's links */ - public NodeNet joinLink(GenNode node) { + public NodeNet joinLink(GenNode node) { if(node.net != null) node.net.leaveLink(node); return forceJoinLink(node); } /** Adds the node as part of this network's links, skips the part about removing it from existing networks */ - public NodeNet forceJoinLink(GenNode node) { + public NodeNet forceJoinLink(GenNode node) { this.links.add(node); node.setNet(this); return this; } /** Removes the specified node */ - public void leaveLink(GenNode node) { + public void leaveLink(GenNode node) { node.setNet(null); this.links.remove(node); } @@ -73,7 +73,7 @@ public abstract class NodeNet { public void destroy() { this.invalidate(); - for(GenNode 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.receiverEntries().clear(); this.providerEntries().clear(); diff --git a/src/main/java/com/hbm/uninos/UniNodespace.java b/src/main/java/com/hbm/uninos/UniNodespace.java index f0e9e7ffd..aa92b1d1a 100644 --- a/src/main/java/com/hbm/uninos/UniNodespace.java +++ b/src/main/java/com/hbm/uninos/UniNodespace.java @@ -38,7 +38,7 @@ public class UniNodespace { public static class UniNodeWorld { - public HashMap, GenNode> nodes = new HashMap(); + public HashMap, GenNode> nodes = new HashMap(); /** Adds a node at all its positions to the nodespace */ public void pushNode(GenNode node) { diff --git a/src/main/java/com/hbm/uninos/networks/PowerNetwork.java b/src/main/java/com/hbm/uninos/networks/PowerNetwork.java index 174f553a9..9c68b0cda 100644 --- a/src/main/java/com/hbm/uninos/networks/PowerNetwork.java +++ b/src/main/java/com/hbm/uninos/networks/PowerNetwork.java @@ -6,31 +6,41 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; -import com.hbm.uninos.IGenProvider; -import com.hbm.uninos.IGenReceiver; import com.hbm.uninos.NodeNet; -import com.hbm.uninos.networkproviders.PowerProvider; import com.hbm.util.Tuple.Pair; import api.hbm.energymk2.IEnergyProviderMK2; import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority; -public class PowerNetwork extends NodeNet { +public class PowerNetwork extends NodeNet { + + /* + * the original idea was to have every part have a generic type 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 receiverEntries = new HashMap(); public HashMap providerEntries = new HashMap(); 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 - public HashMap, Long> receiverEntries() { - return null; + @Override + public HashMap receiverEntries() { + 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, 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 - public HashMap, Long> providerEntries() { - return null; + @Override + public HashMap providerEntries() { + return providerEntries; } protected static int timeout = 3_000;