generated from NeoForgeMDKs/MDK-1.21.1-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfa2d8f
commit 4f85bc2
Showing
13 changed files
with
215 additions
and
61 deletions.
There are no files selected for viewing
9 changes: 7 additions & 2 deletions
9
src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
// 1.21.1 2025-01-12T01:35:51.697973695 Registries | ||
a2254160c3b757cc65c156058b73a4d7fcfee7af data/researchd/researchd/research/example.json | ||
// 1.21.1 2025-01-12T11:42:27.249407057 Registries | ||
1c90d9b45c6886c69a5e05f3b5b8f43ed409246f data/researchd/researchd/research/coal.json | ||
5675612b592e247a9090712849c235fedca9bcc8 data/researchd/researchd/research/copper.json | ||
9228586f51e932a81cbe989082a1395abf460d5e data/researchd/researchd/research/stick.json | ||
5d59ad6b8434e563bab7b543ab6e1b90e1dc5bfc data/researchd/researchd/research/stone.json | ||
19ef9527cf9f4017e6f1abe9717cbb27ee522af9 data/researchd/researchd/research/wood.json | ||
aa3e8393680f785192c41c83fc3f389967312dfc data/researchd/researchd/research/wooden_pickaxe.json | ||
1cdd93f8a6bb79a07d1657ef616b5bd4fbdb247d data/researchd/researchd/research_pack/end.json | ||
89ac98c63d706e87b221fe288b9947b8018976ca data/researchd/researchd/research_pack/nether.json | ||
f077b1491836c0ad25f25653e259fb15df317440 data/researchd/researchd/research_pack/overworld.json |
9 changes: 0 additions & 9 deletions
9
src/generated/resources/data/researchd/researchd/research/example.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/main/java/com/portingdeadmods/researchd/client/ResearchManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.portingdeadmods.researchd.client; | ||
|
||
import com.portingdeadmods.researchd.Researchd; | ||
import com.portingdeadmods.researchd.ResearchdRegistries; | ||
import com.portingdeadmods.researchd.api.research.Research; | ||
import com.portingdeadmods.researchd.client.screens.graph.ResearchNode; | ||
import com.portingdeadmods.researchd.registries.Researches; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.world.level.Level; | ||
|
||
import java.util.*; | ||
|
||
public class ResearchManager { | ||
private Set<Holder<Research>> researches = new HashSet<>(); | ||
private Set<ResearchNode> nodes = new HashSet<>(); | ||
private Set<ResearchNode> rootNodes; | ||
|
||
public ResearchManager(Level level) { | ||
RegistryAccess registryAccess = level.registryAccess(); | ||
HolderLookup.RegistryLookup<Research> registry = registryAccess.lookupOrThrow(ResearchdRegistries.RESEARCH_KEY); | ||
|
||
// Collect researches | ||
registry.listElements().forEach(research -> { | ||
this.researches.add(research); | ||
this.nodes.add(new ResearchNode(research)); | ||
}); | ||
|
||
for (ResearchNode node : this.nodes) { | ||
List<Holder<Research>> parents = node.getHolder().value().parents().stream() | ||
.map(registryAccess::holderOrThrow).toList(); | ||
|
||
for (Holder<Research> parentResearch : parents) { | ||
ResearchNode parentNode = getNodeByResearch(parentResearch); | ||
if (parentNode != null) { | ||
parentNode.addNext(node); | ||
} | ||
} | ||
} | ||
|
||
Set<ResearchNode> referencedNodes = new HashSet<>(); | ||
for (ResearchNode node : this.nodes) { | ||
referencedNodes.addAll(node.getNext()); | ||
} | ||
|
||
HashSet<ResearchNode> researchNodesCopy = new HashSet<>(this.nodes); | ||
researchNodesCopy.removeAll(referencedNodes); | ||
|
||
this.rootNodes = new HashSet<>(researchNodesCopy); | ||
} | ||
|
||
public void setCoordinates(int paddingX, int paddingY) { | ||
int i = 0; | ||
for (ResearchNode node : this.rootNodes) { | ||
Researchd.LOGGER.debug("root: {}", node.getHolder().getKey().location()); | ||
setCoordinate(node, paddingX + i * 40, paddingY, 0); | ||
i++; | ||
} | ||
} | ||
|
||
public void setCoordinate(ResearchNode node, int x, int y, int nesting) { | ||
Researchd.LOGGER.debug("node: {}, nesting: {}", node.getHolder().getKey().location(), nesting); | ||
node.setX(x); | ||
node.setY(y); | ||
Researchd.LOGGER.debug("y: {}", y); | ||
List<ResearchNode> next = node.getNext(); | ||
for (int i = 0; i < next.size(); i++) { | ||
ResearchNode nextNode = next.get(i); | ||
int newNesting = nesting + 1; | ||
setCoordinate(nextNode, x + i * 30, y + newNesting * 30, newNesting + 1); | ||
} | ||
} | ||
|
||
public ResearchNode getNodeByResearch(Holder<Research> research) { | ||
for (ResearchNode node : nodes) { | ||
if (node.getHolder().is(research.getKey())) { | ||
return node; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public Set<ResearchNode> getNodes() { | ||
return nodes; | ||
} | ||
|
||
public Set<Holder<Research>> getResearches() { | ||
return researches; | ||
} | ||
|
||
public Set<ResearchNode> getRootNodes() { | ||
return rootNodes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
src/main/java/com/portingdeadmods/researchd/client/screens/graph/ResearchGraph.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.