Skip to content

Commit

Permalink
Migrate to GCAPI3
Browse files Browse the repository at this point in the history
  • Loading branch information
telvarost committed Oct 21, 2024
1 parent f45d91c commit 6ea2aa1
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 128 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'fabric-loom' version '1.7.3'
id 'babric-loom-extension' version '1.7.4'
id 'fabric-loom' version '1.7.4'
id 'babric-loom-extension' version '1.7.5'
id 'maven-publish'
}

Expand Down Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2'
implementation "blue.endless:jankson:1.2.1"
implementation(include("me.carleslc:Simple-Yaml:1.8.4") as Dependency)
implementation("io.github.llamalad7:mixinextras-fabric:${project.properties["mixinextras_version"]}")

modImplementation "net.modificationstation:StationAPI:${project.stapi_version}"
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=b1.7.3
yarn_mappings=b1.7.3+cfb11d9
yarn_mappings=b1.7.3+4cbd9c8
loader_version=0.15.6-babric.1

# Mod Properties
Expand All @@ -18,6 +18,6 @@ stapi_version=2.0-alpha.2
mixinextras_version = 0.2.1

# Extra Dependencies
gcapi_version=2.0.1
howmanyitems_version=5.1.1
gcapi_version=3.0.1
howmanyitems_version=5.2.1
modmenu_version=dcef643
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.github.telvarost.annoyancefix;

import blue.endless.jankson.JsonElement;
import blue.endless.jankson.JsonPrimitive;
import com.google.common.collect.ImmutableMap;
import net.glasslauncher.mods.api.gcapi.api.ConfigFactoryProvider;
import net.glasslauncher.mods.api.gcapi.api.MaxLength;
import net.glasslauncher.mods.api.gcapi.impl.NonFunction;
import net.glasslauncher.mods.api.gcapi.impl.config.ConfigEntry;
import net.glasslauncher.mods.api.gcapi.impl.config.entry.EnumConfigEntry;
import net.glasslauncher.mods.gcapi3.api.*;
import net.glasslauncher.mods.gcapi3.impl.SeptFunction;
import net.glasslauncher.mods.gcapi3.impl.object.ConfigEntryHandler;
import net.glasslauncher.mods.gcapi3.impl.object.entry.EnumConfigEntryHandler;

import java.lang.reflect.*;
import java.util.function.*;

public class BoatCollisionEnumFactory implements ConfigFactoryProvider {

@Override
public void provideLoadFactories(ImmutableMap.Builder<Type, NonFunction<String, String, String, Field, Object, Boolean, Object, Object, MaxLength, ConfigEntry<?>>> immutableBuilder) {
immutableBuilder.put(BoatCollisionEnum.class, ((id, name, description, parentField, parentObject, isMultiplayerSynced, enumOrOrdinal, defaultEnum, maxLength) ->
public void provideLoadFactories(ImmutableMap.Builder<Type, SeptFunction<String, ConfigEntry, Field, Object, Boolean, Object, Object, ConfigEntryHandler<?>>> immutableBuilder) {
immutableBuilder.put(BoatCollisionEnum.class, ((id, configEntry, parentField, parentObject, isMultiplayerSynced, enumOrOrdinal, defaultEnum) ->
{
int enumOrdinal;
if(enumOrOrdinal instanceof Integer ordinal) {
Expand All @@ -24,17 +22,12 @@ public void provideLoadFactories(ImmutableMap.Builder<Type, NonFunction<String,
else {
enumOrdinal = ((BoatCollisionEnum) enumOrOrdinal).ordinal();
}
return new EnumConfigEntry<BoatCollisionEnum>(id, name, description, parentField, parentObject, isMultiplayerSynced, enumOrdinal, ((BoatCollisionEnum) defaultEnum).ordinal(), BoatCollisionEnum.class);
return new EnumConfigEntryHandler<BoatCollisionEnum>(id, configEntry, parentField, parentObject, isMultiplayerSynced, enumOrdinal, ((BoatCollisionEnum) defaultEnum).ordinal(), BoatCollisionEnum.class);
}));
}

@Override
public void provideSaveFactories(ImmutableMap.Builder<Type, Function<Object, JsonElement>> immutableBuilder) {
immutableBuilder.put(BoatCollisionEnum.class, enumEntry -> new JsonPrimitive(((BoatCollisionEnum) enumEntry).ordinal()));
}

@Override
public void provideLoadTypeAdapterFactories(@SuppressWarnings("rawtypes") ImmutableMap.Builder<Type, Class> immutableBuilder) {
immutableBuilder.put(BoatCollisionEnum.class, Integer.class);
public void provideSaveFactories(ImmutableMap.Builder<Type, Function<Object, Object>> immutableBuilder) {
immutableBuilder.put(BoatCollisionEnum.class, enumEntry -> enumEntry);
}
}
Loading

0 comments on commit 6ea2aa1

Please sign in to comment.