diff --git a/legacy-fabric-api-base/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-api-base/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 33c617a66..000000000 --- a/legacy-fabric-api-base/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-api-base-testmod", - "name": "Legacy Fabric API Base Test Mod", - "version": "1.0.0", - "environment": "*", - "license": "Apache-2.0", - "entrypoints": { - "main": [] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-command-api-v1/common/src/testmod/resources/fabric.mod.json b/legacy-fabric-command-api-v1/common/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 7af4a7f70..000000000 --- a/legacy-fabric-command-api-v1/common/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-command-api-v1-testmod", - "description": "Tests for api features", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.command.CommandV1Test" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-command-api-v2/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-command-api-v2/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 255852242..000000000 --- a/legacy-fabric-command-api-v2/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-command-api-v2-testmod", - "description": "Tests for api features", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.command.SpongeCommandTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-command-api-v2/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-command-api-v2/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index b8b0d6131..000000000 --- a/legacy-fabric-command-api-v2/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-sponge-command-api-v2-testmod", - "description": "Tests for api features", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.command.SpongeCommandTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-command-api-v2/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-command-api-v2/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 255852242..000000000 --- a/legacy-fabric-command-api-v2/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-command-api-v2-testmod", - "description": "Tests for api features", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.command.SpongeCommandTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-entity-events-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-entity-events-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 8fdf9ae34..000000000 --- a/legacy-fabric-entity-events-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-entity-events-v1-testmod", - "description": "Tests for entity events", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.entity.EntityEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-entity-events-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-entity-events-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 8fdf9ae34..000000000 --- a/legacy-fabric-entity-events-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-entity-events-v1-testmod", - "description": "Tests for entity events", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.entity.EntityEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-entity-events-v1/1.9.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-entity-events-v1/1.9.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 8fdf9ae34..000000000 --- a/legacy-fabric-entity-events-v1/1.9.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-entity-events-v1-testmod", - "description": "Tests for entity events", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.entity.EntityEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang b/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang deleted file mode 100644 index 92e649b84..000000000 --- a/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang +++ /dev/null @@ -1 +0,0 @@ -itemGroup.dmn.testgroup=Test Group by DomamaN202 diff --git a/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index ffa7dbef4..000000000 --- a/legacy-fabric-item-groups-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-item-groups-v0-testmod", - "description": "Tests for Item Groups", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.item.group.ItemGroupTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang deleted file mode 100644 index 92e649b84..000000000 --- a/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang +++ /dev/null @@ -1 +0,0 @@ -itemGroup.dmn.testgroup=Test Group by DomamaN202 diff --git a/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index ffa7dbef4..000000000 --- a/legacy-fabric-item-groups-v1/1.6.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-item-groups-v0-testmod", - "description": "Tests for Item Groups", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.item.group.ItemGroupTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang deleted file mode 100644 index 92e649b84..000000000 --- a/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang +++ /dev/null @@ -1 +0,0 @@ -itemGroup.dmn.testgroup=Test Group by DomamaN202 diff --git a/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index ffa7dbef4..000000000 --- a/legacy-fabric-item-groups-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-item-groups-v0-testmod", - "description": "Tests for Item Groups", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.item.group.ItemGroupTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-keybindings-api-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index b9c55e26f..000000000 --- a/legacy-fabric-keybindings-api-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-keybinding-api-v1-testmod", - "description": "Tests for keybindings", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.6.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-keybindings-api-v1/1.6.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 0033bc2ec..000000000 --- a/legacy-fabric-keybindings-api-v1/1.6.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-keybinding-api-v1-testmod", - "description": "Tests for keybindings", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}", - "legacy-fabric-keybinding-api-v1": "*", - "legacy-fabric-lifecycle-events-v1-common": "*" - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.7.10/build.gradle b/legacy-fabric-keybindings-api-v1/1.7.10/build.gradle deleted file mode 100644 index e69de29bb..000000000 diff --git a/legacy-fabric-keybindings-api-v1/1.7.10/gradle.properties b/legacy-fabric-keybindings-api-v1/1.7.10/gradle.properties deleted file mode 100644 index af031afbf..000000000 --- a/legacy-fabric-keybindings-api-v1/1.7.10/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -minVersionIncluded=1.7.10 -maxVersionIncluded=1.7.10 diff --git a/legacy-fabric-keybindings-api-v1/1.7.10/src/main/resources/fabric.mod.json b/legacy-fabric-keybindings-api-v1/1.7.10/src/main/resources/fabric.mod.json deleted file mode 100644 index 17813b87b..000000000 --- a/legacy-fabric-keybindings-api-v1/1.7.10/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-keybinding-api-v1", - "name": "Legacy Fabric Keybinding API (V1)", - "version": "${version}", - "environment": "client", - "license": "Apache-2.0", - "icon": "assets/legacy-fabric-api/icon.png", - "contact": { - "homepage": "https://legacyfabric.net/", - "issues": "https://github.com/Legacy-Fabric/fabric/issues", - "sources": "https://github.com/Legacy-Fabric/fabric" - }, - "authors": [ - "Legacy Fabric", - "FabricMC" - ], - "depends": { - "minecraft": "${minecraft_version}" - }, - "mixins": [], - "description": "Hooks that help adding keybindings", - "custom": { - "modmenu": { - "badges": [ "library" ], - "parent": { - "id": "legacy-fabric-api", - "name": "Legacy Fabric API", - "badges": [ "library" ], - "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", - "icon": "assets/legacy-fabric-api/icon.png" - } - } - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-keybindings-api-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 0033bc2ec..000000000 --- a/legacy-fabric-keybindings-api-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-keybinding-api-v1-testmod", - "description": "Tests for keybindings", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}", - "legacy-fabric-keybinding-api-v1": "*", - "legacy-fabric-lifecycle-events-v1-common": "*" - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.8.9/gradle.properties b/legacy-fabric-keybindings-api-v1/1.8.9/gradle.properties index 5afbd66bd..c7fb3b261 100644 --- a/legacy-fabric-keybindings-api-v1/1.8.9/gradle.properties +++ b/legacy-fabric-keybindings-api-v1/1.8.9/gradle.properties @@ -1,2 +1,2 @@ -minVersionIncluded=1.8 +minVersionIncluded=1.7.10 maxVersionIncluded=1.11.2 diff --git a/legacy-fabric-keybindings-api-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-keybindings-api-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index b9c55e26f..000000000 --- a/legacy-fabric-keybindings-api-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-keybinding-api-v1-testmod", - "description": "Tests for keybindings", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 3ff8b8978..000000000 --- a/legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-lifecycle-events-v1-testmod", - "description": "Tests for lifecycle events", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 3ff8b8978..000000000 --- a/legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-lifecycle-events-v1-testmod", - "description": "Tests for lifecycle events", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 3ff8b8978..000000000 --- a/legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-lifecycle-events-v1-testmod", - "description": "Tests for lifecycle events", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 3ff8b8978..000000000 --- a/legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-lifecycle-events-v1-testmod", - "description": "Tests for lifecycle events", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-lifecycle-events-v1/common/src/testmod/resources/fabric.mod.json b/legacy-fabric-lifecycle-events-v1/common/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 23c4a9fab..000000000 --- a/legacy-fabric-lifecycle-events-v1/common/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-lifecycle-events-v1-common-testmod", - "description": "Tests for lifecycle events", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest" - ], - "client": [ - "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsCommonTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-networking-api-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-networking-api-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index be761589d..000000000 --- a/legacy-fabric-networking-api-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-networking-api-v1-testmod", - "description": "Tests for networking", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.network.ServerNetworkingTest" - ], - "client": [ - "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-networking-api-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-networking-api-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index be761589d..000000000 --- a/legacy-fabric-networking-api-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-networking-api-v1-testmod", - "description": "Tests for networking", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.network.ServerNetworkingTest" - ], - "client": [ - "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-networking-api-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-networking-api-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index be761589d..000000000 --- a/legacy-fabric-networking-api-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-networking-api-v1-testmod", - "description": "Tests for networking", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.network.ServerNetworkingTest" - ], - "client": [ - "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.10.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.10.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.10.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.7.10/src/main/resources/registrysync.accesswidener b/legacy-fabric-registry-sync-api-v1/1.7.10/src/main/resources/registrysync.accesswidener index be5a8fb24..45ae69ced 100644 --- a/legacy-fabric-registry-sync-api-v1/1.7.10/src/main/resources/registrysync.accesswidener +++ b/legacy-fabric-registry-sync-api-v1/1.7.10/src/main/resources/registrysync.accesswidener @@ -1,3 +1,3 @@ -accessWidener v1 named +accessWidener v2 named -accessible method net/minecraft/block/Block (Lnet/minecraft/block/material/Material;)V +transitive-accessible method net/minecraft/block/Block (Lnet/minecraft/block/material/Material;)V diff --git a/legacy-fabric-registry-sync-api-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.8/src/main/resources/registrysync.accesswidener b/legacy-fabric-registry-sync-api-v1/1.8/src/main/resources/registrysync.accesswidener index be5a8fb24..45ae69ced 100644 --- a/legacy-fabric-registry-sync-api-v1/1.8/src/main/resources/registrysync.accesswidener +++ b/legacy-fabric-registry-sync-api-v1/1.8/src/main/resources/registrysync.accesswidener @@ -1,3 +1,3 @@ -accessWidener v1 named +accessWidener v2 named -accessible method net/minecraft/block/Block (Lnet/minecraft/block/material/Material;)V +transitive-accessible method net/minecraft/block/Block (Lnet/minecraft/block/material/Material;)V diff --git a/legacy-fabric-registry-sync-api-v1/1.8/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.8/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.8/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/1.9.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/1.9.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index d6b0884ad..000000000 --- a/legacy-fabric-registry-sync-api-v1/1.9.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [ - "net.legacyfabric.fabric.test.registry.RegistryTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/fabric.mod.json b/legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 55fab3b5e..000000000 --- a/legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-registry-sync-api-v1-testmod-common", - "description": "Tests for registry", - "version": "1.0.0", - "entrypoints": { - "main": [] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-rendering-api-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-rendering-api-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 70b0ecd70..000000000 --- a/legacy-fabric-rendering-api-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-rendering-api-v1-testmod", - "description": "Tests for rendering hooks", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index e78f5cdac..000000000 --- a/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-rendering-api-v1-testmod", - "description": "Tests for rendering hooks", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", - "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.10.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.10.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.10.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.12.2/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.12.2/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.12.2/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.6.4/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.6.4/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.6.4/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.7.10/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.7.10/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.7.10/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.8.9/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.8.9/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.8.9/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-resource-loader-v1/1.8/src/testmod/resources/fabric.mod.json b/legacy-fabric-resource-loader-v1/1.8/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 5f42c7640..000000000 --- a/legacy-fabric-resource-loader-v1/1.8/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schemaVersion": 1, - "id": "legacy-fabric-resource-loader-v1-testmod", - "description": "Tests for resource loading", - "version": "1.0.0", - "entrypoints": { - "client": [ - "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest" - ] - }, - "depends": { - "minecraft": "${minecraft_version}" - } -} diff --git a/legacy-fabric-keybindings-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java similarity index 100% rename from legacy-fabric-keybindings-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java diff --git a/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java similarity index 100% rename from legacy-fabric-rendering-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java diff --git a/legacy-fabric-rendering-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java similarity index 100% rename from legacy-fabric-rendering-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java diff --git a/legacy-fabric-command-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java similarity index 100% rename from legacy-fabric-command-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java diff --git a/legacy-fabric-command-api-v2/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java similarity index 100% rename from legacy-fabric-command-api-v2/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java diff --git a/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..1f0c11714 --- /dev/null +++ b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void method_3279(MinecraftServer minecraftServer, CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } +} diff --git a/legacy-fabric-command-api-v2/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java similarity index 100% rename from legacy-fabric-command-api-v2/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java diff --git a/legacy-fabric-entity-events-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java similarity index 100% rename from legacy-fabric-entity-events-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java diff --git a/legacy-fabric-item-groups-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java similarity index 100% rename from legacy-fabric-item-groups-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java diff --git a/legacy-fabric-lifecycle-events-v1/common/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java similarity index 100% rename from legacy-fabric-lifecycle-events-v1/common/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java diff --git a/legacy-fabric-lifecycle-events-v1/common/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsCommonTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java similarity index 83% rename from legacy-fabric-lifecycle-events-v1/common/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsCommonTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java index 2e26e0403..f40555b83 100644 --- a/legacy-fabric-lifecycle-events-v1/common/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsCommonTest.java +++ b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -23,14 +23,21 @@ import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; -public class ClientLifecycleEventsCommonTest implements ClientModInitializer { +public class ClientLifecycleEventsTest implements ClientModInitializer { private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); @Override public void onInitializeClient() { + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + LOGGER.info("Client started"); + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + LOGGER.info("Client stopping"); + }); ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { if (chunk != null) { LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); diff --git a/legacy-fabric-networking-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java diff --git a/legacy-fabric-networking-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java diff --git a/legacy-fabric-registry-sync-api-v1/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacy-fabric-resource-loader-v1/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.10.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacy-fabric-rendering-api-v1/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json similarity index 100% rename from legacy-fabric-rendering-api-v1/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json rename to legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json diff --git a/legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json similarity index 100% rename from legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json rename to legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json diff --git a/legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png similarity index 100% rename from legacy-fabric-registry-sync-api-v1/common/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png rename to legacyfabric-api/1.10.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png diff --git a/legacyfabric-api/1.10.2/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.10.2/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b390f90ca --- /dev/null +++ b/legacyfabric-api/1.10.2/src/testmod/resources/fabric.mod.json @@ -0,0 +1,62 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacy-fabric-keybindings-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java similarity index 100% rename from legacy-fabric-keybindings-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java diff --git a/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java new file mode 100644 index 000000000..1566ba27b --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.PlayerEntityRenderer; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.entity.LivingEntity; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; + +public class ModelFeatureTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityClass, entityRenderer, registrationHelper) -> { + if (entityRenderer instanceof PlayerEntityRenderer) { + registrationHelper.register(new FeatureRenderer() { + private final BlockState state = Blocks.DIRT.getDefaultState(); + + @Override + public void render(LivingEntity entity, float handSwing, float handSwingAmount, float tickDelta, float age, float headYaw, float headPitch, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.enableTexture(); + GlStateManager.translate(0.0F, 1.0F, 0.0F); + GlStateManager.scale(2, 2, 2); + MinecraftClient.getInstance().getBlockRenderManager().renderBlockEntity(state, 9923917); + GlStateManager.disableTexture(); + GlStateManager.popMatrix(); + } + + @Override + public boolean combineTextures() { + return false; + } + }); + } + }); + } +} diff --git a/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java similarity index 100% rename from legacy-fabric-rendering-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java diff --git a/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacy-fabric-command-api-v2/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java similarity index 100% rename from legacy-fabric-command-api-v2/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java diff --git a/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..1f0c11714 --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void method_3279(MinecraftServer minecraftServer, CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } +} diff --git a/legacy-fabric-command-api-v2/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java similarity index 100% rename from legacy-fabric-command-api-v2/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java diff --git a/legacy-fabric-entity-events-v1/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java similarity index 100% rename from legacy-fabric-entity-events-v1/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java diff --git a/legacy-fabric-item-groups-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java similarity index 100% rename from legacy-fabric-item-groups-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java diff --git a/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java similarity index 61% rename from legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java index bf1b8088e..f40555b83 100644 --- a/legacy-fabric-lifecycle-events-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java +++ b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -17,8 +17,12 @@ package net.legacyfabric.fabric.test.lifecycle.client; +import net.minecraft.entity.EntityType; + import net.fabricmc.api.ClientModInitializer; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; @@ -34,5 +38,21 @@ public void onInitializeClient() { ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { LOGGER.info("Client stopping"); }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); } } diff --git a/legacy-fabric-networking-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java diff --git a/legacy-fabric-networking-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java diff --git a/legacy-fabric-registry-sync-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacy-fabric-resource-loader-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.11.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacy-fabric-rendering-api-v1/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json similarity index 100% rename from legacy-fabric-rendering-api-v1/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json rename to legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json diff --git a/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json new file mode 100644 index 000000000..54edb4eac --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "legacy-fabric-api:items/test_item" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.11.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.11.2/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.11.2/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b390f90ca --- /dev/null +++ b/legacyfabric-api/1.11.2/src/testmod/resources/fabric.mod.json @@ -0,0 +1,62 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacy-fabric-keybindings-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java similarity index 100% rename from legacy-fabric-keybindings-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java new file mode 100644 index 000000000..1566ba27b --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.PlayerEntityRenderer; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.entity.LivingEntity; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; + +public class ModelFeatureTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityClass, entityRenderer, registrationHelper) -> { + if (entityRenderer instanceof PlayerEntityRenderer) { + registrationHelper.register(new FeatureRenderer() { + private final BlockState state = Blocks.DIRT.getDefaultState(); + + @Override + public void render(LivingEntity entity, float handSwing, float handSwingAmount, float tickDelta, float age, float headYaw, float headPitch, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.enableTexture(); + GlStateManager.translate(0.0F, 1.0F, 0.0F); + GlStateManager.scale(2, 2, 2); + MinecraftClient.getInstance().getBlockRenderManager().renderBlockEntity(state, 9923917); + GlStateManager.disableTexture(); + GlStateManager.popMatrix(); + } + + @Override + public boolean combineTextures() { + return false; + } + }); + } + }); + } +} diff --git a/legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java similarity index 58% rename from legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java index bf1b8088e..45652ad3d 100644 --- a/legacy-fabric-lifecycle-events-v1/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -15,24 +15,29 @@ * limitations under the License. */ -package net.legacyfabric.fabric.test.lifecycle.client; +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; import net.fabricmc.api.ClientModInitializer; -import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; -public class ClientLifecycleEventsTest implements ClientModInitializer { - private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); @Override public void onInitializeClient() { - ClientLifecycleEvents.CLIENT_STARTED.register(client -> { - LOGGER.info("Client started"); + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); }); - ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { - LOGGER.info("Client stopping"); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); }); } } diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java new file mode 100644 index 000000000..435f23c03 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Objects; + +import net.minecraft.text.ClickEvent; +import net.minecraft.text.LiteralText; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandException; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandManager; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandResult; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.CommandContext; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.GenericArguments; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.spec.CommandSpec; +import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource; + +public class ModMetadataCommand { + public static void register(CommandManager manager) { + manager.register( + CommandSpec.builder() + .arguments(GenericArguments.mod(new LiteralText("modid"))) + .executor(ModMetadataCommand::execute) + .build(), + "modmetadata" + ); + } + + private static final boolean useStyle = !Objects.equals(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString(), "1.8"); + + private static CommandResult execute(PermissibleCommandSource source, CommandContext ctx) throws CommandException { + ModContainer container = ctx.getOne("modid").orElseThrow(() -> new CommandException(new LiteralText("mod not found"))); + LiteralText builder = new LiteralText(""); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + LiteralText issueText = new LiteralText(""); + issueText.append("Issues: "); + LiteralText issueUrl = new LiteralText(contact.get("issues").get()); + if (useStyle) issueUrl.setStyle(issueText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, issueUrl.computeValue()))); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + LiteralText sourcesText = new LiteralText(""); + sourcesText.append("Sources: "); + LiteralText sourcesUrl = new LiteralText(contact.get("sources").get()); + if (useStyle) sourcesUrl.setStyle(sourcesText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, sourcesUrl.computeValue()))); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + source.sendMessage(builder); + return CommandResult.success(); + } +} diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..1f0c11714 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void method_3279(MinecraftServer minecraftServer, CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } +} diff --git a/legacy-fabric-command-api-v2/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java similarity index 100% rename from legacy-fabric-command-api-v2/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java new file mode 100644 index 000000000..7f52d4ac5 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.entity; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityCombatEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class EntityEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "EntityEvents"); + + @Override + public void onInitialize() { + ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((entity, killedEntity) -> { + LOGGER.info("%s killed %s", EntityType.getEntityName(entity), EntityType.getEntityName(killedEntity)); + }); + ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> { + LOGGER.info("%s went from dim %s to dim %s", EntityType.getEntityName(newEntity), origin.dimension.getDimensionType().getName(), destination.dimension.getDimensionType().getName()); + }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { + LOGGER.info("Player went from dim %s to dim %s", origin.dimension.getDimensionType().getName(), destination.dimension.getDimensionType().getName()); + }); + ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, world, alive) -> { + LOGGER.info("Player %s respawned", newPlayer.getGameProfile().getName()); + }); + ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { + LOGGER.info("%s player data is being copied", newPlayer.getGameProfile().getName()); + }); + } +} diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..7c3d7afc0 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.item.group; + +import java.util.stream.StreamSupport; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.legacyfabric.fabric.api.util.Identifier; + +public class ItemGroupTest implements ModInitializer { + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) + .iconWithItemStack(() -> new ItemStack(Items.DIAMOND)) + .appendItems(stacks -> + StreamSupport.stream(Item.REGISTRY.spliterator(), false) + .map(ItemStack::new) + .forEach(stacks::add) + ).build(); + + private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) + .iconWithItemStack(() -> new ItemStack(Items.REDSTONE)) + .appendItems((stacks, itemGroup) -> { + for (Item item : Item.REGISTRY) { + if (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup) { + stacks.add(new ItemStack(item)); + } + } + }).build(); + + @Override + public void onInitialize() { } +} diff --git a/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java similarity index 61% rename from legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java index bf1b8088e..f40555b83 100644 --- a/legacy-fabric-lifecycle-events-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java +++ b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -17,8 +17,12 @@ package net.legacyfabric.fabric.test.lifecycle.client; +import net.minecraft.entity.EntityType; + import net.fabricmc.api.ClientModInitializer; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; @@ -34,5 +38,21 @@ public void onInitializeClient() { ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { LOGGER.info("Client stopping"); }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); } } diff --git a/legacy-fabric-networking-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java diff --git a/legacy-fabric-networking-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java similarity index 100% rename from legacy-fabric-networking-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java diff --git a/legacy-fabric-registry-sync-api-v1/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacy-fabric-resource-loader-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.12.2/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json new file mode 100644 index 000000000..54edb4eac --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "legacy-fabric-api:items/test_item" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.12.2/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.12.2/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.12.2/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b390f90ca --- /dev/null +++ b/legacyfabric-api/1.12.2/src/testmod/resources/fabric.mod.json @@ -0,0 +1,62 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacy-fabric-keybindings-api-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java similarity index 100% rename from legacy-fabric-keybindings-api-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java rename to legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java diff --git a/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java new file mode 100644 index 000000000..45652ad3d --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); + + @Override + public void onInitializeClient() { + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); + }); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); + }); + } +} diff --git a/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..6eb39bf34 --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import org.jetbrains.annotations.NotNull; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.Command; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void execute(CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } + + @Override + public int compareTo(@NotNull Object o) { + return super.compareTo((Command) o); + } +} diff --git a/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java new file mode 100644 index 000000000..096aaf861 --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.entity; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityCombatEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class EntityEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "EntityEvents"); + + @Override + public void onInitialize() { + ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((entity, killedEntity) -> { + LOGGER.info("%s killed %s", EntityType.getEntityName(entity), EntityType.getEntityName(killedEntity)); + }); + ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> { + LOGGER.info("%s went from dim %s to dim %s", EntityType.getEntityName(newEntity), origin.dimension.getName(), destination.dimension.getName()); + }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { + LOGGER.info("Player went from dim %s to dim %s", origin.dimension.getName(), destination.dimension.getName()); + }); + ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, world, alive) -> { + LOGGER.info("Player %s respawned", newPlayer.getUsername()); + }); + ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { + LOGGER.info("%s player data is being copied", newPlayer.getUsername()); + }); + } +} diff --git a/legacy-fabric-item-groups-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java similarity index 100% rename from legacy-fabric-item-groups-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java rename to legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java diff --git a/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java similarity index 61% rename from legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java rename to legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java index bf1b8088e..f40555b83 100644 --- a/legacy-fabric-lifecycle-events-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java +++ b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -17,8 +17,12 @@ package net.legacyfabric.fabric.test.lifecycle.client; +import net.minecraft.entity.EntityType; + import net.fabricmc.api.ClientModInitializer; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.legacyfabric.fabric.api.logger.v1.Logger; import net.legacyfabric.fabric.impl.logger.LoggerImpl; @@ -34,5 +38,21 @@ public void onInitializeClient() { ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { LOGGER.info("Client stopping"); }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); } } diff --git a/legacy-fabric-resource-loader-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.6.4/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.6.4/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..a51bb913b --- /dev/null +++ b/legacyfabric-api/1.6.4/src/testmod/resources/fabric.mod.json @@ -0,0 +1,57 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacy-fabric-resource-loader-v1/1.6.4/src/testmod/resources/pack.mcmeta b/legacyfabric-api/1.6.4/src/testmod/resources/pack.mcmeta similarity index 100% rename from legacy-fabric-resource-loader-v1/1.6.4/src/testmod/resources/pack.mcmeta rename to legacyfabric-api/1.6.4/src/testmod/resources/pack.mcmeta diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java new file mode 100644 index 000000000..e9882cf4e --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.keybinding; + +import org.lwjgl.input.Keyboard; + +import net.minecraft.client.option.KeyBinding; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; + +public class KeybindingTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey", Keyboard.KEY_F, "key.categories.lftesting")); + KeyBinding keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey2", Keyboard.KEY_G, "key.categories.lftesting")); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (keyBinding.wasPressed()) { + System.out.printf("The key %s was pressed%n", Keyboard.getKeyName(keyBinding.getCode())); + } + }); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java new file mode 100644 index 000000000..45652ad3d --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); + + @Override + public void onInitializeClient() { + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); + }); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); + }); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacy-fabric-command-api-v2/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java similarity index 100% rename from legacy-fabric-command-api-v2/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java rename to legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..6eb39bf34 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import org.jetbrains.annotations.NotNull; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.Command; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void execute(CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } + + @Override + public int compareTo(@NotNull Object o) { + return super.compareTo((Command) o); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java new file mode 100644 index 000000000..af1a6c161 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.command.v2.CommandRegistrar; + +public class SpongeCommandTest implements ModInitializer { + @Override + public void onInitialize() { + CommandRegistrar.EVENT.register((manager, dedicated) -> { + ModMetadataCommand.register(manager); + }); + } +} diff --git a/legacy-fabric-entity-events-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java similarity index 100% rename from legacy-fabric-entity-events-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java rename to legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..049a1a4c3 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.item.group; + +import java.util.stream.StreamSupport; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.legacyfabric.fabric.api.util.Identifier; + +public class ItemGroupTest implements ModInitializer { + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) + .iconWithItemStack(() -> new ItemStack(Items.DIAMOND)) + .appendItems(stacks -> + StreamSupport.stream(Item.REGISTRY.spliterator(), false) + .map(o -> new ItemStack((Item) o)) + .forEach(o -> stacks.add((ItemStack) o)) + ).build(); + + private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) + .iconWithItemStack(() -> new ItemStack(Items.REDSTONE)) + .appendItems((stacks, itemGroup) -> { + for (Object o : Item.REGISTRY) { + Item item = (Item) o; + + if (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup) { + stacks.add(new ItemStack(item)); + } + } + }).build(); + + @Override + public void onInitialize() { } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java new file mode 100644 index 000000000..f40555b83 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle.client; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientLifecycleEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); + + @Override + public void onInitializeClient() { + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + LOGGER.info("Client started"); + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + LOGGER.info("Client stopping"); + }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java new file mode 100644 index 000000000..b6df87b38 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network; + +import java.util.Arrays; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.networking.v1.S2CPlayChannelEvents; +import net.legacyfabric.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerNetworkingTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerNetworking"); + + @Override + public void onInitialize() { + S2CPlayChannelEvents.REGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Registered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + S2CPlayChannelEvents.UNREGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Unregistered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + ServerPlayConnectionEvents.INIT.register((handler, server) -> { + LOGGER.info("Connection initialized (S2C)"); + }); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + LOGGER.info("World joined (S2C)"); + }); + ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { + LOGGER.info("Connection disconnected (S2C)"); + }); + } +} diff --git a/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java new file mode 100644 index 000000000..2c76c14d3 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network.client; + +import java.util.Arrays; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.networking.v1.C2SPlayChannelEvents; +import net.legacyfabric.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientNetworkingTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientNetworking"); + + @Override + public void onInitializeClient() { + C2SPlayChannelEvents.REGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Registered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + C2SPlayChannelEvents.UNREGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Unregistered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + ClientPlayConnectionEvents.INIT.register((handler, client) -> { + LOGGER.info("Connection initialized (C2S)"); + }); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { + LOGGER.info("World joined (C2S)"); + }); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { + LOGGER.info("Connection disconnected (C2S)"); + }); + } +} diff --git a/legacy-fabric-registry-sync-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacy-fabric-resource-loader-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.7.10/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.7.10/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.7.10/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.7.10/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b745d372a --- /dev/null +++ b/legacyfabric-api/1.7.10/src/testmod/resources/fabric.mod.json @@ -0,0 +1,61 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java new file mode 100644 index 000000000..e9882cf4e --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.keybinding; + +import org.lwjgl.input.Keyboard; + +import net.minecraft.client.option.KeyBinding; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; + +public class KeybindingTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey", Keyboard.KEY_F, "key.categories.lftesting")); + KeyBinding keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey2", Keyboard.KEY_G, "key.categories.lftesting")); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (keyBinding.wasPressed()) { + System.out.printf("The key %s was pressed%n", Keyboard.getKeyName(keyBinding.getCode())); + } + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java new file mode 100644 index 000000000..1566ba27b --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.PlayerEntityRenderer; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.entity.LivingEntity; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; + +public class ModelFeatureTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityClass, entityRenderer, registrationHelper) -> { + if (entityRenderer instanceof PlayerEntityRenderer) { + registrationHelper.register(new FeatureRenderer() { + private final BlockState state = Blocks.DIRT.getDefaultState(); + + @Override + public void render(LivingEntity entity, float handSwing, float handSwingAmount, float tickDelta, float age, float headYaw, float headPitch, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.enableTexture(); + GlStateManager.translate(0.0F, 1.0F, 0.0F); + GlStateManager.scale(2, 2, 2); + MinecraftClient.getInstance().getBlockRenderManager().renderBlockEntity(state, 9923917); + GlStateManager.disableTexture(); + GlStateManager.popMatrix(); + } + + @Override + public boolean combineTextures() { + return false; + } + }); + } + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java new file mode 100644 index 000000000..45652ad3d --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); + + @Override + public void onInitializeClient() { + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); + }); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java new file mode 100644 index 000000000..435f23c03 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Objects; + +import net.minecraft.text.ClickEvent; +import net.minecraft.text.LiteralText; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandException; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandManager; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandResult; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.CommandContext; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.GenericArguments; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.spec.CommandSpec; +import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource; + +public class ModMetadataCommand { + public static void register(CommandManager manager) { + manager.register( + CommandSpec.builder() + .arguments(GenericArguments.mod(new LiteralText("modid"))) + .executor(ModMetadataCommand::execute) + .build(), + "modmetadata" + ); + } + + private static final boolean useStyle = !Objects.equals(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString(), "1.8"); + + private static CommandResult execute(PermissibleCommandSource source, CommandContext ctx) throws CommandException { + ModContainer container = ctx.getOne("modid").orElseThrow(() -> new CommandException(new LiteralText("mod not found"))); + LiteralText builder = new LiteralText(""); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + LiteralText issueText = new LiteralText(""); + issueText.append("Issues: "); + LiteralText issueUrl = new LiteralText(contact.get("issues").get()); + if (useStyle) issueUrl.setStyle(issueText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, issueUrl.computeValue()))); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + LiteralText sourcesText = new LiteralText(""); + sourcesText.append("Sources: "); + LiteralText sourcesUrl = new LiteralText(contact.get("sources").get()); + if (useStyle) sourcesUrl.setStyle(sourcesText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, sourcesUrl.computeValue()))); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + source.sendMessage(builder); + return CommandResult.success(); + } +} diff --git a/legacy-fabric-command-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java similarity index 96% rename from legacy-fabric-command-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java rename to legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java index d37c38c81..6dbd21ea6 100644 --- a/legacy-fabric-command-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -39,7 +39,7 @@ public String getUsageTranslationKey(CommandSource source) { } @Override - public void execute(CommandSource source, String[] args) throws CommandException { + public void execute(CommandSource commandSource, String[] args) throws CommandException { if (args.length > 0) { Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java new file mode 100644 index 000000000..af1a6c161 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.command.v2.CommandRegistrar; + +public class SpongeCommandTest implements ModInitializer { + @Override + public void onInitialize() { + CommandRegistrar.EVENT.register((manager, dedicated) -> { + ModMetadataCommand.register(manager); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java new file mode 100644 index 000000000..d45f09d4a --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.entity; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityCombatEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class EntityEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "EntityEvents"); + + @Override + public void onInitialize() { + ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((entity, killedEntity) -> { + LOGGER.info("%s killed %s", EntityType.getEntityName(entity), EntityType.getEntityName(killedEntity)); + }); + ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> { + LOGGER.info("%s went from dim %s to dim %s", EntityType.getEntityName(newEntity), origin.dimension.getName(), destination.dimension.getName()); + }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { + LOGGER.info("Player went from dim %s to dim %s", origin.dimension.getName(), destination.dimension.getName()); + }); + ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, world, alive) -> { + LOGGER.info("Player %s respawned", newPlayer.getGameProfile().getName()); + }); + ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { + LOGGER.info("%s player data is being copied", newPlayer.getGameProfile().getName()); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..7c3d7afc0 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.item.group; + +import java.util.stream.StreamSupport; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.legacyfabric.fabric.api.util.Identifier; + +public class ItemGroupTest implements ModInitializer { + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) + .iconWithItemStack(() -> new ItemStack(Items.DIAMOND)) + .appendItems(stacks -> + StreamSupport.stream(Item.REGISTRY.spliterator(), false) + .map(ItemStack::new) + .forEach(stacks::add) + ).build(); + + private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) + .iconWithItemStack(() -> new ItemStack(Items.REDSTONE)) + .appendItems((stacks, itemGroup) -> { + for (Item item : Item.REGISTRY) { + if (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup) { + stacks.add(new ItemStack(item)); + } + } + }).build(); + + @Override + public void onInitialize() { } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java new file mode 100644 index 000000000..f40555b83 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle.client; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientLifecycleEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); + + @Override + public void onInitializeClient() { + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + LOGGER.info("Client started"); + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + LOGGER.info("Client stopping"); + }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java new file mode 100644 index 000000000..b6df87b38 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network; + +import java.util.Arrays; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.networking.v1.S2CPlayChannelEvents; +import net.legacyfabric.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerNetworkingTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerNetworking"); + + @Override + public void onInitialize() { + S2CPlayChannelEvents.REGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Registered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + S2CPlayChannelEvents.UNREGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Unregistered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + ServerPlayConnectionEvents.INIT.register((handler, server) -> { + LOGGER.info("Connection initialized (S2C)"); + }); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + LOGGER.info("World joined (S2C)"); + }); + ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { + LOGGER.info("Connection disconnected (S2C)"); + }); + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java new file mode 100644 index 000000000..2c76c14d3 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network.client; + +import java.util.Arrays; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.networking.v1.C2SPlayChannelEvents; +import net.legacyfabric.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientNetworkingTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientNetworking"); + + @Override + public void onInitializeClient() { + C2SPlayChannelEvents.REGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Registered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + C2SPlayChannelEvents.UNREGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Unregistered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + ClientPlayConnectionEvents.INIT.register((handler, client) -> { + LOGGER.info("Connection initialized (C2S)"); + }); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { + LOGGER.info("World joined (C2S)"); + }); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { + LOGGER.info("Connection disconnected (C2S)"); + }); + } +} diff --git a/legacy-fabric-registry-sync-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacy-fabric-resource-loader-v1/1.8/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java similarity index 100% rename from legacy-fabric-resource-loader-v1/1.8/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java rename to legacyfabric-api/1.8.9/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java diff --git a/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json new file mode 100644 index 000000000..54edb4eac --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "legacy-fabric-api:items/test_item" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.8.9/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.8.9/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.8.9/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b390f90ca --- /dev/null +++ b/legacyfabric-api/1.8.9/src/testmod/resources/fabric.mod.json @@ -0,0 +1,62 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java new file mode 100644 index 000000000..e9882cf4e --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.keybinding; + +import org.lwjgl.input.Keyboard; + +import net.minecraft.client.option.KeyBinding; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; + +public class KeybindingTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey", Keyboard.KEY_F, "key.categories.lftesting")); + KeyBinding keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey2", Keyboard.KEY_G, "key.categories.lftesting")); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (keyBinding.wasPressed()) { + System.out.printf("The key %s was pressed%n", Keyboard.getKeyName(keyBinding.getCode())); + } + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java new file mode 100644 index 000000000..45652ad3d --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); + + @Override + public void onInitializeClient() { + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); + }); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java new file mode 100644 index 000000000..a8f4d1726 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Objects; + +import net.minecraft.text.ClickEvent; +import net.minecraft.text.ClickEventAction; +import net.minecraft.text.LiteralText; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandException; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandManager; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandResult; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.CommandContext; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.GenericArguments; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.spec.CommandSpec; +import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource; + +public class ModMetadataCommand { + public static void register(CommandManager manager) { + manager.register( + CommandSpec.builder() + .arguments(GenericArguments.mod(new LiteralText("modid"))) + .executor(ModMetadataCommand::execute) + .build(), + "modmetadata" + ); + } + + private static final boolean useStyle = !Objects.equals(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString(), "1.8"); + + private static CommandResult execute(PermissibleCommandSource source, CommandContext ctx) throws CommandException { + ModContainer container = ctx.getOne("modid").orElseThrow(() -> new CommandException(new LiteralText("mod not found"))); + LiteralText builder = new LiteralText(""); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + LiteralText issueText = new LiteralText(""); + issueText.append("Issues: "); + LiteralText issueUrl = new LiteralText(contact.get("issues").get()); + if (useStyle) issueUrl.setStyle(issueText.getStyle().setClickEvent(new ClickEvent(ClickEventAction.OPEN_URL, issueUrl.computeValue()))); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + LiteralText sourcesText = new LiteralText(""); + sourcesText.append("Sources: "); + LiteralText sourcesUrl = new LiteralText(contact.get("sources").get()); + if (useStyle) sourcesUrl.setStyle(sourcesText.getStyle().setClickEvent(new ClickEvent(ClickEventAction.OPEN_URL, sourcesUrl.computeValue()))); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + source.sendMessage(builder); + return CommandResult.success(); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..40a9ffad0 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import org.jetbrains.annotations.NotNull; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.Command; +import net.minecraft.command.CommandSource; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void execute(CommandSource commandSource, String[] args) { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } + + @Override + public int compareTo(@NotNull Object o) { + return super.compareTo((Command) o); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java new file mode 100644 index 000000000..af1a6c161 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.command.v2.CommandRegistrar; + +public class SpongeCommandTest implements ModInitializer { + @Override + public void onInitialize() { + CommandRegistrar.EVENT.register((manager, dedicated) -> { + ModMetadataCommand.register(manager); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java new file mode 100644 index 000000000..d45f09d4a --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.entity; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityCombatEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class EntityEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "EntityEvents"); + + @Override + public void onInitialize() { + ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((entity, killedEntity) -> { + LOGGER.info("%s killed %s", EntityType.getEntityName(entity), EntityType.getEntityName(killedEntity)); + }); + ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> { + LOGGER.info("%s went from dim %s to dim %s", EntityType.getEntityName(newEntity), origin.dimension.getName(), destination.dimension.getName()); + }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { + LOGGER.info("Player went from dim %s to dim %s", origin.dimension.getName(), destination.dimension.getName()); + }); + ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, world, alive) -> { + LOGGER.info("Player %s respawned", newPlayer.getGameProfile().getName()); + }); + ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { + LOGGER.info("%s player data is being copied", newPlayer.getGameProfile().getName()); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..049a1a4c3 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.item.group; + +import java.util.stream.StreamSupport; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.legacyfabric.fabric.api.util.Identifier; + +public class ItemGroupTest implements ModInitializer { + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) + .iconWithItemStack(() -> new ItemStack(Items.DIAMOND)) + .appendItems(stacks -> + StreamSupport.stream(Item.REGISTRY.spliterator(), false) + .map(o -> new ItemStack((Item) o)) + .forEach(o -> stacks.add((ItemStack) o)) + ).build(); + + private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) + .iconWithItemStack(() -> new ItemStack(Items.REDSTONE)) + .appendItems((stacks, itemGroup) -> { + for (Object o : Item.REGISTRY) { + Item item = (Item) o; + + if (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup) { + stacks.add(new ItemStack(item)); + } + } + }).build(); + + @Override + public void onInitialize() { } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java new file mode 100644 index 000000000..f40555b83 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle.client; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientLifecycleEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); + + @Override + public void onInitializeClient() { + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + LOGGER.info("Client started"); + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + LOGGER.info("Client stopping"); + }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java new file mode 100644 index 000000000..b6df87b38 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network; + +import java.util.Arrays; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.networking.v1.S2CPlayChannelEvents; +import net.legacyfabric.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerNetworkingTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerNetworking"); + + @Override + public void onInitialize() { + S2CPlayChannelEvents.REGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Registered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + S2CPlayChannelEvents.UNREGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Unregistered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + ServerPlayConnectionEvents.INIT.register((handler, server) -> { + LOGGER.info("Connection initialized (S2C)"); + }); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + LOGGER.info("World joined (S2C)"); + }); + ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { + LOGGER.info("Connection disconnected (S2C)"); + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java new file mode 100644 index 000000000..2c76c14d3 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network.client; + +import java.util.Arrays; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.networking.v1.C2SPlayChannelEvents; +import net.legacyfabric.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientNetworkingTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientNetworking"); + + @Override + public void onInitializeClient() { + C2SPlayChannelEvents.REGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Registered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + C2SPlayChannelEvents.UNREGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Unregistered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + ClientPlayConnectionEvents.INIT.register((handler, client) -> { + LOGGER.info("Connection initialized (C2S)"); + }); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { + LOGGER.info("World joined (C2S)"); + }); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { + LOGGER.info("Connection disconnected (C2S)"); + }); + } +} diff --git a/legacy-fabric-registry-sync-api-v1/1.8/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java similarity index 100% rename from legacy-fabric-registry-sync-api-v1/1.8/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java rename to legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java diff --git a/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java new file mode 100644 index 000000000..99ab573c7 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.resource.loader.client; + +import java.util.Arrays; + +import net.minecraft.resource.ResourceManager; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.resource.IdentifiableResourceReloadListener; +import net.legacyfabric.fabric.api.resource.ResourceManagerHelper; +import net.legacyfabric.fabric.api.util.Identifier; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ResourceReloadTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ResourceReload"); + + @Override + public void onInitializeClient() { + Identifier id = new Identifier("legacy-fabric-api", "test_reload"); + ResourceManagerHelper.getInstance().registerReloadListener(new IdentifiableResourceReloadListener() { + @Override + public Identifier getFabricId() { + return id; + } + + @Override + public void reload(ResourceManager resourceManager) { + LOGGER.info("Resources and reloading"); + LOGGER.info("Namespaces are %s", Arrays.toString(resourceManager.getAllNamespaces().toArray())); + } + }); + } +} diff --git a/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json new file mode 100644 index 000000000..54edb4eac --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "legacy-fabric-api:items/test_item" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.8/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.8/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.8/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b745d372a --- /dev/null +++ b/legacyfabric-api/1.8/src/testmod/resources/fabric.mod.json @@ -0,0 +1,61 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java new file mode 100644 index 000000000..e9882cf4e --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/keybinding/KeybindingTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.keybinding; + +import org.lwjgl.input.Keyboard; + +import net.minecraft.client.option.KeyBinding; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; + +public class KeybindingTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey", Keyboard.KEY_F, "key.categories.lftesting")); + KeyBinding keyBinding2 = KeyBindingHelper.registerKeyBinding(new KeyBinding("api.keybinding.testTranslationKey2", Keyboard.KEY_G, "key.categories.lftesting")); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (keyBinding.wasPressed()) { + System.out.printf("The key %s was pressed%n", Keyboard.getKeyName(keyBinding.getCode())); + } + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java new file mode 100644 index 000000000..1566ba27b --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/ModelFeatureTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.entity.PlayerEntityRenderer; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.entity.LivingEntity; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; + +public class ModelFeatureTest implements ClientModInitializer { + @Override + public void onInitializeClient() { + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityClass, entityRenderer, registrationHelper) -> { + if (entityRenderer instanceof PlayerEntityRenderer) { + registrationHelper.register(new FeatureRenderer() { + private final BlockState state = Blocks.DIRT.getDefaultState(); + + @Override + public void render(LivingEntity entity, float handSwing, float handSwingAmount, float tickDelta, float age, float headYaw, float headPitch, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.enableTexture(); + GlStateManager.translate(0.0F, 1.0F, 0.0F); + GlStateManager.scale(2, 2, 2); + MinecraftClient.getInstance().getBlockRenderManager().renderBlockEntity(state, 9923917); + GlStateManager.disableTexture(); + GlStateManager.popMatrix(); + } + + @Override + public boolean combineTextures() { + return false; + } + }); + } + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java new file mode 100644 index 000000000..45652ad3d --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/client/rendering/RenderingEventsTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.client.rendering; + +import java.awt.Color; + +import net.minecraft.client.resource.language.I18n; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.rendering.v1.HudRenderCallback; +import net.legacyfabric.fabric.api.client.rendering.v1.InvalidateRenderStateCallback; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class RenderingEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "RenderingEvents"); + + @Override + public void onInitializeClient() { + HudRenderCallback.EVENT.register((client, tickDelta) -> { + client.textRenderer.draw(I18n.translate("legacyfabric.api.youreTesting"), 10, 10, Color.RED.getRGB()); + }); + InvalidateRenderStateCallback.EVENT.register(() -> { + LOGGER.info("Render state invalidated"); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java new file mode 100644 index 000000000..390a8a7ab --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.registry.CommandRegistry; + +public class CommandV1Test implements ModInitializer { + public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); + + @Override + public void onInitialize() { + CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java new file mode 100644 index 000000000..435f23c03 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommand.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Objects; + +import net.minecraft.text.ClickEvent; +import net.minecraft.text.LiteralText; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandException; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandManager; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.CommandResult; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.CommandContext; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.args.GenericArguments; +import net.legacyfabric.fabric.api.command.v2.lib.sponge.spec.CommandSpec; +import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource; + +public class ModMetadataCommand { + public static void register(CommandManager manager) { + manager.register( + CommandSpec.builder() + .arguments(GenericArguments.mod(new LiteralText("modid"))) + .executor(ModMetadataCommand::execute) + .build(), + "modmetadata" + ); + } + + private static final boolean useStyle = !Objects.equals(FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion().getFriendlyString(), "1.8"); + + private static CommandResult execute(PermissibleCommandSource source, CommandContext ctx) throws CommandException { + ModContainer container = ctx.getOne("modid").orElseThrow(() -> new CommandException(new LiteralText("mod not found"))); + LiteralText builder = new LiteralText(""); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + LiteralText issueText = new LiteralText(""); + issueText.append("Issues: "); + LiteralText issueUrl = new LiteralText(contact.get("issues").get()); + if (useStyle) issueUrl.setStyle(issueText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, issueUrl.computeValue()))); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + LiteralText sourcesText = new LiteralText(""); + sourcesText.append("Sources: "); + LiteralText sourcesUrl = new LiteralText(contact.get("sources").get()); + if (useStyle) sourcesUrl.setStyle(sourcesText.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, sourcesUrl.computeValue()))); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + source.sendMessage(builder); + return CommandResult.success(); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java new file mode 100644 index 000000000..1f0c11714 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import java.util.Optional; + +import net.minecraft.command.AbstractCommand; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandSource; +import net.minecraft.server.MinecraftServer; + +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ContactInformation; + +public class ModMetadataCommandV1 extends AbstractCommand { + @Override + public String getCommandName() { + return "modmetadatav1"; + } + + @Override + public String getUsageTranslationKey(CommandSource source) { + return "modmetadatav1"; + } + + @Override + public void method_3279(MinecraftServer minecraftServer, CommandSource commandSource, String[] args) throws CommandException { + if (args.length > 0) { + Optional optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); + + if (optionalModContainer.isPresent()) { + ModContainer container = optionalModContainer.get(); + + StringBuilder builder = new StringBuilder(); + builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); + builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); + ContactInformation contact = container.getMetadata().getContact(); + + if (contact.get("issues").isPresent()) { + StringBuilder issueText = new StringBuilder(""); + issueText.append("Issues: "); + StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); + issueText.append(issueUrl); + issueText.append("\n"); + builder.append(issueText); + } + + if (contact.get("sources").isPresent()) { + StringBuilder sourcesText = new StringBuilder(""); + sourcesText.append("Sources: "); + StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); + sourcesText.append(sourcesUrl); + sourcesText.append("\n"); + builder.append(sourcesText); + } + + builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); + CommandV1Test.LOGGER.info(builder.toString()); + } else { + CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); + } + } + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java new file mode 100644 index 000000000..af1a6c161 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/command/SpongeCommandTest.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.command; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.command.v2.CommandRegistrar; + +public class SpongeCommandTest implements ModInitializer { + @Override + public void onInitialize() { + CommandRegistrar.EVENT.register((manager, dedicated) -> { + ModMetadataCommand.register(manager); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java new file mode 100644 index 000000000..7f52d4ac5 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/entity/EntityEventsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.entity; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityCombatEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; +import net.legacyfabric.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class EntityEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "EntityEvents"); + + @Override + public void onInitialize() { + ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((entity, killedEntity) -> { + LOGGER.info("%s killed %s", EntityType.getEntityName(entity), EntityType.getEntityName(killedEntity)); + }); + ServerEntityWorldChangeEvents.AFTER_ENTITY_CHANGE_WORLD.register((originalEntity, newEntity, origin, destination) -> { + LOGGER.info("%s went from dim %s to dim %s", EntityType.getEntityName(newEntity), origin.dimension.getDimensionType().getName(), destination.dimension.getDimensionType().getName()); + }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> { + LOGGER.info("Player went from dim %s to dim %s", origin.dimension.getDimensionType().getName(), destination.dimension.getDimensionType().getName()); + }); + ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, world, alive) -> { + LOGGER.info("Player %s respawned", newPlayer.getGameProfile().getName()); + }); + ServerPlayerEvents.COPY_FROM.register((oldPlayer, newPlayer, alive) -> { + LOGGER.info("%s player data is being copied", newPlayer.getGameProfile().getName()); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java new file mode 100644 index 000000000..7c3d7afc0 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.item.group; + +import java.util.stream.StreamSupport; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.legacyfabric.fabric.api.util.Identifier; + +public class ItemGroupTest implements ModInitializer { + //Adds an item group with all items in it + private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) + .iconWithItemStack(() -> new ItemStack(Items.DIAMOND)) + .appendItems(stacks -> + StreamSupport.stream(Item.REGISTRY.spliterator(), false) + .map(ItemStack::new) + .forEach(stacks::add) + ).build(); + + private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) + .iconWithItemStack(() -> new ItemStack(Items.REDSTONE)) + .appendItems((stacks, itemGroup) -> { + for (Item item : Item.REGISTRY) { + if (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup) { + stacks.add(new ItemStack(item)); + } + } + }).build(); + + @Override + public void onInitialize() { } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java new file mode 100644 index 000000000..6ebc689ee --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/ServerLifecycleEventsTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerChunkEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerEntityEvents; +import net.legacyfabric.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerLifecycleEventsTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerLifecycleEvents"); + + @Override + public void onInitialize() { + ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Server chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s loaded", EntityType.getEntityName(entity)); + }); + ServerEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Server Entity %s unloaded", EntityType.getEntityName(entity)); + }); + ServerLifecycleEvents.SERVER_STARTING.register(server -> { + LOGGER.info("Server starting"); + }); + ServerLifecycleEvents.SERVER_STARTED.register(server -> { + LOGGER.info("Server started"); + }); + ServerLifecycleEvents.SERVER_STOPPING.register(server -> { + LOGGER.info("Server stopping"); + }); + ServerLifecycleEvents.SERVER_STOPPED.register(server -> { + LOGGER.info("Server stopped"); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java new file mode 100644 index 000000000..f40555b83 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/lifecycle/client/ClientLifecycleEventsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.lifecycle.client; + +import net.minecraft.entity.EntityType; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; +import net.legacyfabric.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientLifecycleEventsTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientLifecycleEvents"); + + @Override + public void onInitializeClient() { + ClientLifecycleEvents.CLIENT_STARTED.register(client -> { + LOGGER.info("Client started"); + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + LOGGER.info("Client stopping"); + }); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk loaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> { + if (chunk != null) { + LOGGER.trace("Client chunk unloaded at %s %s", chunk.chunkX, chunk.chunkZ); + } + }); + ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s loaded", EntityType.getEntityName(entity)); + }); + ClientEntityEvents.ENTITY_UNLOAD.register((entity, world) -> { + LOGGER.trace("Client Entity %s unloaded", EntityType.getEntityName(entity)); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java new file mode 100644 index 000000000..b6df87b38 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/ServerNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network; + +import java.util.Arrays; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.networking.v1.S2CPlayChannelEvents; +import net.legacyfabric.fabric.api.networking.v1.ServerPlayConnectionEvents; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ServerNetworkingTest implements ModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ServerNetworking"); + + @Override + public void onInitialize() { + S2CPlayChannelEvents.REGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Registered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + S2CPlayChannelEvents.UNREGISTER.register((handler, sender, server, channels) -> { + LOGGER.info("Unregistered channels (S2C callback) - " + Arrays.toString(channels.toArray())); + }); + ServerPlayConnectionEvents.INIT.register((handler, server) -> { + LOGGER.info("Connection initialized (S2C)"); + }); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + LOGGER.info("World joined (S2C)"); + }); + ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { + LOGGER.info("Connection disconnected (S2C)"); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java new file mode 100644 index 000000000..2c76c14d3 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/network/client/ClientNetworkingTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.network.client; + +import java.util.Arrays; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.client.networking.v1.C2SPlayChannelEvents; +import net.legacyfabric.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ClientNetworkingTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ClientNetworking"); + + @Override + public void onInitializeClient() { + C2SPlayChannelEvents.REGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Registered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + C2SPlayChannelEvents.UNREGISTER.register((handler, sender, client, channels) -> { + LOGGER.info("Unregistered channels (C2S callback) - " + Arrays.toString(channels.toArray())); + }); + ClientPlayConnectionEvents.INIT.register((handler, client) -> { + LOGGER.info("Connection initialized (C2S)"); + }); + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { + LOGGER.info("World joined (C2S)"); + }); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { + LOGGER.info("Connection disconnected (C2S)"); + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java new file mode 100644 index 000000000..3d72858aa --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/registry/RegistryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.registry; + +import java.util.concurrent.ThreadLocalRandom; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialColor; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.item.itemgroup.ItemGroup; + +import net.fabricmc.api.ModInitializer; + +import net.legacyfabric.fabric.api.registry.v1.RegistryHelper; +import net.legacyfabric.fabric.api.resource.ItemModelRegistry; +import net.legacyfabric.fabric.api.util.Identifier; + +public class RegistryTest implements ModInitializer { + @Override + public void onInitialize() { + Block concBlock = new Block(Material.STONE, MaterialColor.BLACK).setItemGroup(ItemGroup.FOOD); + Block concBlock2 = new Block(Material.STONE, MaterialColor.BLUE).setItemGroup(ItemGroup.FOOD); + Block[] blocks = ThreadLocalRandom.current().nextBoolean() ? new Block[] {concBlock, concBlock2} : new Block[] {concBlock2, concBlock}; + + for (Block block : blocks) { + int color = 1644825; + + if (block == concBlock2) { + color = 3361970; + } + + Identifier identifier = new Identifier("legacy-fabric-api", "conc_block_" + color); + + RegistryHelper.registerBlock(block, identifier); + RegistryHelper.registerItem(new BlockItem(block), identifier); + } + + Item testItem = new Item().setItemGroup(ItemGroup.FOOD); + RegistryHelper.registerItem(testItem, new Identifier("legacy-fabric-api", "test_item")); + ItemModelRegistry.registerItemModel(testItem, new Identifier("legacy-fabric-api:test_item")); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java new file mode 100644 index 000000000..99ab573c7 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/java/net/legacyfabric/fabric/test/resource/loader/client/ResourceReloadTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 - 2024 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.test.resource.loader.client; + +import java.util.Arrays; + +import net.minecraft.resource.ResourceManager; + +import net.fabricmc.api.ClientModInitializer; + +import net.legacyfabric.fabric.api.logger.v1.Logger; +import net.legacyfabric.fabric.api.resource.IdentifiableResourceReloadListener; +import net.legacyfabric.fabric.api.resource.ResourceManagerHelper; +import net.legacyfabric.fabric.api.util.Identifier; +import net.legacyfabric.fabric.impl.logger.LoggerImpl; + +public class ResourceReloadTest implements ClientModInitializer { + private static final Logger LOGGER = Logger.get(LoggerImpl.API, "Test", "ResourceReload"); + + @Override + public void onInitializeClient() { + Identifier id = new Identifier("legacy-fabric-api", "test_reload"); + ResourceManagerHelper.getInstance().registerReloadListener(new IdentifiableResourceReloadListener() { + @Override + public Identifier getFabricId() { + return id; + } + + @Override + public void reload(ResourceManager resourceManager) { + LOGGER.info("Resources and reloading"); + LOGGER.info("Namespaces are %s", Arrays.toString(resourceManager.getAllNamespaces().toArray())); + } + }); + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang new file mode 100644 index 000000000..5b2a9c0e6 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang @@ -0,0 +1,2 @@ +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group=All Items +itemGroup.legacy-fabric-item-groups-v1-testmod.test_group_two=Food Clone diff --git a/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json new file mode 100644 index 000000000..676b62a43 --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "api.keybinding.testTranslationKey": "Test Keybinding", + "legacyfabric.api.youreTesting": "You're Testing Fabric API!" +} diff --git a/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json new file mode 100644 index 000000000..54edb4eac --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/models/item/test_item.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "legacy-fabric-api:items/test_item" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png new file mode 100644 index 000000000..2931efbf6 Binary files /dev/null and b/legacyfabric-api/1.9.4/src/testmod/resources/assets/legacy-fabric-api/textures/items/test_item.png differ diff --git a/legacyfabric-api/1.9.4/src/testmod/resources/fabric.mod.json b/legacyfabric-api/1.9.4/src/testmod/resources/fabric.mod.json new file mode 100644 index 000000000..b390f90ca --- /dev/null +++ b/legacyfabric-api/1.9.4/src/testmod/resources/fabric.mod.json @@ -0,0 +1,62 @@ +{ + "schemaVersion": 1, + "id": "legacy-fabric-api-testmod-impl", + "name": "Legacy Fabric API Testmod", + "version": "${version}", + "environment": "*", + "license": "Apache-2.0", + "icon": "assets/legacy-fabric-api/icon.png", + "contact": { + "homepage": "https://legacyfabric.net/", + "issues": "https://github.com/Legacy-Fabric/fabric/issues", + "sources": "https://github.com/Legacy-Fabric/fabric" + }, + "entrypoints": { + "client": [ + "net.legacyfabric.fabric.test.resource.loader.client.ResourceReloadTest", + "net.legacyfabric.fabric.test.client.rendering.ModelFeatureTest", + "net.legacyfabric.fabric.test.client.rendering.RenderingEventsTest", + "net.legacyfabric.fabric.test.network.client.ClientNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.client.ClientLifecycleEventsTest", + "net.legacyfabric.fabric.test.client.keybinding.KeybindingTest" + ], + "main": [ + "net.legacyfabric.fabric.test.registry.RegistryTest", + "net.legacyfabric.fabric.test.network.ServerNetworkingTest", + "net.legacyfabric.fabric.test.lifecycle.ServerLifecycleEventsTest", + "net.legacyfabric.fabric.test.item.group.ItemGroupTest", + "net.legacyfabric.fabric.test.entity.EntityEventsTest", + "net.legacyfabric.fabric.test.command.SpongeCommandTest", + "net.legacyfabric.fabric.test.command.CommandV1Test" + ] + }, + "authors": [ + { + "name": "Legacy Fabric", + "contact": { + "homepage": "https://legacyfabric.net/", + "discord": "https://legacyfabric.net/discord", + "sources": "https://github.com/Legacy-Fabric/fabric", + "issues": "https://github.com/Legacy-Fabric/fabric/issues" + } + }, + { + "name": "FabricMC", + "contact": { + "homepage": "https://fabricmc.net", + "discord": "https://discord.gg/v6v4pMv", + "sources": "https://github.com/FabricMC/fabric", + "issues": "https://github.com/FabricMC/fabric/issues" + } + } + ], + "description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", + "depends": { + "minecraft": "${minecraft_version}" + }, + "custom": { + "modmenu": { + "badges": [ "library" ] + } + } +}