-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool items update #109
Comments
The idea is that each level node is only aware of its predecessors and can have multiple of them. In code, if tool material only specifies a numeric mining level, it'll stick to the default branch (vanilla + extended). Any level node can be modified at any time to get more predecessors, including vanilla nodes. Feedback is greatly appreciated. |
Draft implementation without extended levelsimport java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
public class Main {
static MiningNode[] VANILLA_NODES = new MiningNode[4];
static {
var base = new MiningNode(Optional.empty(), Set.of());
var stone = new MiningNode(Optional.of(new BlockTag("needs_stone_tool")), set(base));
var iron = new MiningNode(Optional.of(new BlockTag("needs_iron_tool")), set(stone));
var diamond = new MiningNode(Optional.of(new BlockTag("needs_diamond_tool")), set(iron));
VANILLA_NODES[0] = base;
VANILLA_NODES[1] = stone;
VANILLA_NODES[2] = iron;
VANILLA_NODES[3] = diamond;
}
@SafeVarargs
static <T> Set<T> set(T... elements) {
return new HashSet<>(Arrays.asList(elements));
}
public static void main(String[] args) {
var myLevel1 = new MiningNode(Optional.of(new BlockTag("needs_my_tool_level_1")), set(VANILLA_NODES[1]));
var myLevel2 = new MiningNode(Optional.of(new BlockTag("needs_my_tool_level_2")), set(myLevel1));
var myLevel3 = new MiningNode(Optional.of(new BlockTag("needs_my_tool_level_3")), set(myLevel2));
VANILLA_NODES[2].predecessors().add(myLevel3);
System.out.println(VANILLA_NODES[1].contains(new BlockTag("needs_my_tool_level_2")));
System.out.println(VANILLA_NODES[2].contains(new BlockTag("needs_my_tool_level_2")));
}
record ToolMaterial(
int miningLevel,
int itemDurability,
float miningSpeed,
int attackDamage,
Optional<MiningNode> miningNode
) {
MiningNode getNode() {
return miningNode.orElseGet(() -> VANILLA_NODES[miningLevel]);
}
}
record MiningNode(
Optional<BlockTag> tag,
Set<MiningNode> predecessors
) {
boolean contains(BlockTag otherTag) {
return (tag.isPresent() && tag.get().equals(otherTag)) || predecessors.stream().anyMatch(predecessor -> predecessor.contains(otherTag));
}
}
record BlockTag(String id) {}
} |
Actual implementation turned out to be way easier thanks to tags that basically replace the Implementation is being worked on at https://github.com/ModificationStation/StationAPI/tree/2.0-alpha.3 |
Current StationAPI tool items system is convoluted and broken.
There aren't solid plans on how to reimplement the system.
Discussion is welcome.
The text was updated successfully, but these errors were encountered: