Skip to content

Commit ebd2d72

Browse files
2.0 alpha.3 (#134)
* First version of tool items update * Mining levels graph * Fix a bad mixin declaration in lifecycle events * Add RegistriesFrozenEvent * Yeet deprecated code * *actually* remove deprecated stuff * Dependency debloat (#126) * Partial dependency debloat (doesn't yet compile) * Partial dependency debloat part 2 (still doesn't compile) * Finished debloating * Use `Pair#of` instead of `Pair#new` * Remove dependency declarations * Move client-side entity registries to client.registry package. * Packet types (#123) * Implemented packet types (registry sync is broken). * Introduced blocking packets. Fixed packet types registry sync. * Re-enabled GCAPI and HMI * Use WrapOperation instead of Redirect in network * Tools API (#133) * Simpler and more flexible * More tools API documentation * Organized `TestContext#failed` into levels of BFS * Allow tool levels to be equivalent to their immediate siblings * Moved tools system implementation into mixins for easier override by custom tools. Now infinite loops during graph search are detected and logged with relevant information. * Replaced item stack effectiveness and strength events with player ones to allow for null item stack checks * Propagated more context to tool item effectiveness and strength tests * Added a method for instantiating numeric tool levels * Documentation for the resultProvider fields of tool events. * Change version --------- Co-authored-by: calmilamsy <bumbill00@gmail.com>
1 parent c61a3b6 commit ebd2d72

129 files changed

Lines changed: 1153 additions & 999 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle.kts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,15 @@ allprojects {
6565

6666
modImplementation("babric:fabric-loader:${project.properties["loader_version"]}")
6767

68-
implementation("io.github.llamalad7:mixinextras-fabric:${project.properties["mixinextras_version"]}")
69-
annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.properties["mixinextras_version"]}")
70-
7168
"transitiveImplementation"("org.apache.commons:commons-lang3:3.12.0")
7269
"transitiveImplementation"("commons-io:commons-io:2.11.0")
7370
"transitiveImplementation"("net.jodah:typetools:${project.properties["typetools_version"]}")
74-
"transitiveImplementation"("com.github.mineLdiver:expressions:${project.properties["expressions_version"]}")
7571
"transitiveImplementation"("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}")
7672
"transitiveImplementation"("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}")
7773
//noinspection GradlePackageUpdate
7874
"transitiveImplementation"("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}")
7975
"transitiveImplementation"("com.mojang:datafixerupper:${project.properties["dfu_version"]}")
8076
"transitiveImplementation"("maven.modrinth:spasm:${project.properties["spasm_version"]}")
81-
"transitiveImplementation"("com.oath.cyclops:cyclops:${project.properties["cyclops_version"]}")
8277

8378
// convenience stuff
8479
// adds some useful annotations for data classes. does not add any dependencies
@@ -95,6 +90,10 @@ allprojects {
9590
}
9691

9792
implementation("blue.endless:jankson:1.2.1")
93+
implementation("me.carleslc:Simple-Yaml:1.8.4")
94+
modLocalRuntime("net.glasslauncher.mods:glass-networking:1.0.2") {
95+
isTransitive = false
96+
}
9897
modLocalRuntime("net.glasslauncher.mods:GlassConfigAPI:${project.properties["gcapi_version"]}") {
9998
isTransitive = false
10099
}
@@ -261,18 +260,12 @@ subprojects {
261260
}
262261

263262
dependencies {
264-
include("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.properties["mixinextras_version"]}")
265263
include("net.jodah:typetools:${project.properties["typetools_version"]}")
266-
include("com.github.mineLdiver:expressions:${project.properties["expressions_version"]}")
267264
include("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}")
268265
include("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}")
269266
include("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}")
270267
include("com.mojang:datafixerupper:${project.properties["dfu_version"]}")
271268
include("maven.modrinth:spasm:${project.properties["spasm_version"]}")
272-
include("com.oath.cyclops:cyclops:${project.properties["cyclops_version"]}")
273-
include("org.reactivestreams:reactive-streams:${project.properties["reactivestreams_version"]}")
274-
include("io.kindedj:kindedj:${project.properties["kindedj_version"]}")
275-
include("org.agrona:Agrona:${project.properties["agrona_version"]}")
276269
}
277270

278271
// Makes java shut up

gradle.properties

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@ fabric.loom.multiProjectOptimisation=true
1515

1616
# Library Properties
1717
typetools_version = 0.8.3
18-
expressions_version = f676bbe
1918
unsafeevents_version = 17ac2971
2019
fastutil_version = 8.5.8
2120
caffeine_version = 3.0.5
2221
dfu_version = 6.0.6
2322
spasm_version = 0.2.2
24-
cyclops_version = 10.4.1
25-
reactivestreams_version = 1.0.0
26-
kindedj_version = 1.1.0
27-
agrona_version = 0.9.1
28-
mixinextras_version = 0.2.2
2923

3024
# Mod Properties
31-
mod_version = 2.0-alpha.2.4
25+
mod_version = 2.0-alpha.3
3226
maven_group = net.modificationstation
3327
archives_base_name = StationAPI
3428

3529
# Test properties
36-
gcapi_version = 1.3.1
30+
gcapi_version = 3.0.0
3731
hmi_version = 5.2.1
3832
modmenu_version = v1.8.5-beta.3
3933
mojangfix_version = 0.5.2

src/test/java/net/modificationstation/sltest/block/Blocks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public enum Blocks {
1818

19-
TEST_BLOCK("test_block", "testBlock", id -> new TemplateBlock(id, Material.CLAY).setHardness(1)),
19+
TEST_BLOCK("test_block", "testBlock", id -> new TemplateBlock(id, Material.STONE).setHardness(1)),
2020
TEST_ANIMATED_BLOCK("test_animated_block", "testAnimatedBlock", id -> new ModdedMetaBlock(id, Material.NETHER_PORTAL)),
2121
CUSTOM_MODEL_BLOCK("farlands_block", "farlands_block", id -> new ModdedModelBlock(id, Material.SOIL).setHardness(1)),
2222
FREEZER("freezer", "freezer", id -> new BlockFreezer(id).setHardness(2.5F).setSoundGroup(TemplateBlock.DEFAULT_SOUND_GROUP)),

src/test/java/net/modificationstation/sltest/gui/GuiListener.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
import net.minecraft.inventory.Inventory;
99
import net.modificationstation.sltest.SLTest;
1010
import net.modificationstation.sltest.tileentity.TileEntityFreezer;
11+
import net.modificationstation.stationapi.api.client.gui.screen.GuiHandler;
12+
import net.modificationstation.stationapi.api.client.registry.GuiHandlerRegistry;
1113
import net.modificationstation.stationapi.api.event.registry.GuiHandlerRegistryEvent;
12-
import net.modificationstation.stationapi.api.registry.GuiHandlerRegistry;
14+
import net.modificationstation.stationapi.api.registry.Registry;
1315
import net.modificationstation.stationapi.api.util.Identifier;
14-
import uk.co.benjiweber.expressions.tuple.BiTuple;
1516

1617
public class GuiListener {
1718

1819
@Environment(EnvType.CLIENT)
1920
@EventListener
2021
public void registerGuiHandlers(GuiHandlerRegistryEvent event) {
2122
GuiHandlerRegistry registry = event.registry;
22-
registry.registerValueNoMessage(Identifier.of(SLTest.NAMESPACE, "freezer"), BiTuple.of(this::openFreezer, TileEntityFreezer::new));
23+
Registry.register(registry, Identifier.of(SLTest.NAMESPACE, "freezer"), new GuiHandler((GuiHandler.ScreenFactoryNoMessage) this::openFreezer, TileEntityFreezer::new));
2324
}
2425

2526
@Environment(EnvType.CLIENT)

src/test/java/net/modificationstation/sltest/item/ItemListener.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
import net.modificationstation.sltest.block.Blocks;
77
import net.modificationstation.sltest.block.VariationBlock;
88
import net.modificationstation.stationapi.api.event.registry.ItemRegistryEvent;
9+
import net.modificationstation.stationapi.api.item.tool.TagToolLevel;
10+
import net.modificationstation.stationapi.api.item.tool.ToolLevel;
911
import net.modificationstation.stationapi.api.item.tool.ToolMaterialFactory;
12+
import net.modificationstation.stationapi.api.registry.BlockRegistry;
1013
import net.modificationstation.stationapi.api.registry.ItemRegistry;
1114
import net.modificationstation.stationapi.api.registry.Registry;
15+
import net.modificationstation.stationapi.api.tag.TagKey;
1216
import net.modificationstation.stationapi.api.template.item.BlockStateItem;
1317

1418
import static net.modificationstation.sltest.SLTest.NAMESPACE;
@@ -17,8 +21,16 @@ public class ItemListener {
1721

1822
@EventListener
1923
public void registerItems(ItemRegistryEvent event) {
24+
ToolLevel moddedNode = new TagToolLevel(TagKey.of(BlockRegistry.KEY, NAMESPACE.id("needs_tool_level_modded")));
25+
ToolLevel.GRAPH.putEdge(ToolMaterial.STONE.getToolLevel(), moddedNode);
26+
ToolLevel.GRAPH.putEdge(moddedNode, ToolMaterial.IRON.getToolLevel());
27+
ToolLevel siblingNode = new TagToolLevel(TagKey.of(BlockRegistry.KEY, NAMESPACE.id("needs_tool_level_sibling"))).equivalentToImmediateSiblings();
28+
ToolLevel.GRAPH.putEdge(ToolMaterial.STONE.getToolLevel(), siblingNode);
29+
ToolLevel.GRAPH.putEdge(siblingNode, ToolMaterial.IRON.getToolLevel());
30+
ToolLevel.GRAPH.removeEdge(ToolMaterial.STONE.getToolLevel(), ToolMaterial.IRON.getToolLevel());
31+
2032
testItem = new ModdedItem(NAMESPACE.id("test_item")).setTranslationKey(NAMESPACE, "testItem"); //8475
21-
testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2);
33+
testMaterial = ToolMaterialFactory.create("testMaterial", 3, Integer.MAX_VALUE, Float.MAX_VALUE, Integer.MAX_VALUE - 2).toolLevel(siblingNode);
2234
testPickaxe = new ModdedPickaxeItem(NAMESPACE.id("test_pickaxe"), testMaterial).setTranslationKey(NAMESPACE, "testPickaxe"); //8476
2335
testNBTItem = new NBTItem(NAMESPACE.id("nbt_item")).setTranslationKey(NAMESPACE, "nbt_item"); //8477
2436
testModelItem = new ModelItem(NAMESPACE.id("model_item")).setMaxCount(1).setTranslationKey(NAMESPACE, "idkSomething");
@@ -30,6 +42,8 @@ public void registerItems(ItemRegistryEvent event) {
3042
testShears = new TestShearsItem(NAMESPACE.id("test_shears")).setTranslationKey(NAMESPACE, "test_shears");
3143
pacifistSword = new PacifistSwordItem(NAMESPACE.id("pacifist_sword")).setTranslationKey(NAMESPACE, "pacifist_sword");
3244
dullPickaxe = new DullPickaxeItem(NAMESPACE.id("dull_pickaxe")).setTranslationKey(NAMESPACE, "dull_pickaxe");
45+
46+
3347
}
3448

3549
public static Item testItem;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"sltest:test_block"
4+
]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"sltest:test_block"
4+
]
5+
}

station-achievements-v0/src/main/java/net/modificationstation/stationapi/api/client/gui/screen/achievement/AchievementPage.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import net.minecraft.achievement.Achievement;
77
import net.modificationstation.stationapi.api.util.Identifier;
88
import net.modificationstation.stationapi.api.util.Namespace;
9-
import uk.co.benjiweber.expressions.property.Named;
109

1110
import java.util.ArrayList;
1211
import java.util.Collections;
@@ -17,7 +16,7 @@
1716
* Instantiates and adds an achievement page to the achievement page list.
1817
* @author calmilamsy
1918
*/
20-
public class AchievementPage implements Named<AchievementPage> {
19+
public class AchievementPage {
2120
private static final List<AchievementPage> PAGES = new ArrayList<>();
2221
private static int currentPage = 0;
2322

@@ -75,7 +74,6 @@ public int getBackgroundTexture(Random random, int column, int row, int randomiz
7574
return currentTexture;
7675
}
7776

78-
@Override
7977
public String name() {
8078
return translationKey;
8179
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.modificationstation.stationapi.api.client.gui.screen;
2+
3+
import net.minecraft.client.gui.screen.Screen;
4+
import net.minecraft.entity.player.PlayerEntity;
5+
import net.minecraft.inventory.Inventory;
6+
import net.modificationstation.stationapi.api.network.packet.MessagePacket;
7+
8+
public record GuiHandler(ScreenFactory screenFactory, InventoryFactory inventoryFactory) {
9+
@FunctionalInterface
10+
public interface ScreenFactory {
11+
Screen create(PlayerEntity player, Inventory inventory, MessagePacket packet);
12+
}
13+
14+
@FunctionalInterface
15+
public interface ScreenFactoryNoMessage extends ScreenFactory {
16+
@Override
17+
default Screen create(PlayerEntity player, Inventory inventory, MessagePacket packet) {
18+
return create(player, inventory);
19+
}
20+
21+
Screen create(PlayerEntity player, Inventory inventory);
22+
}
23+
24+
@FunctionalInterface
25+
public interface InventoryFactory {
26+
Inventory create();
27+
}
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.modificationstation.stationapi.api.client.registry;
2+
3+
import com.mojang.serialization.Lifecycle;
4+
import net.modificationstation.stationapi.api.StationAPI;
5+
import net.modificationstation.stationapi.api.client.gui.screen.GuiHandler;
6+
import net.modificationstation.stationapi.api.registry.Registries;
7+
import net.modificationstation.stationapi.api.registry.RegistryKey;
8+
import net.modificationstation.stationapi.api.registry.SimpleRegistry;
9+
import net.modificationstation.stationapi.api.util.Identifier;
10+
11+
public final class GuiHandlerRegistry extends SimpleRegistry<GuiHandler> {
12+
private static final GuiHandler EMPTY = new GuiHandler((player, inventory, packet) -> null, () -> null);
13+
public static final RegistryKey<GuiHandlerRegistry> KEY = RegistryKey.ofRegistry(Identifier.of(StationAPI.NAMESPACE, "gui_handlers"));
14+
public static final GuiHandlerRegistry INSTANCE = Registries.create(KEY, new GuiHandlerRegistry(), registry -> EMPTY, Lifecycle.experimental());
15+
16+
private GuiHandlerRegistry() {
17+
super(KEY, Lifecycle.experimental(), false);
18+
}
19+
}

0 commit comments

Comments
 (0)