Skip to content

Commit 85b07a0

Browse files
authored
Merge pull request #474 from OKTW-Network/migrate-mapping
Migrate to Mojang mapping
2 parents 397a7ba + 5b37c04 commit 85b07a0

File tree

149 files changed

+2196
-2223
lines changed

Some content is hidden

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

149 files changed

+2196
-2223
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build:
88
docker:
99
# specify the version you desire here
10-
- image: openjdk:21-jdk-slim
10+
- image: eclipse-temurin:21-jdk-noble
1111
resource_class: large
1212

1313
working_directory: ~/repo

build.gradle.kts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
55
plugins {
66
// "maven-publish"
77
kotlin("jvm") version "2.2.20"
8-
id("fabric-loom") version "1.11-SNAPSHOT"
8+
id("fabric-loom") version "1.13-SNAPSHOT"
99
}
1010

1111
val version = "0.0.1"
1212
val group = "one.oktw"
1313

1414
val minecraftVersion = "1.21.10"
15-
val mappingVersion = "1.21.10+build.1"
16-
val fabricLoaderVersion = "0.17.2"
17-
val fabricAPIVersion = "0.134.1+1.21.10"
15+
val fabricLoaderVersion = "0.17.3"
16+
val fabricAPIVersion = "0.138.3+1.21.10"
1817
val galaxyLibVersion = "f4e1b25"
1918

2019
repositories {
@@ -53,7 +52,7 @@ fabricApi {
5352
dependencies {
5453
// Core
5554
minecraft("com.mojang:minecraft:${minecraftVersion}")
56-
mappings("net.fabricmc:yarn:${mappingVersion}:v2")
55+
mappings(loom.officialMojangMappings())
5756
modImplementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}")
5857

5958
// fabric api

src/datagen/kotlin/one/oktw/galaxy/datagen/GalaxyRecipeProvider.kt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@ package one.oktw.galaxy.datagen
2020

2121
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput
2222
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider
23-
import net.minecraft.data.recipe.RecipeExporter
24-
import net.minecraft.data.recipe.RecipeGenerator
25-
import net.minecraft.item.Items
26-
import net.minecraft.recipe.book.RecipeCategory
27-
import net.minecraft.registry.RegistryKeys
28-
import net.minecraft.registry.RegistryWrapper
29-
import net.minecraft.registry.tag.ItemTags
23+
import net.minecraft.core.HolderLookup
24+
import net.minecraft.core.registries.Registries
25+
import net.minecraft.data.recipes.RecipeCategory
26+
import net.minecraft.data.recipes.RecipeOutput
27+
import net.minecraft.data.recipes.RecipeProvider
28+
import net.minecraft.tags.ItemTags
29+
import net.minecraft.world.item.Items
3030
import one.oktw.galaxy.datagen.util.ShapedRecipeJsonBuilder
3131
import one.oktw.galaxy.item.CustomBlockItem
3232
import one.oktw.galaxy.item.Tool
3333
import java.util.concurrent.CompletableFuture
3434

35-
class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup>) :
35+
class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: CompletableFuture<HolderLookup.Provider>) :
3636
FabricRecipeProvider(output, registriesFuture) {
37-
override fun getRecipeGenerator(registries: RegistryWrapper.WrapperLookup, exporter: RecipeExporter) = object : RecipeGenerator(registries, exporter) {
38-
override fun generate() {
39-
val itemLookup = registries.getOrThrow(RegistryKeys.ITEM)
37+
override fun createRecipeProvider(registries: HolderLookup.Provider, exporter: RecipeOutput) = object : RecipeProvider(registries, exporter) {
38+
override fun buildRecipes() {
39+
val itemLookup = registries.lookupOrThrow(Registries.ITEM)
4040

4141
// Block
42-
createShapeless(RecipeCategory.BUILDING_BLOCKS, CustomBlockItem.ELEVATOR.createItemStack())
43-
.input(Items.ENDER_PEARL)
44-
.input(Items.IRON_BLOCK)
45-
.criterion(hasItem(Items.ENDER_PEARL), conditionsFromItem(Items.ENDER_PEARL))
46-
.criterion(hasItem(Items.IRON_BLOCK), conditionsFromItem(Items.IRON_BLOCK))
47-
.offerTo(exporter, "block/elevator")
42+
shapeless(RecipeCategory.BUILDING_BLOCKS, CustomBlockItem.ELEVATOR.createItemStack())
43+
.requires(Items.ENDER_PEARL)
44+
.requires(Items.IRON_BLOCK)
45+
.unlockedBy(getHasName(Items.ENDER_PEARL), has(Items.ENDER_PEARL))
46+
.unlockedBy(getHasName(Items.IRON_BLOCK), has(Items.IRON_BLOCK))
47+
.save(exporter, "block/elevator")
4848
ShapedRecipeJsonBuilder(itemLookup, RecipeCategory.BUILDING_BLOCKS, CustomBlockItem.HARVEST.createItemStack())
4949
.addInput('C', Items.COPPER_INGOT)
5050
.addInput('D', Items.DISPENSER)
@@ -56,10 +56,10 @@ class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: Completab
5656
"CCC"
5757
)
5858
)
59-
.criterion(hasItem(Items.COPPER_INGOT), conditionsFromItem(Items.COPPER_INGOT))
60-
.criterion(hasItem(Items.DISPENSER), conditionsFromItem(Items.DISPENSER))
61-
.criterion(hasItem(Items.OBSERVER), conditionsFromItem(Items.OBSERVER))
62-
.offerTo(exporter, "block/harvest")
59+
.unlockedBy(getHasName(Items.COPPER_INGOT), has(Items.COPPER_INGOT))
60+
.unlockedBy(getHasName(Items.DISPENSER), has(Items.DISPENSER))
61+
.unlockedBy(getHasName(Items.OBSERVER), has(Items.OBSERVER))
62+
.save(exporter, "block/harvest")
6363
ShapedRecipeJsonBuilder(itemLookup, RecipeCategory.BUILDING_BLOCKS, CustomBlockItem.HT_CRAFTING_TABLE.createItemStack())
6464
.addInput('R', Items.REDSTONE)
6565
.addInput('D', Items.DIAMOND)
@@ -74,13 +74,13 @@ class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: Completab
7474
"LOR"
7575
)
7676
)
77-
.criterion(hasItem(Items.REDSTONE), conditionsFromItem(Items.REDSTONE))
78-
.criterion(hasItem(Items.DIAMOND), conditionsFromItem(Items.DIAMOND))
79-
.criterion(hasItem(Items.LAPIS_LAZULI), conditionsFromItem(Items.LAPIS_LAZULI))
80-
.criterion(hasItem(Items.IRON_INGOT), conditionsFromItem(Items.IRON_INGOT))
81-
.criterion(hasItem(Items.CRAFTING_TABLE), conditionsFromItem(Items.CRAFTING_TABLE))
82-
.criterion(hasItem(Items.OBSIDIAN), conditionsFromItem(Items.OBSIDIAN))
83-
.offerTo(exporter, "block/ht_crafting_table")
77+
.unlockedBy(getHasName(Items.REDSTONE), has(Items.REDSTONE))
78+
.unlockedBy(getHasName(Items.DIAMOND), has(Items.DIAMOND))
79+
.unlockedBy(getHasName(Items.LAPIS_LAZULI), has(Items.LAPIS_LAZULI))
80+
.unlockedBy(getHasName(Items.IRON_INGOT), has(Items.IRON_INGOT))
81+
.unlockedBy(getHasName(Items.CRAFTING_TABLE), has(Items.CRAFTING_TABLE))
82+
.unlockedBy(getHasName(Items.OBSIDIAN), has(Items.OBSIDIAN))
83+
.save(exporter, "block/ht_crafting_table")
8484
ShapedRecipeJsonBuilder(itemLookup, RecipeCategory.BUILDING_BLOCKS, CustomBlockItem.TRASHCAN.createItemStack())
8585
.addInput('G', Items.GLASS)
8686
.addInput('C', Items.CACTUS)
@@ -93,11 +93,11 @@ class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: Completab
9393
"TST"
9494
)
9595
)
96-
.criterion(hasItem(Items.GLASS), conditionsFromItem(Items.GLASS))
97-
.criterion(hasItem(Items.CACTUS), conditionsFromItem(Items.CACTUS))
98-
.criterion(hasItem(Items.TERRACOTTA), conditionsFromItem(Items.TERRACOTTA))
99-
.criterion(hasItem(Items.SAND), conditionsFromTag(ItemTags.SAND))
100-
.offerTo(exporter, "block/trashcan")
96+
.unlockedBy(getHasName(Items.GLASS), has(Items.GLASS))
97+
.unlockedBy(getHasName(Items.CACTUS), has(Items.CACTUS))
98+
.unlockedBy(getHasName(Items.TERRACOTTA), has(Items.TERRACOTTA))
99+
.unlockedBy(getHasName(Items.SAND), has(ItemTags.SAND))
100+
.save(exporter, "block/trashcan")
101101

102102
// Tool
103103
ShapedRecipeJsonBuilder(itemLookup, RecipeCategory.TOOLS, Tool.CROWBAR.createItemStack())
@@ -109,8 +109,8 @@ class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: Completab
109109
" I"
110110
)
111111
)
112-
.criterion(hasItem(Items.IRON_INGOT), conditionsFromItem(Items.IRON_INGOT))
113-
.offerTo(exporter, "tool/crowbar")
112+
.unlockedBy(getHasName(Items.IRON_INGOT), has(Items.IRON_INGOT))
113+
.save(exporter, "tool/crowbar")
114114
ShapedRecipeJsonBuilder(itemLookup, RecipeCategory.TOOLS, Tool.WRENCH.createItemStack())
115115
.addInput('I', Items.IRON_INGOT)
116116
.addInput('S', Items.STICK)
@@ -121,9 +121,9 @@ class GalaxyRecipeProvider(output: FabricDataOutput, registriesFuture: Completab
121121
" I "
122122
)
123123
)
124-
.criterion(hasItem(Items.IRON_INGOT), conditionsFromItem(Items.IRON_INGOT))
125-
.criterion(hasItem(Items.STICK), conditionsFromItem(Items.STICK))
126-
.offerTo(exporter, "tool/wrench")
124+
.unlockedBy(getHasName(Items.IRON_INGOT), has(Items.IRON_INGOT))
125+
.unlockedBy(getHasName(Items.STICK), has(Items.STICK))
126+
.save(exporter, "tool/wrench")
127127
}
128128
}
129129

src/datagen/kotlin/one/oktw/galaxy/datagen/util/ShapedRecipeJsonBuilder.kt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@
1818

1919
package one.oktw.galaxy.datagen.util
2020

21-
import net.minecraft.advancement.AdvancementCriterion
22-
import net.minecraft.advancement.AdvancementRequirements
23-
import net.minecraft.advancement.AdvancementRewards
24-
import net.minecraft.advancement.criterion.RecipeUnlockedCriterion
25-
import net.minecraft.data.recipe.CraftingRecipeJsonBuilder
26-
import net.minecraft.data.recipe.RecipeExporter
27-
import net.minecraft.item.Item
28-
import net.minecraft.item.ItemConvertible
29-
import net.minecraft.item.ItemStack
30-
import net.minecraft.recipe.Ingredient
31-
import net.minecraft.recipe.RawShapedRecipe
32-
import net.minecraft.recipe.Recipe
33-
import net.minecraft.recipe.ShapedRecipe
34-
import net.minecraft.recipe.book.RecipeCategory
35-
import net.minecraft.registry.RegistryEntryLookup
36-
import net.minecraft.registry.RegistryKey
37-
import net.minecraft.registry.tag.TagKey
21+
import net.minecraft.advancements.AdvancementRequirements
22+
import net.minecraft.advancements.AdvancementRewards
23+
import net.minecraft.advancements.Criterion
24+
import net.minecraft.advancements.critereon.RecipeUnlockedTrigger
25+
import net.minecraft.core.HolderGetter
26+
import net.minecraft.data.recipes.RecipeBuilder
27+
import net.minecraft.data.recipes.RecipeCategory
28+
import net.minecraft.data.recipes.RecipeOutput
29+
import net.minecraft.resources.ResourceKey
30+
import net.minecraft.tags.TagKey
31+
import net.minecraft.world.item.Item
32+
import net.minecraft.world.item.ItemStack
33+
import net.minecraft.world.item.crafting.Ingredient
34+
import net.minecraft.world.item.crafting.Recipe
35+
import net.minecraft.world.item.crafting.ShapedRecipe
36+
import net.minecraft.world.item.crafting.ShapedRecipePattern
37+
import net.minecraft.world.level.ItemLike
3838
import java.util.*
3939

40-
class ShapedRecipeJsonBuilder(private val registry: RegistryEntryLookup<Item>, private val category: RecipeCategory, private val output: ItemStack) :
41-
CraftingRecipeJsonBuilder {
42-
private val criteria: MutableMap<String, AdvancementCriterion<*>> = LinkedHashMap()
40+
class ShapedRecipeJsonBuilder(private val registry: HolderGetter<Item>, private val category: RecipeCategory, private val output: ItemStack) :
41+
RecipeBuilder {
42+
private val criteria: MutableMap<String, Criterion<*>> = LinkedHashMap()
4343
private var group: String? = null
4444
private val inputs: MutableMap<Char, Ingredient> = LinkedHashMap()
4545
private val pattern: MutableList<String> = ArrayList()
@@ -53,9 +53,9 @@ class ShapedRecipeJsonBuilder(private val registry: RegistryEntryLookup<Item>, p
5353
return this
5454
}
5555

56-
fun addInput(char: Char, tag: TagKey<Item>) = addInput(char, Ingredient.ofTag(registry.getOrThrow(tag)))
56+
fun addInput(char: Char, tag: TagKey<Item>) = addInput(char, Ingredient.of(registry.getOrThrow(tag)))
5757

58-
fun addInput(char: Char, item: ItemConvertible) = addInput(char, Ingredient.ofItem(item))
58+
fun addInput(char: Char, item: ItemLike) = addInput(char, Ingredient.of(item))
5959

6060
fun setPattern(pattern: List<String>): ShapedRecipeJsonBuilder {
6161
this.pattern.clear()
@@ -68,7 +68,7 @@ class ShapedRecipeJsonBuilder(private val registry: RegistryEntryLookup<Item>, p
6868
return this
6969
}
7070

71-
override fun criterion(name: String, criterion: AdvancementCriterion<*>): ShapedRecipeJsonBuilder {
71+
override fun unlockedBy(name: String, criterion: Criterion<*>): ShapedRecipeJsonBuilder {
7272
this.criteria[name] = criterion
7373
return this
7474
}
@@ -78,24 +78,24 @@ class ShapedRecipeJsonBuilder(private val registry: RegistryEntryLookup<Item>, p
7878
return this
7979
}
8080

81-
override fun getOutputItem(): Item = output.item
81+
override fun getResult(): Item = output.item
8282

83-
override fun offerTo(exporter: RecipeExporter, recipeKey: RegistryKey<Recipe<*>>) {
84-
val recipeKey = RegistryKey.of(recipeKey.getRegistryRef(), exporter.getRecipeIdentifier(recipeKey.value))
85-
val rawRecipe = RawShapedRecipe.create(this.inputs, this.pattern)
86-
val builder = exporter.advancementBuilder
87-
.criterion("has_the_recipe", RecipeUnlockedCriterion.create(recipeKey))
83+
override fun save(exporter: RecipeOutput, recipeKey: ResourceKey<Recipe<*>>) {
84+
val recipeKey = ResourceKey.create(recipeKey.registryKey(), exporter.getRecipeIdentifier(recipeKey.location()))
85+
val rawRecipe = ShapedRecipePattern.of(this.inputs, this.pattern)
86+
val builder = exporter.advancement()
87+
.addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(recipeKey))
8888
.rewards(AdvancementRewards.Builder.recipe(recipeKey))
89-
.criteriaMerger(AdvancementRequirements.CriterionMerger.OR)
90-
this.criteria.forEach(builder::criterion)
89+
.requirements(AdvancementRequirements.Strategy.OR)
90+
this.criteria.forEach(builder::addCriterion)
9191
val recipe = ShapedRecipe(
9292
Objects.requireNonNullElse<String?>(this.group, "") as String,
93-
CraftingRecipeJsonBuilder.toCraftingCategory(this.category),
93+
RecipeBuilder.determineBookCategory(this.category),
9494
rawRecipe,
9595
output,
9696
this.showNotification
9797
)
9898

99-
exporter.accept(recipeKey, recipe, builder.build(recipeKey.value.withPrefixedPath("recipes/" + this.category.getName() + "/")))
99+
exporter.accept(recipeKey, recipe, builder.build(recipeKey.location().withPrefix("recipes/" + this.category.folderName + "/")))
100100
}
101101
}

src/main/java/one/oktw/galaxy/mixin/accessor/PlayerAbilitiesAccessor.java renamed to src/main/java/one/oktw/galaxy/mixin/accessor/AbilitiesAccessor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* OKTW Galaxy Project
3-
* Copyright (C) 2018-2020
3+
* Copyright (C) 2018-2025
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as published
@@ -18,12 +18,12 @@
1818

1919
package one.oktw.galaxy.mixin.accessor;
2020

21-
import net.minecraft.entity.player.PlayerAbilities;
21+
import net.minecraft.world.entity.player.Abilities;
2222
import org.spongepowered.asm.mixin.Mixin;
2323
import org.spongepowered.asm.mixin.gen.Accessor;
2424

25-
@Mixin(PlayerAbilities.class)
26-
public interface PlayerAbilitiesAccessor {
25+
@Mixin(Abilities.class)
26+
public interface AbilitiesAccessor {
2727
@Accessor
28-
void setFlySpeed(float speed);
28+
void setFlyingSpeed(float speed);
2929
}

src/main/java/one/oktw/galaxy/mixin/accessor/BeaconLevelAccessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* OKTW Galaxy Project
3-
* Copyright (C) 2018-2021
3+
* Copyright (C) 2018-2025
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as published
@@ -18,12 +18,12 @@
1818

1919
package one.oktw.galaxy.mixin.accessor;
2020

21-
import net.minecraft.block.entity.BeaconBlockEntity;
21+
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
2222
import org.spongepowered.asm.mixin.Mixin;
2323
import org.spongepowered.asm.mixin.gen.Accessor;
2424

2525
@Mixin(BeaconBlockEntity.class)
2626
public interface BeaconLevelAccessor {
2727
@Accessor
28-
int getLevel();
28+
int getLevels();
2929
}

src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerAction_NetworkHandler.java renamed to src/main/java/one/oktw/galaxy/mixin/event/MixinPlayerAction_ServerGamePacketListener.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
package one.oktw.galaxy.mixin.event;
2020

21-
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
22-
import net.minecraft.network.packet.s2c.play.BlockUpdateS2CPacket;
23-
import net.minecraft.server.network.ServerPlayNetworkHandler;
24-
import net.minecraft.server.network.ServerPlayerEntity;
21+
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
22+
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
23+
import net.minecraft.server.level.ServerPlayer;
24+
import net.minecraft.server.network.ServerGamePacketListenerImpl;
2525
import one.oktw.galaxy.event.EventManager;
2626
import one.oktw.galaxy.event.type.PlayerActionEvent;
2727
import org.spongepowered.asm.mixin.Mixin;
@@ -30,20 +30,17 @@
3030
import org.spongepowered.asm.mixin.injection.Inject;
3131
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3232

33-
@Mixin(ServerPlayNetworkHandler.class)
34-
public abstract class MixinPlayerAction_NetworkHandler {
33+
@Mixin(ServerGamePacketListenerImpl.class)
34+
public abstract class MixinPlayerAction_ServerGamePacketListener {
3535
@Shadow
36-
public ServerPlayerEntity player;
36+
public ServerPlayer player;
3737

38-
@Inject(method = "onPlayerAction", at = @At(
39-
value = "HEAD",
40-
target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;onPlayerAction(Lnet/minecraft/network/packet/c2s/play/PlayerActionC2SPacket;)V"
41-
), cancellable = true)
42-
private void onPlayerAction(PlayerActionC2SPacket packet, CallbackInfo ci) {
38+
@Inject(method = "handlePlayerAction", at = @At(value = "HEAD"), cancellable = true)
39+
private void onPlayerAction(ServerboundPlayerActionPacket packet, CallbackInfo ci) {
4340
if (EventManager.safeEmit(new PlayerActionEvent(packet, player)).getCancel()) {
4441
ci.cancel();
45-
player.networkHandler.sendPacket(new BlockUpdateS2CPacket(player.getEntityWorld(), packet.getPos()));
46-
player.currentScreenHandler.syncState();
42+
player.connection.send(new ClientboundBlockUpdatePacket(player.level(), packet.getPos()));
43+
player.containerMenu.sendAllDataToRemote();
4744
}
4845
}
4946
}

0 commit comments

Comments
 (0)