From ae61b1e240a935334d44293d257be132ee86888d Mon Sep 17 00:00:00 2001 From: Amarok Date: Tue, 17 Sep 2024 21:12:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=BA=F0=9F=9B=A0=EF=B8=8F=E2=9D=8C?= =?UTF-8?q?=F0=9F=AA=84=F0=9F=A5=93=F0=9F=92=BB=F0=9F=92=BE=E2=9C=A8?= =?UTF-8?q?=F0=9F=8D=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kessoku/lib/config/KessokuConfig.java | 23 ++-- .../lib/config/api/AbstractConfig.java | 127 +++++++++++------- .../kessoku/lib/config/api/ConfigValue.java | 10 +- .../api/serializers/Json5Serializer.java | 2 +- .../api/serializers/JsonSerializer.java | 1 + 5 files changed, 99 insertions(+), 64 deletions(-) diff --git a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java index a96f4909..8164f1d7 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; @@ -31,36 +32,40 @@ public final class KessokuConfig { private static final Map> configs = new HashMap<>(); - private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); + private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); + public static final String MOD_ID = "kessoku_config"; public static final Marker MARKER = MarkerFactory.getMarker("[KessokuConfig]"); @SuppressWarnings({"unchecked", "unused"}) public static T register(T config, Class serializer) { if (config.getClass().isAnonymousClass()) throw new IllegalArgumentException(); - final File file = config.getPath().toFile(); + try { - FileUtils.touch(file); + FileUtils.touch(config.getPath().toFile()); } catch (IOException e) { throw new RuntimeException(e); } + configs.put(config, (Class) serializer); return config; } @Contract(pure = true) - public static @Nullable Class getSerializer(T config) { + @Nullable + public static Class getSerializer(T config) { return configs.get(config); } @Contract(pure = true) @SuppressWarnings("unchecked") - public static @NotNull ConfigSerializer getSerializerInstance(Class serializer) { - if (serializerCache.containsKey(serializer)) return serializerCache.get(serializer); + @NotNull + public static T getSerializerInstance(Class serializer) { try { - T serializerInstance = serializer.getConstructor().newInstance(); - serializerCache.put((Class) serializer, serializerInstance); - return serializerInstance; + return (T) Objects.requireNonNull(serializerCache.containsKey(serializer) + ? serializerCache.get(serializer) + : serializerCache.put(serializer, + serializer.getConstructor().newInstance())); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index a36176d9..6f4d70ce 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -35,13 +35,14 @@ import com.google.common.collect.ImmutableMap; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; +import org.apache.logging.log4j.core.util.ReflectionUtil; -//@SuppressWarnings({"rawtypes", "unchecked", "unused"}) +@SuppressWarnings({"rawtypes", "unused"}) public abstract class AbstractConfig { - private final List preSave = new ArrayList<>(); - private final List preLoad = new ArrayList<>(); - private final List postSave = new ArrayList<>(); - private final List postLoad = new ArrayList<>(); + private final List> preSave = new ArrayList<>(); + private final List> preLoad = new ArrayList<>(); + private final List> postSave = new ArrayList<>(); + private final List> postLoad = new ArrayList<>(); private List values; private List categories; private boolean split = false; @@ -53,13 +54,14 @@ public boolean save() { preSave.forEach(consumer -> consumer.accept(this)); File file = this.getPath().toFile(); ConfigSerializer serializer = this.getSerializer(); - boolean result; + + boolean result = true; try (FileWriter writer = new FileWriter(file, StandardCharsets.UTF_8)) { writer.write(serializer.serialize(this.serialize())); - result = true; } catch (IOException e) { result = false; } + final boolean finalResult = result; postSave.forEach(biConsumer -> biConsumer.accept(this, finalResult)); return finalResult; @@ -69,59 +71,62 @@ public boolean load() { preLoad.forEach(consumer -> consumer.accept(this)); ConfigSerializer serializer = this.getSerializer(); File file = this.getPath().toFile(); - boolean result; + + boolean result = true; try { Map map = serializer.deserialize(FileUtils.readFileToString(file, StandardCharsets.UTF_8)); // Put values into the config for (Map.Entry entry : map.entrySet()) { - String string = entry.getKey(); - Object object = entry.getValue(); + String key = entry.getKey(); + Object cValue = entry.getValue(); + ConfigValue value; // Check the value is public and not static try { - Field field = this.getClass().getField(string); + Field field = this.getClass().getField(key); if (!Modifier.isPublic(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) continue; - value = (ConfigValue) field.get(this); - } catch (NoSuchFieldException | IllegalAccessException e) { + value = (ConfigValue) ReflectionUtil.getFieldValue(field, this); + } catch (NoSuchFieldException e) { continue; } - ConfigValue.Type type; + + ConfigValue.Type type = ConfigValue.Type.asType(cValue); // Check if the type is valid to deserialize - try { - type = ConfigValue.Type.asType(object); - } catch (IllegalArgumentException e) { - ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file!", object.getClass().getName()); + if (type == ConfigValue.Type.NULL) { + ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file!", cValue.getClass().getName()); continue; } + // Check if the type matches the value's type if (value.getType() != type) { ModUtils.getLogger().error(KessokuConfig.MARKER, "Illegal type`{}` found in the file! Expect {}.", type.toString().toLowerCase(), value.getType().toString().toLowerCase()); continue; } - value.setTo(object); + + value.setTo(cValue); } - result = true; } catch (IOException e) { result = false; } + final boolean finalResult = result; postLoad.forEach(biConsumer -> biConsumer.accept(this, finalResult)); return finalResult; } - public void registerPreSaveListener(Consumer preSave) { + public void registerPreSaveListener(Consumer preSave) { this.preSave.add(preSave); } - public void registerPreLoadListener(Consumer preLoad) { + public void registerPreLoadListener(Consumer preLoad) { this.preLoad.add(preLoad); } - public void registerPostSaveListener(BiConsumer postSave) { + public void registerPostSaveListener(BiConsumer postSave) { this.postSave.add(postSave); } - public void registerPostLoadListener(BiConsumer postLoad) { + public void registerPostLoadListener(BiConsumer postLoad) { this.postLoad.add(postLoad); } @@ -131,37 +136,41 @@ public void reset() { } public ImmutableList> getValidValues() { - if (this.values != null) - return ImmutableList.>builder().addAll(this.values.stream().map(field -> { - try { - return (ConfigValue) field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }).toList()).build(); + if (this.values != null) { + return ImmutableList.>builder().addAll(this.values.stream().map(field -> + (ConfigValue) ReflectionUtil.getFieldValue(field, this)).toList()).build(); + } + List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if (declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class) && Modifier.isPublic(declaredField.getModifiers()) && !Modifier.isStatic(declaredField.getModifiers())) + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); + final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); + final boolean flag2 = !Modifier.isStatic(declaredField.getModifiers()); + if (flag0 && flag1 && flag2) { fields.add(declaredField); + } } + this.values = fields; return this.getValidValues(); } public ImmutableList getValidCategories() { - if (this.categories != null) - return ImmutableList.builder().addAll(this.categories.stream().map(field -> { - try { - return (AbstractConfig) field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }).toList()).build(); + if (this.categories != null){ + return ImmutableList.builder().addAll(this.categories.stream().map(field -> + (AbstractConfig) ReflectionUtil.getFieldValue(field, this)).toList()).build(); + } + List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if (declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class) && Modifier.isPublic(declaredField.getModifiers())) + + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); + final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); + if (flag0 && flag1){ fields.add(declaredField); + } } + this.categories = fields; return this.getValidCategories(); } @@ -169,8 +178,16 @@ public ImmutableList getValidCategories() { private ImmutableList getValidFields() { ImmutableList.Builder builder = ImmutableList.builder(); for (Field declaredField : this.getClass().getDeclaredFields()) { - if ((declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class) || declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class)) && Modifier.isPublic(declaredField.getModifiers())) + + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); + final boolean flag1 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); + final boolean flag2 = Modifier.isPublic(declaredField.getModifiers()); + + final var flag = flag0 || flag1; + + if (flag && flag2){ builder.add(declaredField); + } } return builder.build(); } @@ -178,21 +195,20 @@ private ImmutableList getValidFields() { private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { + field.setAccessible(true); final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; - Object o; - try { - o = field.get(this); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + + Object fieldValue = ReflectionUtil.getFieldValue(field, this); + // ConfigValue - if (o instanceof ConfigValue value) { + if (fieldValue instanceof ConfigValue value) { builder.put(name, new ValueWithComment(value.get(), comments)); continue; } + // Category - AbstractConfig category = (AbstractConfig) o; + AbstractConfig category = (AbstractConfig) fieldValue; if (this.split) { if (!category.save()) { ModUtils.getLogger().error(KessokuConfig.MARKER, "Failed to save category `{}!`", category.getSimpleName()); @@ -212,13 +228,20 @@ public boolean isSplitToFiles() { return this.split; } + /** + * Get config full name. If it's a sub file, it will include the paths. + * @return Get the full name of the config. + */ // Not including file ext, but parent path `/` public String getName() { Name name = this.getClass().getAnnotation(Name.class); return name == null ? this.getClass().getSimpleName() : name.value(); } - // Just config name + /** + * Get the config name. Even it's a sub file, just config name. + * @return The simple config name. + */ public String getSimpleName() { String[] strings = this.getName().split("/"); return strings[strings.length - 1]; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java index b2a371f8..7868674a 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/ConfigValue.java @@ -42,7 +42,7 @@ default F get() { T getDefaultTo(); enum Type { - LIST, MAP, BOOLEAN, STRING, INTEGER, LONG, FLOAT, DOUBLE; + LIST, MAP, BOOLEAN, STRING, INTEGER, LONG, FLOAT, DOUBLE, NULL; public static Type asType(Object o) { return switch (o) { @@ -54,7 +54,13 @@ public static Type asType(Object o) { case Integer ignored -> INTEGER; case Float ignored -> FLOAT; case Double ignored -> DOUBLE; - case null, default -> throw new IllegalArgumentException(); + + /* AmarokIce Note: + try catch 对性能会造成额外影响。此处 throw 后在 { @code AbstractConfig } 中捕获是无意义的。 + 因此,改用 NULL 作为空置对象。 + */ + case null, default -> NULL; + // case null, default -> throw new IllegalArgumentException(); }; } } diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java index 28e42019..e206fd37 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java @@ -23,7 +23,7 @@ import club.someoneice.json.node.JsonNode; import club.someoneice.json.processor.Json5Builder; -//todo +// TODO public class Json5Serializer implements ConfigSerializer { @Override public String serialize(Map value) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java index 42b983cf..04edba7e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java @@ -33,6 +33,7 @@ public String serialize(Map value) { .map(it -> new Pair<>(it.getKey(), JsonNode.asJsonNodeOrEmpty(it.getValue().object()))) .filter(it -> it.getValue().nonNull()) .forEach(it -> node.put(it.getKey(), it.getValue())); + return JsonBuilder.prettyPrint(node); } From 995bc9eaf377437269f4828b0e95b0633c05ac54 Mon Sep 17 00:00:00 2001 From: Amarok Date: Tue, 17 Sep 2024 21:13:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=BA=E2=81=89=EF=B8=8F=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/band/kessoku/lib/base/ModUtils.java | 6 ++--- .../api/events/CommandRegistryEvent.java | 1 - .../testmod/command/KessokuTestCommand.java | 1 - .../lib/command/KessokuCommandEntrypoint.java | 1 - .../lib/command/impl/KessokuCommandImpl.java | 1 - .../lib/command/KessokuCommandEntrypoint.java | 1 - .../lib/command/impl/KessokuCommandImpl.java | 1 - .../kessoku/lib/config/KessokuConfig.java | 11 +++++----- .../lib/config/api/AbstractConfig.java | 22 +++++++++---------- .../api/serializers/Json5Serializer.java | 4 ++-- .../api/serializers/JsonSerializer.java | 4 ++-- .../api/serializers/TomlSerializer.java | 4 ++-- .../lib/config/api/values/BooleanValue.java | 4 ++-- .../config/api/values/DefaultConfigValue.java | 4 ++-- .../lib/config/api/values/DoubleValue.java | 4 ++-- .../lib/config/api/values/FloatValue.java | 4 ++-- .../lib/config/api/values/IntegerValue.java | 4 ++-- .../lib/config/api/values/ListValue.java | 6 ++--- .../lib/config/api/values/LongValue.java | 4 ++-- .../lib/config/api/values/MapValue.java | 9 +++++--- .../lib/config/api/values/StringValue.java | 4 ++-- .../lib/data/mixin/BlockEntityMixin.java | 4 ++-- .../api/ServerEntityWorldChangeEvent.java | 1 - .../entity/api/ServerLivingEntityEvent.java | 1 - .../events/entity/api/ServerPlayerEvent.java | 1 - .../entity/KessokuEntityEventEntrypoint.java | 1 - .../entity/KessokuEntityEventEntrypoint.java | 2 -- .../lib/events/entity/mixin/EntityMixin.java | 13 +++++------ .../entity/mixin/IItemExtensionMixin.java | 8 +++---- .../entity/mixin/LivingEntityMixin.java | 22 ++++++++++--------- .../events/entity/mixin/MobEntityMixin.java | 5 ++--- .../entity/mixin/PlayerEntityMixin.java | 3 +-- .../entity/mixin/PlayerManagerMixin.java | 7 +++--- .../entity/mixin/ServerPlayerEntityMixin.java | 21 +++++++++--------- .../mixin/elytra/LivingEntityMixin.java | 9 ++++---- .../mixin/elytra/PlayerEntityMixin.java | 9 ++++---- .../KessokuEntrypointEntrypoint.java | 11 +++++----- .../KessokuEntrypointEntrypoint.java | 9 ++++---- .../band/kessoku/lib/event/api/Event.java | 4 ++-- .../kessoku/lib/event/impl/EventImpl.java | 6 ++--- .../lib/event/KessokuEventBaseEntrypoint.java | 1 - .../kessoku/lib/event/util/NeoEventUtils.java | 4 ++-- .../lib/keybind/api/KeyBindRegister.java | 1 - .../testmod/keybind/KessokuTestKeybind.java | 1 - .../lib/keybind/KessokuKeybindEntrypoint.java | 1 - .../lib/keybind/impl/KeyBindRegisterImpl.java | 6 ++--- .../lib/keybind/KessokuKeyBindEntrypoint.java | 1 - .../lib/keybind/impl/KeyBindRegisterImpl.java | 10 ++++----- .../lib/keybind/mixin/KeyBindingAccessor.java | 7 +++--- .../events/lifecycle/api/LifecycleEvent.java | 1 - .../lifecycle/api/ServerBlockEntityEvent.java | 1 - .../lifecycle/api/ServerChunkEvent.java | 1 - .../lifecycle/api/ServerEntityEvent.java | 1 - .../lifecycle/api/ServerLifecycleEvent.java | 1 - .../events/lifecycle/api/ServerTickEvent.java | 1 - .../lifecycle/api/ServerWorldEvent.java | 1 - .../api/client/ClientBlockEntityEvent.java | 1 - .../api/client/ClientChunkEvent.java | 1 - .../api/client/ClientEntityEvent.java | 1 - .../api/client/ClientLifecycleEvent.java | 1 - .../lifecycle/api/client/ClientTickEvent.java | 1 - .../impl/KessokuLifecycleEventsImpl.java | 1 - .../lifecycle/impl/LoadedChunksCache.java | 4 ++-- .../events/lifecycle/mixin/WorldMixin.java | 9 ++++---- .../lifecycle/KessokuTestLifecycle.java | 3 ++- .../lifecycle/ServerBlockEntityTests.java | 7 +++--- .../testmod/lifecycle/ServerEntityTests.java | 7 +++--- .../testmod/lifecycle/ServerTickTests.java | 7 +++--- .../KessokuLifecycleEventsEntrypoint.java | 1 - .../KessokuLifecycleEventsImplFabric.java | 1 - .../KessokuLifecycleEventsEntrypoint.java | 1 - .../impl/KessokuLifecycleEventsImplNeo.java | 2 -- .../mixin/neo/MinecraftServerMixin.java | 7 +++--- .../mixin/neo/ServerEntityHandlerMixin.java | 5 ++--- .../lifecycle/mixin/neo/ServerWorldMixin.java | 5 ++--- .../neo/client/ClientChunkManagerMixin.java | 17 +++++++------- .../neo/client/ClientEntityHandlerMixin.java | 5 ++--- .../client/ClientPlayNetworkHandlerMixin.java | 11 +++++----- .../neo/client/MinecraftClientMixin.java | 3 +-- .../mixin/neo/client/WorldChunkMixin.java | 15 ++++++------- .../mixin/neo/server/WorldChunkMixin.java | 13 +++++------ .../kessoku-lifecycle-events.neo.mixins.json | 2 +- .../kessoku/lib/platform/api/ModLoader.java | 4 ++-- .../platform/KessokuPlatformEntrypoint.java | 1 - .../lib/platform/impl/ModDataImpl.java | 13 +++++------ .../platform/impl/ModDependencyInfoImpl.java | 1 - .../lib/platform/impl/ModLoaderImpl.java | 11 +++++----- .../platform/KessokuPlatformEntrypoint.java | 1 - .../lib/platform/impl/ModDataImpl.java | 12 +++++----- .../platform/impl/ModDependencyInfoImpl.java | 1 - .../lib/platform/impl/ModLoaderImpl.java | 11 +++++----- .../lib/registry/api/FuelRegistry.java | 17 +++++++------- .../kessoku/lib/registry/api/Registry.java | 3 +-- .../registry/KessokuRegistryEntrypoint.java | 1 - .../lib/registry/impl/RegistryImpl.java | 1 - .../AbstractFurnaceBlockEntityMixin.java | 11 +++++----- .../registry/KessokuRegistryEntrypoint.java | 2 -- .../lib/registry/impl/RegistryImpl.java | 11 +++++----- 98 files changed, 218 insertions(+), 290 deletions(-) diff --git a/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java b/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java index ca3b49d0..1fc1cac6 100644 --- a/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java +++ b/base/common/src/main/java/band/kessoku/lib/base/ModUtils.java @@ -15,13 +15,13 @@ */ package band.kessoku.lib.base; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Constructor; import java.util.List; import java.util.ServiceLoader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ModUtils { public static T loadService(Class clazz) { return ServiceLoader.load(clazz).findFirst().orElseThrow(() -> new AssertionError("No impl found for " + clazz.getName())); diff --git a/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java b/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java index cf7cccf3..e6f1780f 100644 --- a/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java +++ b/command/common/src/main/java/band/kessoku/lib/command/api/events/CommandRegistryEvent.java @@ -17,7 +17,6 @@ import band.kessoku.lib.event.api.Event; import com.mojang.brigadier.CommandDispatcher; - import net.minecraft.command.CommandRegistryAccess; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; diff --git a/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java b/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java index b1ff2f82..c01b1a6a 100644 --- a/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java +++ b/command/common/src/test/java/kessoku/testmod/command/KessokuTestCommand.java @@ -17,7 +17,6 @@ import band.kessoku.lib.command.api.events.CommandRegistryEvent; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; - import net.minecraft.server.command.CommandManager; import net.minecraft.text.Text; diff --git a/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java b/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java index 906e9535..e37cd1f3 100644 --- a/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java +++ b/command/fabric/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.command.impl.KessokuCommandImpl; - import net.fabricmc.api.ModInitializer; public class KessokuCommandEntrypoint implements ModInitializer { diff --git a/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java b/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java index 79960bc7..565b0902 100644 --- a/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java +++ b/command/fabric/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.command.impl; import band.kessoku.lib.command.api.events.CommandRegistryEvent; - import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; public class KessokuCommandImpl { diff --git a/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java b/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java index 16decb44..581e8ad9 100644 --- a/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java +++ b/command/neo/src/main/java/band/kessoku/lib/command/KessokuCommandEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.command.impl.KessokuCommandImpl; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; diff --git a/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java b/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java index 9ac6a938..b265eaae 100644 --- a/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java +++ b/command/neo/src/main/java/band/kessoku/lib/command/impl/KessokuCommandImpl.java @@ -17,7 +17,6 @@ import band.kessoku.lib.command.api.events.CommandRegistryEvent; import band.kessoku.lib.event.util.NeoEventUtils; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.event.RegisterCommandsEvent; diff --git a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java index 8164f1d7..e9a021b1 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/KessokuConfig.java @@ -15,12 +15,6 @@ */ package band.kessoku.lib.config; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import org.apache.commons.io.FileUtils; @@ -30,6 +24,11 @@ import org.slf4j.Marker; import org.slf4j.MarkerFactory; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + public final class KessokuConfig { private static final Map> configs = new HashMap<>(); private static final Map, ConfigSerializer> serializerCache = new HashMap<>(); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index 6f4d70ce..2c3041bf 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -15,17 +15,6 @@ */ package band.kessoku.lib.config.api; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.config.KessokuConfig; import band.kessoku.lib.config.api.annotations.Comment; @@ -37,6 +26,17 @@ import org.apache.commons.io.FilenameUtils; import org.apache.logging.log4j.core.util.ReflectionUtil; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.*; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + @SuppressWarnings({"rawtypes", "unused"}) public abstract class AbstractConfig { private final List> preSave = new ArrayList<>(); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java index e206fd37..3e5c3f40 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/Json5Serializer.java @@ -15,14 +15,14 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import club.someoneice.json.JSON; import club.someoneice.json.node.JsonNode; import club.someoneice.json.processor.Json5Builder; +import java.util.Map; + // TODO public class Json5Serializer implements ConfigSerializer { @Override diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java index 04edba7e..38d331a4 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/JsonSerializer.java @@ -15,8 +15,6 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import club.someoneice.json.JSON; @@ -25,6 +23,8 @@ import club.someoneice.json.node.MapNode; import club.someoneice.json.processor.JsonBuilder; +import java.util.Map; + public class JsonSerializer implements ConfigSerializer { @Override public String serialize(Map value) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java index 23bbd29c..5b5afe5b 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/serializers/TomlSerializer.java @@ -15,12 +15,12 @@ */ package band.kessoku.lib.config.api.serializers; -import java.util.Map; - import band.kessoku.lib.config.api.AbstractConfig; import band.kessoku.lib.config.api.ConfigSerializer; import com.electronwill.nightconfig.core.CommentedConfig; +import java.util.Map; + //todo public class TomlSerializer implements ConfigSerializer { @Override diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java index 34ff72d2..b9120543 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/BooleanValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class BooleanValue extends DefaultConfigValue { private BooleanValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java index 220814f5..460c8623 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DefaultConfigValue.java @@ -15,10 +15,10 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import band.kessoku.lib.config.api.ConfigValue; +import java.util.function.Supplier; + sealed abstract class DefaultConfigValue implements ConfigValue permits BooleanValue, DoubleValue, FloatValue, IntegerValue, ListValue, LongValue, MapValue, StringValue { public final Supplier defaultValue; public T value; diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java index 966e0913..3c05a1b7 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/DoubleValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class DoubleValue extends DefaultConfigValue { private DoubleValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java index 40a495d4..1d66d0ff 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/FloatValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class FloatValue extends DefaultConfigValue { private FloatValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java index b8f778f1..ce7539cb 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/IntegerValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class IntegerValue extends DefaultConfigValue { private IntegerValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java index 193d9a63..ecf17e84 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/ListValue.java @@ -15,14 +15,14 @@ */ package band.kessoku.lib.config.api.values; -import java.util.*; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; +import java.util.*; +import java.util.function.Supplier; + @SuppressWarnings({"rawtypes"}) public final class ListValue extends DefaultConfigValue> implements List { private ListValue(Supplier> defaultValue) { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java index e068ea14..2de89dc5 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/LongValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class LongValue extends DefaultConfigValue { private LongValue(Supplier defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java index 9a583caf..39858f37 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/MapValue.java @@ -15,15 +15,18 @@ */ package band.kessoku.lib.config.api.values; -import java.util.*; -import java.util.function.Supplier; - import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Supplier; + public final class MapValue extends DefaultConfigValue> implements Map { private MapValue(Supplier> defaultValue) { super(defaultValue); diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java index db6a43aa..6d75a28e 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/values/StringValue.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.config.api.values; -import java.util.function.Supplier; - import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import java.util.function.Supplier; + public final class StringValue extends DefaultConfigValue { private StringValue(Supplier defaultValue) { super(defaultValue); diff --git a/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java b/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java index 959b7b27..d01a2982 100644 --- a/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java +++ b/data/common/src/main/java/band/kessoku/lib/data/mixin/BlockEntityMixin.java @@ -1,9 +1,9 @@ package band.kessoku.lib.data.mixin; +import band.kessoku.lib.data.api.BlockEntityStructure; import band.kessoku.lib.data.api.Data; -import band.kessoku.lib.data.api.NBTSerializable; import band.kessoku.lib.data.api.DataStructure; -import band.kessoku.lib.data.api.BlockEntityStructure; +import band.kessoku.lib.data.api.NBTSerializable; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.RegistryWrapper; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java index 724fb1d7..1208e598 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerEntityWorldChangeEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.Entity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java index 359aa10e..55a8602f 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerLivingEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.MobEntity; diff --git a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java index 2f70fa21..6a00958f 100644 --- a/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java +++ b/entity-events/common/src/main/java/band/kessoku/lib/events/entity/api/ServerPlayerEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.entity.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.network.ServerPlayerEntity; public class ServerPlayerEvent { diff --git a/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java b/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java index d1b65fdd..9ae2dcc4 100644 --- a/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java +++ b/entity-events/fabric/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.events.entity.api.EntityElytraEvent; import band.kessoku.lib.events.entity.api.EntitySleepEvent; - import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.entity.event.v1.EntityElytraEvents; import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents; diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java index 18e450ca..1355e9a2 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/KessokuEntityEventEntrypoint.java @@ -19,12 +19,10 @@ import band.kessoku.lib.events.entity.api.EntitySleepEvent; import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import band.kessoku.lib.events.entity.api.ServerPlayerEvent; - import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.ActionResult; - import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.entity.living.LivingConversionEvent; diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java index a771b369..bbc7b00b 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/EntityMixin.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.Set; - import band.kessoku.lib.events.entity.api.ServerEntityWorldChangeEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.entity.Entity; +import net.minecraft.network.packet.s2c.play.PositionFlag; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.TeleportTarget; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.network.packet.s2c.play.PositionFlag; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.world.TeleportTarget; -import net.minecraft.world.World; +import java.util.Set; @Mixin(Entity.class) abstract class EntityMixin { diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java index 7605d65e..7156960e 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/IItemExtensionMixin.java @@ -16,16 +16,14 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.item.KessokuElytraItem; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.neoforged.neoforge.common.extensions.IItemExtension; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; - -import net.neoforged.neoforge.common.extensions.IItemExtension; - @Mixin(IItemExtension.class) public interface IItemExtensionMixin { @Inject(method = "canElytraFly", at = @At("HEAD"), cancellable = true) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java index 89c9a4f5..8f7a3141 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/LivingEntityMixin.java @@ -15,22 +15,12 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.Optional; - import band.kessoku.lib.events.entity.api.EntitySleepEvent; import band.kessoku.lib.events.entity.api.ServerEntityCombatEvent; import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BedBlock; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -46,6 +36,18 @@ import net.minecraft.world.CollisionView; import net.minecraft.world.World; import net.minecraft.world.WorldView; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Optional; @Mixin(LivingEntity.class) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java index beadba7d..ee612144 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/MobEntityMixin.java @@ -17,13 +17,12 @@ import band.kessoku.lib.events.entity.api.ServerLivingEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.entity.Entity; +import net.minecraft.entity.mob.MobEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -import net.minecraft.entity.Entity; -import net.minecraft.entity.mob.MobEntity; - @Mixin(MobEntity.class) public class MobEntityMixin { @ModifyArg(method = "convertTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java index 3a33f202..3a4e042d 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerEntityMixin.java @@ -16,13 +16,12 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.EntitySleepEvent; +import net.minecraft.entity.player.PlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.player.PlayerEntity; - @Mixin(PlayerEntity.class) abstract class PlayerEntityMixin { @Inject(method = "canResetTimeBySleeping", at = @At("RETURN"), cancellable = true) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java index d4a2d9e8..e9e255a3 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/PlayerManagerMixin.java @@ -16,15 +16,14 @@ package band.kessoku.lib.events.entity.mixin; import band.kessoku.lib.events.entity.api.ServerPlayerEvent; +import net.minecraft.entity.Entity; +import net.minecraft.server.PlayerManager; +import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.Entity; -import net.minecraft.server.PlayerManager; -import net.minecraft.server.network.ServerPlayerEntity; - @Mixin(PlayerManager.class) abstract class PlayerManagerMixin { @Inject(method = "respawnPlayer", at = @At("TAIL")) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java index 1c45fd24..78e9dc39 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/ServerPlayerEntityMixin.java @@ -15,20 +15,9 @@ */ package band.kessoku.lib.events.entity.mixin; -import java.util.List; - import band.kessoku.lib.events.entity.api.*; import com.llamalad7.mixinextras.sugar.Local; import com.mojang.datafixers.util.Either; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -44,6 +33,16 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; @Mixin(ServerPlayerEntity.class) abstract class ServerPlayerEntityMixin extends LivingEntityMixin { diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java index 3e5c653d..6d1bc813 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/LivingEntityMixin.java @@ -16,15 +16,14 @@ package band.kessoku.lib.events.entity.mixin.elytra; import band.kessoku.lib.events.entity.api.EntityElytraEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @SuppressWarnings("unused") @Mixin(LivingEntity.class) diff --git a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java index 61431727..4f976263 100644 --- a/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java +++ b/entity-events/neo/src/main/java/band/kessoku/lib/events/entity/mixin/elytra/PlayerEntityMixin.java @@ -16,17 +16,16 @@ package band.kessoku.lib.events.entity.mixin.elytra; import band.kessoku.lib.events.entity.api.EntityElytraEvent; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; - @SuppressWarnings("unused") @Mixin(PlayerEntity.class) abstract class PlayerEntityMixin extends LivingEntity { diff --git a/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 77ebc5b7..d26a67db 100644 --- a/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/fabric/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -15,17 +15,11 @@ */ package band.kessoku.lib.entrypoint; -import java.lang.reflect.InvocationTargetException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Map; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.entrypoint.api.KessokuClientModInitializer; import band.kessoku.lib.entrypoint.api.KessokuDedicatedServerModInitializer; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import com.google.common.collect.ImmutableMap; - import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.ModInitializer; @@ -33,6 +27,11 @@ import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import java.lang.reflect.InvocationTargetException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Map; + public class KessokuEntrypointEntrypoint implements ModInitializer, ClientModInitializer, DedicatedServerModInitializer, PreLaunchEntrypoint { private static ImmutableMap modInfoList; diff --git a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java index 95b992b1..3585114b 100644 --- a/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java +++ b/entrypoint/neo/src/main/java/band/kessoku/lib/entrypoint/KessokuEntrypointEntrypoint.java @@ -15,20 +15,19 @@ */ package band.kessoku.lib.entrypoint; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.entrypoint.api.KessokuClientModInitializer; import band.kessoku.lib.entrypoint.api.KessokuDedicatedServerModInitializer; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import com.google.common.collect.ImmutableList; - import net.neoforged.api.distmarker.Dist; import net.neoforged.fml.ModList; import net.neoforged.fml.common.Mod; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + @Mod(KessokuEntrypoint.MOD_ID) public final class KessokuEntrypointEntrypoint { private static final Map> entrypointMap = new HashMap<>(); diff --git a/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java b/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java index 667fb68f..c2d742fb 100644 --- a/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java +++ b/event-base/common/src/main/java/band/kessoku/lib/event/api/Event.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.event.api; +import band.kessoku.lib.event.impl.EventImpl; + import java.util.List; import java.util.function.Function; -import band.kessoku.lib.event.impl.EventImpl; - public interface Event { T invoker(); diff --git a/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java b/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java index 15d17394..9336c11f 100644 --- a/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java +++ b/event-base/common/src/main/java/band/kessoku/lib/event/impl/EventImpl.java @@ -15,15 +15,15 @@ */ package band.kessoku.lib.event.impl; +import band.kessoku.lib.event.api.Event; +import band.kessoku.lib.event.api.EventPhase; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Function; -import band.kessoku.lib.event.api.Event; -import band.kessoku.lib.event.api.EventPhase; - public class EventImpl implements Event { private Map> listeners = new HashMap<>(); diff --git a/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java b/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java index 2b954047..a41b9cec 100644 --- a/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java +++ b/event-base/fabric/src/main/java/band/kessoku/lib/event/KessokuEventBaseEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.event; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuEventBaseEntrypoint implements ModInitializer { diff --git a/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java b/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java index 96d4d952..7684094d 100644 --- a/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java +++ b/event-base/neo/src/main/java/band/kessoku/lib/event/util/NeoEventUtils.java @@ -15,12 +15,12 @@ */ package band.kessoku.lib.event.util; -import java.util.function.Consumer; - import net.neoforged.bus.api.Event; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; +import java.util.function.Consumer; + public class NeoEventUtils { public static void registerEvent(IEventBus eventBus, Class eventClass, Consumer consumer) { eventBus.addListener(EventPriority.HIGHEST, eventClass, consumer); diff --git a/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java b/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java index 4b093883..2cbf21a0 100644 --- a/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java +++ b/keybind/common/src/main/java/band/kessoku/lib/keybind/api/KeyBindRegister.java @@ -16,7 +16,6 @@ package band.kessoku.lib.keybind.api; import band.kessoku.lib.keybind.impl.KessokuKeyBindService; - import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; diff --git a/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java b/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java index f29c5bf1..f0b7f9ca 100644 --- a/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java +++ b/keybind/common/src/test/java/kessoku/testmod/keybind/KessokuTestKeybind.java @@ -17,7 +17,6 @@ import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.keybind.api.KeyBindRegister; - import net.minecraft.client.option.KeyBinding; public class KessokuTestKeybind implements KessokuModInitializer { diff --git a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java index 8f7747ca..dd08fd87 100644 --- a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java +++ b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/KessokuKeybindEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.keybind; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ClientModInitializer; public class KessokuKeybindEntrypoint implements ClientModInitializer { diff --git a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 832ac4c0..d5764291 100644 --- a/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/fabric/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -17,12 +17,10 @@ import band.kessoku.lib.keybind.api.KeyBindRegister; import com.google.auto.service.AutoService; - -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; - import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java index b1f8642a..08b76ae1 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/KessokuKeyBindEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.keybind.impl.KeyBindRegisterImpl; - import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 6ca1fe4f..09c9e343 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -15,22 +15,20 @@ */ package band.kessoku.lib.keybind.impl; -import java.util.List; -import java.util.Map; -import java.util.Optional; - import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.keybind.api.KeyBindRegister; import band.kessoku.lib.keybind.mixin.KeyBindingAccessor; import com.google.auto.service.AutoService; import it.unimi.dsi.fastutil.objects.ReferenceArrayList; - import net.minecraft.client.option.KeyBinding; import net.minecraft.client.util.InputUtil; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import java.util.List; +import java.util.Map; +import java.util.Optional; + @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { private static final List KEY_BINDINGS = new ReferenceArrayList<>(); diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java index 6af6106e..761b190d 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/mixin/KeyBindingAccessor.java @@ -15,13 +15,12 @@ */ package band.kessoku.lib.keybind.mixin; -import java.util.Map; - +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.client.option.KeyBinding; -import net.minecraft.client.util.InputUtil; +import java.util.Map; @Mixin(KeyBinding.class) public interface KeyBindingAccessor { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java index 8eac0596..8da71c44 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/LifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.registry.DynamicRegistryManager; public class LifecycleEvent { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java index a361d47b..be8f5023 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerBlockEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java index df360d56..56281165 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerChunkEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.world.ServerWorld; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java index 5317a735..541e7f99 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.entity.Entity; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java index d09a8556..83855139 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerLifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.resource.LifecycledResourceManager; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java index c243dc31..ff4ff747 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerTickEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java index 90c799a6..ab56c956 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/ServerWorldEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api; import band.kessoku.lib.event.api.Event; - import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java index cfe0a47e..8236ef45 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientBlockEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.world.ClientWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java index 3ba54e83..902aa49e 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientChunkEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.world.ClientWorld; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java index 6648b8a2..f7723e72 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientEntityEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java index b1077d81..c86a245b 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientLifecycleEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.MinecraftClient; public class ClientLifecycleEvent { diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java index d9350779..16afe29a 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/api/client/ClientTickEvent.java @@ -16,7 +16,6 @@ package band.kessoku.lib.events.lifecycle.api.client; import band.kessoku.lib.event.api.Event; - import net.minecraft.client.MinecraftClient; import net.minecraft.client.world.ClientWorld; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java index 8474941f..9e6a35ea 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImpl.java @@ -19,7 +19,6 @@ import band.kessoku.lib.events.lifecycle.api.ServerChunkEvent; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; import band.kessoku.lib.events.lifecycle.api.ServerWorldEvent; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.minecraft.world.chunk.WorldChunk; diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java index 3ce366bd..8a0140ef 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/impl/LoadedChunksCache.java @@ -15,10 +15,10 @@ */ package band.kessoku.lib.events.lifecycle.impl; -import java.util.Set; - import net.minecraft.world.chunk.WorldChunk; +import java.util.Set; + /** * A simple marker interface which holds references to chunks which block entities may be loaded or unloaded from. */ diff --git a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java index 2cb52317..68a19b0c 100644 --- a/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java +++ b/lifecycle-events/common/src/main/java/band/kessoku/lib/events/lifecycle/mixin/WorldMixin.java @@ -15,15 +15,14 @@ */ package band.kessoku.lib.events.lifecycle.mixin; -import java.util.HashSet; -import java.util.Set; - import band.kessoku.lib.events.lifecycle.impl.LoadedChunksCache; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.HashSet; +import java.util.Set; @Mixin(World.class) public abstract class WorldMixin implements LoadedChunksCache { diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java index c404f6ac..7378a833 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/KessokuTestLifecycle.java @@ -16,7 +16,8 @@ package kessoku.testmod.lifecycle; import band.kessoku.lib.entrypoint.api.KessokuModInitializer; -import band.kessoku.lib.events.lifecycle.api.*; +import band.kessoku.lib.events.lifecycle.api.ServerChunkEvent; +import band.kessoku.lib.events.lifecycle.api.ServerLifecycleEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java index 6014007c..83d6ef65 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerBlockEntityTests.java @@ -15,15 +15,14 @@ */ package kessoku.testmod.lifecycle; -import java.util.ArrayList; -import java.util.List; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.registry.Registries; +import java.util.ArrayList; +import java.util.List; + public class ServerBlockEntityTests implements KessokuModInitializer { private final List serverBlockEntities = new ArrayList<>(); diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java index 8b790b6a..9267e48f 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerEntityTests.java @@ -15,14 +15,13 @@ */ package kessoku.testmod.lifecycle; -import java.util.ArrayList; -import java.util.List; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; - import net.minecraft.entity.Entity; +import java.util.ArrayList; +import java.util.List; + public class ServerEntityTests implements KessokuModInitializer { private final List serverEntities = new ArrayList<>(); diff --git a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java index 2da00487..3d7dfa89 100644 --- a/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java +++ b/lifecycle-events/common/src/test/java/kessoku/testmod/lifecycle/ServerTickTests.java @@ -15,15 +15,14 @@ */ package kessoku.testmod.lifecycle; -import java.util.HashMap; -import java.util.Map; - import band.kessoku.lib.entrypoint.api.KessokuModInitializer; import band.kessoku.lib.events.lifecycle.api.ServerTickEvent; - import net.minecraft.registry.RegistryKey; import net.minecraft.world.World; +import java.util.HashMap; +import java.util.Map; + public class ServerTickTests implements KessokuModInitializer { private final Map, Integer> tickTracker = new HashMap<>(); diff --git a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java index 29c6ab5f..2dccd782 100644 --- a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java +++ b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.events.lifecycle.impl.KessokuLifecycleEventsImplFabric; - import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ModInitializer; diff --git a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java index 1fe1b20f..f08462a7 100644 --- a/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java +++ b/lifecycle-events/fabric/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplFabric.java @@ -17,7 +17,6 @@ import band.kessoku.lib.events.lifecycle.api.*; import band.kessoku.lib.events.lifecycle.api.client.*; - import net.fabricmc.fabric.api.client.event.lifecycle.v1.*; import net.fabricmc.fabric.api.event.lifecycle.v1.*; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java index f0bceac8..16f01db3 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/KessokuLifecycleEventsEntrypoint.java @@ -17,7 +17,6 @@ import band.kessoku.lib.base.ModUtils; import band.kessoku.lib.events.lifecycle.impl.KessokuLifecycleEventsImplNeo; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java index 1175d724..29facebc 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/impl/KessokuLifecycleEventsImplNeo.java @@ -18,13 +18,11 @@ import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.events.lifecycle.api.*; import band.kessoku.lib.events.lifecycle.api.client.ClientChunkEvent; - import net.minecraft.client.MinecraftClient; import net.minecraft.client.world.ClientWorld; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.chunk.WorldChunk; - import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.client.event.ClientTickEvent; import net.neoforged.neoforge.event.OnDatapackSyncEvent; diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java index dfede6e7..4d736c41 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/MinecraftServerMixin.java @@ -15,17 +15,16 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo; -import java.util.Collection; -import java.util.concurrent.CompletableFuture; - import band.kessoku.lib.events.lifecycle.api.ServerLifecycleEvent; +import net.minecraft.server.MinecraftServer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.server.MinecraftServer; +import java.util.Collection; +import java.util.concurrent.CompletableFuture; @Mixin(MinecraftServer.class) public abstract class MinecraftServerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java index 8f6ef415..c7de6c17 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerEntityHandlerMixin.java @@ -16,6 +16,8 @@ package band.kessoku.lib.events.lifecycle.mixin.neo; import band.kessoku.lib.events.lifecycle.api.ServerEntityEvent; +import net.minecraft.entity.Entity; +import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,9 +25,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.entity.Entity; -import net.minecraft.server.world.ServerWorld; - @Mixin(targets = "net/minecraft/server/world/ServerWorld$ServerEntityHandler") public class ServerEntityHandlerMixin { // final synthetic Lnet/minecraft/server/world/ServerWorld; field_26936 diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java index f304dda5..2689b8ce 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/ServerWorldMixin.java @@ -15,16 +15,15 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo; -import java.util.function.BooleanSupplier; - import band.kessoku.lib.events.lifecycle.api.ServerTickEvent; +import net.minecraft.server.world.ServerWorld; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.server.world.ServerWorld; +import java.util.function.BooleanSupplier; @Mixin(ServerWorld.class) public abstract class ServerWorldMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java index 856ee813..bc38d367 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientChunkManagerMixin.java @@ -15,9 +15,14 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.client; -import java.util.function.Consumer; - import band.kessoku.lib.events.lifecycle.api.client.ClientChunkEvent; +import net.minecraft.client.world.ClientChunkManager; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.s2c.play.ChunkData; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.chunk.WorldChunk; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -27,13 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.client.world.ClientChunkManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.s2c.play.ChunkData; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.WorldChunk; +import java.util.function.Consumer; @Mixin(ClientChunkManager.class) public abstract class ClientChunkManagerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java index eabfb56f..86012919 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientEntityHandlerMixin.java @@ -16,6 +16,8 @@ package band.kessoku.lib.events.lifecycle.mixin.neo.client; import band.kessoku.lib.events.lifecycle.api.client.ClientEntityEvent; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,9 +25,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; - @Mixin(targets = "net/minecraft/client/world/ClientWorld$ClientEntityHandler") public class ClientEntityHandlerMixin { // final synthetic Lnet/minecraft/client/world/ClientWorld; field_27735 diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java index 4f04d185..f3007179 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/ClientPlayNetworkHandlerMixin.java @@ -18,12 +18,6 @@ import band.kessoku.lib.events.lifecycle.api.client.ClientBlockEntityEvent; import band.kessoku.lib.events.lifecycle.api.client.ClientEntityEvent; import band.kessoku.lib.events.lifecycle.impl.LoadedChunksCache; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; @@ -31,6 +25,11 @@ import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) abstract class ClientPlayNetworkHandlerMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java index 7573c631..5a726575 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/MinecraftClientMixin.java @@ -16,13 +16,12 @@ package band.kessoku.lib.events.lifecycle.mixin.neo.client; import band.kessoku.lib.events.lifecycle.api.client.ClientLifecycleEvent; +import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.client.MinecraftClient; - @Mixin(MinecraftClient.class) public abstract class MinecraftClientMixin { @Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop") diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java index 4440caa1..f259450f 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/client/WorldChunkMixin.java @@ -15,11 +15,15 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.client; -import java.util.Map; - import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; import band.kessoku.lib.events.lifecycle.api.client.ClientBlockEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -31,12 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.Map; @Mixin(WorldChunk.class) abstract class WorldChunkMixin { diff --git a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java index 24e41ad4..89e7101e 100644 --- a/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java +++ b/lifecycle-events/neo/src/main/java/band/kessoku/lib/events/lifecycle/mixin/neo/server/WorldChunkMixin.java @@ -15,10 +15,13 @@ */ package band.kessoku.lib.events.lifecycle.mixin.neo.server; -import java.util.Map; - import band.kessoku.lib.events.lifecycle.api.ServerBlockEntityEvent; import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.WorldChunk; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -30,11 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.chunk.WorldChunk; +import java.util.Map; /** * This is a server only mixin for good reason: diff --git a/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json b/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json index f5267d43..8c4c7bb7 100644 --- a/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json +++ b/lifecycle-events/neo/src/main/resources/kessoku-lifecycle-events.neo.mixins.json @@ -12,8 +12,8 @@ ], "client": [ "client.ClientChunkManagerMixin", - "client.ClientPlayNetworkHandlerMixin", "client.ClientEntityHandlerMixin", + "client.ClientPlayNetworkHandlerMixin", "client.MinecraftClientMixin", "client.WorldChunkMixin" ], diff --git a/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java b/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java index abb316be..b7fef091 100644 --- a/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java +++ b/platform/common/src/main/java/band/kessoku/lib/platform/api/ModLoader.java @@ -15,11 +15,11 @@ */ package band.kessoku.lib.platform.api; +import band.kessoku.lib.platform.impl.KessokuPlatformServices; + import java.nio.file.Path; import java.util.Collection; -import band.kessoku.lib.platform.impl.KessokuPlatformServices; - public interface ModLoader { static ModLoader getInstance() { return KessokuPlatformServices.getModLoader(); diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java index 8ab8bbdc..1ba1bcf0 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuPlatformEntrypoint implements ModInitializer { diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java index 181c3bc8..d0bf3a56 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java @@ -15,20 +15,19 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.ModMetadata; import net.fabricmc.loader.api.metadata.Person; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + public class ModDataImpl implements ModData { private final ModContainer modContainer; private final ModMetadata modMetadata; diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index 376b2f07..0d9767a4 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform.impl; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.fabricmc.loader.api.metadata.ModDependency; public class ModDependencyInfoImpl implements ModDependencyInfo { diff --git a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java index 010d74d7..f5e27ff6 100644 --- a/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java +++ b/platform/fabric/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.platform.api.Env; import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModLoader; import com.google.auto.service.AutoService; - import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.ModMetadata; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + @AutoService(ModLoader.class) public class ModLoaderImpl implements ModLoader { private final Map modDataMap = new ConcurrentHashMap<>(); diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java b/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java index e34f78b3..c34ea948 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/KessokuPlatformEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform; import band.kessoku.lib.base.ModUtils; - import net.neoforged.fml.common.Mod; @Mod(KessokuPlatform.MOD_ID) diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java index 957d2157..50f71a4a 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDataImpl.java @@ -15,19 +15,21 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; - import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.neoforged.fml.ModContainer; import net.neoforged.fml.ModList; import net.neoforged.fml.loading.moddiscovery.ModFileInfo; import net.neoforged.neoforgespi.language.IModFileInfo; import net.neoforged.neoforgespi.language.IModInfo; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + public class ModDataImpl implements ModData { private final ModContainer modContainer; private final IModInfo modInfo; diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index 8833c91c..ad676b8d 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -16,7 +16,6 @@ package band.kessoku.lib.platform.impl; import band.kessoku.lib.platform.api.ModDependencyInfo; - import net.neoforged.neoforgespi.language.IModInfo; public class ModDependencyInfoImpl implements ModDependencyInfo { diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java index 32641a74..525796cf 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModLoaderImpl.java @@ -15,21 +15,20 @@ */ package band.kessoku.lib.platform.impl; -import java.nio.file.Path; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.platform.api.Env; import band.kessoku.lib.platform.api.ModData; import band.kessoku.lib.platform.api.ModLoader; import com.google.auto.service.AutoService; - import net.neoforged.fml.ModList; import net.neoforged.fml.loading.FMLLoader; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.neoforgespi.language.IModInfo; +import java.nio.file.Path; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + @AutoService(ModLoader.class) public class ModLoaderImpl implements ModLoader { private final Map modDataMap = new ConcurrentHashMap<>(); diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 654b07f9..d8b3923b 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -15,17 +15,8 @@ */ package band.kessoku.lib.registry.api; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.block.entity.BlockEntity; @@ -38,6 +29,14 @@ import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** * Poor compatibility in Fabric diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java index 542ce3ba..e8cc527d 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java @@ -16,8 +16,6 @@ package band.kessoku.lib.registry.api; import band.kessoku.lib.registry.impl.KessokuRegistryServices; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; @@ -25,6 +23,7 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Identifier; +import org.jetbrains.annotations.ApiStatus; @SuppressWarnings("unused") public interface Registry { diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index dff8702b..dc03364d 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.registry; import band.kessoku.lib.base.ModUtils; - import net.fabricmc.api.ModInitializer; public class KessokuRegistryEntrypoint implements ModInitializer { diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 1b5d9353..a48c47cb 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,7 +17,6 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; - import net.minecraft.util.Identifier; @AutoService(Registry.class) diff --git a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java index ac0d82a3..8a3f0282 100644 --- a/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java +++ b/registry/fabric/src/main/java/band/kessoku/lib/registry/mixin/AbstractFurnaceBlockEntityMixin.java @@ -18,12 +18,6 @@ import band.kessoku.lib.registry.api.FuelRegistry; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import net.minecraft.block.BlockState; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.block.entity.BlockEntityType; @@ -31,6 +25,11 @@ import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.RecipeType; import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(AbstractFurnaceBlockEntity.class) public class AbstractFurnaceBlockEntityMixin { diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index 59c53d29..278a47ae 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -19,10 +19,8 @@ import band.kessoku.lib.event.util.NeoEventUtils; import band.kessoku.lib.registry.api.FuelRegistry; import band.kessoku.lib.registry.impl.RegistryImpl; - import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeType; - import net.neoforged.bus.api.IEventBus; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.NeoForge; diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 06c707a7..70d0e7dd 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -15,16 +15,15 @@ */ package band.kessoku.lib.registry.impl; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.util.Identifier; - import net.neoforged.neoforge.registries.RegisterEvent; +import org.jetbrains.annotations.ApiStatus; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; @AutoService(Registry.class) @SuppressWarnings({"unchecked", "rawtypes"}) From 2439f74fbce900901b076f717aa847f2a0added8 Mon Sep 17 00:00:00 2001 From: Amarok Date: Fri, 20 Sep 2024 14:58:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=BA=E2=81=89=EF=B8=8F=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/base/KessokuBaseEntrypoint.java | 1 + .../lib/config/api/AbstractConfig.java | 5 +++++ .../platform/impl/ModDependencyInfoImpl.java | 22 ++++++------------- .../lib/registry/api/FuelRegistry.java | 10 +++------ .../registry/KessokuRegistryEntrypoint.java | 12 +++++----- .../lib/registry/impl/RegistryImpl.java | 13 ++++++++--- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java index 3077d878..42047348 100644 --- a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java +++ b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java @@ -16,6 +16,7 @@ package band.kessoku.lib.base; import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.event.RegisterCommandsEvent; @Mod(KessokuBase.MOD_ID) public class KessokuBaseEntrypoint { diff --git a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java index 2c3041bf..416d6827 100644 --- a/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java +++ b/config/common/src/main/java/band/kessoku/lib/config/api/AbstractConfig.java @@ -143,6 +143,8 @@ public void reset() { List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); + final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); final boolean flag2 = !Modifier.isStatic(declaredField.getModifiers()); @@ -163,6 +165,7 @@ public ImmutableList getValidCategories() { List fields = new ArrayList<>(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); final boolean flag1 = Modifier.isPublic(declaredField.getModifiers()); @@ -178,6 +181,7 @@ public ImmutableList getValidCategories() { private ImmutableList getValidFields() { ImmutableList.Builder builder = ImmutableList.builder(); for (Field declaredField : this.getClass().getDeclaredFields()) { + declaredField.setAccessible(true); final boolean flag0 = declaredField.getDeclaringClass().isAssignableFrom(AbstractConfig.class); final boolean flag1 = declaredField.getDeclaringClass().isAssignableFrom(ConfigValue.class); @@ -196,6 +200,7 @@ private Map serialize() { ImmutableMap.Builder builder = ImmutableMap.builder(); for (Field field : this.getValidFields()) { field.setAccessible(true); + final String name = field.isAnnotationPresent(Name.class) ? field.getAnnotation(Name.class).value() : field.getName(); final String[] comments = field.isAnnotationPresent(Comments.class) ? (String[]) Arrays.stream(field.getAnnotation(Comments.class).value()).map(Comment::value).toArray() : new String[0]; diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index ad676b8d..ddeef52b 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -25,21 +25,13 @@ public ModDependencyInfoImpl(IModInfo.ModVersion modVersion) { } @Override public DependencyKind getKind() { - switch (value.getType()) { - case OPTIONAL -> { - return DependencyKind.OPTIONAL; - } - case REQUIRED -> { - return DependencyKind.DEPENDS; - } - case DISCOURAGED -> { - return DependencyKind.CONFLICTS; - } - case INCOMPATIBLE -> { - return DependencyKind.BREAKS; - } - } - return null; + return switch (value.getType()) { + case OPTIONAL -> DependencyKind.OPTIONAL; + case REQUIRED -> DependencyKind.DEPENDS; + case DISCOURAGED -> DependencyKind.CONFLICTS; + case INCOMPATIBLE -> DependencyKind.BREAKS; + default -> null; + }; } @Override diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index d8b3923b..339ccf4a 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -178,15 +178,11 @@ public static void setFuelTime(ItemConvertible item, int cookTime) { } /** - * @param block the block which acts like a furnace * @return The fuel time. */ - public static int getFuelTime(T block, ItemStack stack) { - BlockEntity entity = block.createBlockEntity((BlockPos) BlockPos.ZERO, block.getDefaultState()); - if (!(entity instanceof AbstractFurnaceBlockEntity)) return 0; - int fuelTime = ((AbstractFurnaceBlockEntity) entity).getFuelTime(stack); - entity.markRemoved(); - return fuelTime; + public static int getFuelTime(ItemStack stack) { + final var fuelMap = AbstractFurnaceBlockEntity.createFuelTimeMap(); + return fuelMap.getOrDefault(stack.getItem(), 0); } public record ItemWithData(ComponentMap componentMap, ItemConvertible item) { diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java index 278a47ae..af56993b 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/KessokuRegistryEntrypoint.java @@ -27,18 +27,18 @@ import net.neoforged.neoforge.event.furnace.FurnaceFuelBurnTimeEvent; import net.neoforged.neoforge.registries.RegisterEvent; +import java.util.Objects; +import java.util.Optional; + @Mod(KessokuRegistry.MOD_ID) public class KessokuRegistryEntrypoint { public KessokuRegistryEntrypoint(IEventBus modEventBus) { ModUtils.getLogger().info(KessokuRegistry.MARKER, "KessokuLib-Registry is loaded!"); NeoEventUtils.registerEvent(modEventBus, RegisterEvent.class, RegistryImpl::onRegister); NeoEventUtils.registerEvent(NeoForge.EVENT_BUS, FurnaceFuelBurnTimeEvent.class, event -> { - ItemStack stack = event.getItemStack(); - RecipeType recipeType = event.getRecipeType(); - Integer burnTime; - if (recipeType != null) burnTime = FuelRegistry.of(recipeType).get(stack); - else burnTime = FuelRegistry.of(RecipeType.SMELTING).get(stack); - if (burnTime != null) event.setBurnTime(burnTime); + final ItemStack stack = event.getItemStack(); + final RecipeType recipeType = Objects.requireNonNullElse(event.getRecipeType(), RecipeType.SMELTING); + Optional.ofNullable(FuelRegistry.of(recipeType).get(stack)).ifPresent(event::setBurnTime); }); } } diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index 70d0e7dd..c7c859d3 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,12 +17,16 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Maps; +import com.google.common.collect.Table; import net.minecraft.util.Identifier; import net.neoforged.neoforge.registries.RegisterEvent; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @AutoService(Registry.class) @@ -39,12 +43,15 @@ public static void onRegister(RegisterEvent event) { @Override public T registerInternal(net.minecraft.registry.Registry registry, Identifier id, T entry) { - if (registered) + if (registered) { throw new IllegalStateException("Cannot register new entries after net.neoforged.neoforge.registries.RegisterEvent has been fired."); - if (!registries.containsKey(registry)) registries.put(registry, new HashMap<>()); - if (registries.get(registry).putIfAbsent(id, entry) != null) { + } + + final var map = Objects.requireNonNull(registries.putIfAbsent(registry, Maps.newHashMap())); + if (map.putIfAbsent(id, entry) != null) { throw new IllegalArgumentException("Duplicate registration " + id.toString()); } + return entry; } } From ed5c8d6f5297c2c402cb549c13d7e6122f537fbc Mon Sep 17 00:00:00 2001 From: Amarok Date: Fri, 20 Sep 2024 15:24:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=BA=F0=9F=92=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../band/kessoku/lib/base/KessokuBaseEntrypoint.java | 1 - .../kessoku/lib/keybind/impl/KeyBindRegisterImpl.java | 9 +++++---- .../kessoku/lib/platform/impl/ModDependencyInfoImpl.java | 1 - .../java/band/kessoku/lib/registry/api/FuelRegistry.java | 3 --- .../band/kessoku/lib/registry/impl/RegistryImpl.java | 3 --- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java index 42047348..3077d878 100644 --- a/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java +++ b/base/neo/src/main/java/band/kessoku/lib/base/KessokuBaseEntrypoint.java @@ -16,7 +16,6 @@ package band.kessoku.lib.base; import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.event.RegisterCommandsEvent; @Mod(KessokuBase.MOD_ID) public class KessokuBaseEntrypoint { diff --git a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java index 09c9e343..6e34c8ce 100644 --- a/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java +++ b/keybind/neo/src/main/java/band/kessoku/lib/keybind/impl/KeyBindRegisterImpl.java @@ -27,13 +27,15 @@ import java.util.List; import java.util.Map; -import java.util.Optional; @AutoService(KeyBindRegister.class) public class KeyBindRegisterImpl implements KeyBindRegister { private static final List KEY_BINDINGS = new ReferenceArrayList<>(); private static boolean processed; + /* Amarok Note: + Maybe Object2IntMap ...? + */ private static Map getCategoryMap() { return KeyBindingAccessor.kessoku$getCategoryMap(); } @@ -46,9 +48,8 @@ public boolean addCategory(String categoryTranslationKey) { return false; } - Optional largest = map.values().stream().max(Integer::compareTo); - int largestInt = largest.orElse(0); - map.put(categoryTranslationKey, largestInt + 1); + final int largest = map.values().stream().max(Integer::compareTo).orElse(0); + map.put(categoryTranslationKey, largest + 1); return true; } diff --git a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java index ddeef52b..2b202b06 100644 --- a/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java +++ b/platform/neo/src/main/java/band/kessoku/lib/platform/impl/ModDependencyInfoImpl.java @@ -30,7 +30,6 @@ public DependencyKind getKind() { case REQUIRED -> DependencyKind.DEPENDS; case DISCOURAGED -> DependencyKind.CONFLICTS; case INCOMPATIBLE -> DependencyKind.BREAKS; - default -> null; }; } diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java index 339ccf4a..4c829c32 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/FuelRegistry.java @@ -17,9 +17,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import net.minecraft.block.AbstractFurnaceBlock; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.block.entity.BlockEntity; import net.minecraft.component.ComponentMap; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; @@ -28,7 +26,6 @@ import net.minecraft.recipe.RecipeType; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java index c7c859d3..2a352302 100644 --- a/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java +++ b/registry/neo/src/main/java/band/kessoku/lib/registry/impl/RegistryImpl.java @@ -17,14 +17,11 @@ import band.kessoku.lib.registry.api.Registry; import com.google.auto.service.AutoService; -import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; -import com.google.common.collect.Table; import net.minecraft.util.Identifier; import net.neoforged.neoforge.registries.RegisterEvent; import org.jetbrains.annotations.ApiStatus; -import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap;