Skip to content

Commit

Permalink
refactor: move DataComponentTypesInvoker to Accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchen5209 committed Apr 26, 2024
1 parent b11de54 commit 0267fcf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package one.oktw.galaxy.mixin.invoker;
package one.oktw.galaxy.mixin.accessor;

import net.minecraft.component.DataComponentType;
import net.minecraft.component.DataComponentTypes;
Expand All @@ -26,7 +26,7 @@
import java.util.function.UnaryOperator;

@Mixin(DataComponentTypes.class)
public interface DataComponentTypesInvoker {
public interface DataComponentTypesAccessor {
@Invoker("register")
static <T> DataComponentType<T> invokeRegister(String id, UnaryOperator<DataComponentType.Builder<T>> builderOperator) {
throw new AssertionError();
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package one.oktw.galaxy.item

import net.minecraft.component.DataComponentType
import net.minecraft.component.DataComponentTypes
import net.minecraft.component.type.AttributeModifiersComponent
import net.minecraft.component.type.CustomModelDataComponent
Expand All @@ -28,15 +29,15 @@ import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import one.oktw.galaxy.mixin.invoker.DataComponentTypesInvoker
import one.oktw.galaxy.mixin.accessor.DataComponentTypesAccessor
import one.oktw.galaxy.util.CustomRegistry
import one.oktw.galaxy.util.Registrable

abstract class CustomItem(override val identifier: Identifier, private val baseItem: Item, private val modelData: Int) : Registrable {
companion object {
val registry = CustomRegistry<CustomItem>()

val galaxyDataComponent = DataComponentTypesInvoker.invokeRegister("galaxy_data") { builder ->
val galaxyDataComponent: DataComponentType<NbtComponent> = DataComponentTypesAccessor.invokeRegister("galaxy_data") { builder ->
builder.codec(NbtComponent.CODEC)
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/accessor.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_16",
"mixins": [
"BeaconLevelAccessor",
"DataComponentTypesAccessor",
"PlayerAbilitiesAccessor",
"SerializingRegionBasedStorageAccessor",
"ServerPlayerEntityFunctionAccessor",
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"tweak.mixin.json",
"sponge.realtime.mixin.json",
"accessor.mixin.json",
"recipe.mixin.json",
"invoker.mixin.json"
"recipe.mixin.json"
],
"depends": {
"minecraft": "1.20.x",
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/invoker.mixin.json

This file was deleted.

0 comments on commit 0267fcf

Please sign in to comment.