diff options
18 files changed, 158 insertions, 523 deletions
diff --git a/build.gradle b/build.gradle index bfb17ed..a7d337f 100644 --- a/build.gradle +++ b/build.gradle @@ -11,11 +11,9 @@ version = project.mod_version + "-mc" + project.minecraft_version group = project.maven_group repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. + maven { + url 'https://masa.dy.fi/maven' + } } dependencies { @@ -27,6 +25,9 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + // Carpet + modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}" + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. } diff --git a/gradle.properties b/gradle.properties index 3ad27cc..821d65b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,9 +6,10 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.16.5 yarn_mappings=1.16.5+build.9 loader_version=0.11.3 +carpet_core_version=1.4.44+v210714 # Mod Properties -mod_version=1.7.0-pre1 +mod_version=2.0.0-pre1 maven_group=com.keuin.omvm archives_base_name=oh-my-vanilla-mc diff --git a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java index 2cdad10..39b16d8 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java +++ b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java @@ -1,181 +1,22 @@ package com.keuin.ohmyvanillamc; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonIOException; -import com.keuin.ohmyvanillamc.config.ImmutableOmvmConfiguration; -import com.keuin.ohmyvanillamc.config.OmvmConfiguration; -import com.mojang.brigadier.Command; -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.suggestion.SuggestionProvider; -import com.mojang.brigadier.suggestion.Suggestions; -import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.util.Formatting; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.logging.Logger; -import java.util.stream.Stream; - -import static com.keuin.ohmyvanillamc.ReflectionUtils.getFieldName; -import static com.keuin.ohmyvanillamc.ReflectionUtils.setPrivateField; +import net.fabricmc.loader.api.FabricLoader; public class OhMyVanillaMinecraft implements ModInitializer { - private static final Logger LOGGER = Logger.getLogger("OhMyVanillaMinecraft"); + private static final String MOD_ID = "ohmyvanillamc"; - private static final OmvmConfiguration defaultConfiguration = - new ImmutableOmvmConfiguration(); - private static OmvmConfiguration configuration = null; + private static String version; - public static OmvmConfiguration getConfiguration() { - return configuration; + public static String getVersion() { + return version; } @Override public void onInitialize() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - - LOGGER.info("Loading configuration..."); - - // load configuration - - final String fileName = "omvm.json"; - final File file = new File(fileName); - if (!file.exists()) { - LOGGER.info("Configuration file does not exist! Use default configuration."); - try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { - final String jsonString = (new GsonBuilder().setPrettyPrinting().create()).toJson(defaultConfiguration); - try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream)) { - outputStreamWriter.write(jsonString); - } - } catch (FileNotFoundException e) { - LOGGER.severe("Cannot write default configuration to file `" + fileName + "`: " + e); - } catch (IOException e) { - LOGGER.severe("Failed to write default configuration to file `" + fileName + "`: " + e); - } - } else { - try (FileInputStream fileInputStream = new FileInputStream(file)) { - try (InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8)) { - try (BufferedReader reader = new BufferedReader(inputStreamReader)) { - configuration = (new Gson()).fromJson(reader, OmvmConfiguration.class); - } - } - } catch (IOException e) { - LOGGER.severe("Failed to read config file `" + fileName + "`: " + e); - } catch (JsonIOException e) { - LOGGER.severe("Failed to decode config json file `" + fileName + "`: " + e); - } - } - - if (configuration == null) { - configuration = new OmvmConfiguration(defaultConfiguration); - } - - LOGGER.info(getConfigurationString()); - - CommandRegistrationCallback.EVENT.register(new CommandRegistrationCallback() { - @Override - public void register(CommandDispatcher<ServerCommandSource> commandDispatcher, boolean b) { - commandDispatcher.register(CommandManager.literal("omvm").executes(new Command<ServerCommandSource>() { - @Override - public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { - String text = getConfigurationString(); - context.getSource().sendFeedback(new LiteralText(text), false); - return 1; // 1: success, -1: fail - } - })); - } - }); - - - String[] keys = getFieldName(configuration); - final Set<String> keySet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(keys))); - - CommandRegistrationCallback.EVENT.register(new CommandRegistrationCallback() { - @Override - public void register(CommandDispatcher<ServerCommandSource> commandDispatcher, boolean b) { - commandDispatcher.register(CommandManager.literal("omvm") - .then(CommandManager.literal("set") - .then(CommandManager.argument("key", StringArgumentType.word()) - .suggests(new SuggestionProvider<ServerCommandSource>() { - @Override - public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException { - String remaining = builder.getRemaining().toLowerCase(Locale.ROOT); - keySet.stream().filter(key -> key.toLowerCase().startsWith(remaining)).forEach(builder::suggest); - return builder.buildFuture(); - } - }) - .then(CommandManager.argument("value", StringArgumentType.word()).suggests(new SuggestionProvider<ServerCommandSource>() { - @Override - public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException { - String remaining = builder.getRemaining().toLowerCase(Locale.ROOT); - Stream.of("true", "false").filter(key -> key.toLowerCase().startsWith(remaining)).forEach(builder::suggest); - return builder.buildFuture(); - } - }) - .executes(new Command<ServerCommandSource>() { - @Override - public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { - try { - boolean previousFixSpamming = configuration.isFixEntityTrackerEntrySpamming(); - - String key = context.getArgument("key", String.class); - String value = context.getArgument("value", String.class); - - if (!keySet.contains(key)) { - StringBuilder sb = new StringBuilder(); - sb.append("Invalid key. Available keys:"); - keySet.forEach(k -> sb.append("\n- ").append(k)); - context.getSource().sendFeedback(new LiteralText(sb.toString()) - .setStyle(Style.EMPTY.withColor(Formatting.RED)), false); - return -1; - } - - if (!Arrays.asList("true", "false").contains(value)) { - context.getSource().sendFeedback(new LiteralText("Value must be `true` or `false`.") - .setStyle(Style.EMPTY.withColor(Formatting.RED)), false); - return -1; - } - - setPrivateField(configuration, key, Boolean.valueOf(value)); - context.getSource().sendFeedback( - new LiteralText("`" + key + "` has been temporarily set to `" + value + "`."), true - ); - - return 1; // 1: success, -1: fail - } catch (NoSuchFieldException | IllegalAccessException e) { - context.getSource().sendFeedback(new LiteralText("There is a bug. Tell trueKeuin.") - .setStyle(Style.EMPTY.withColor(Formatting.RED)), false); - return -1; - } - } - }) - ) - ))); - } - }); - + version = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString(); + OmvmExtension.initialize(); } - - private String getConfigurationString() { - return "OhMyVanillaMinecraft\n==========\n" + configuration + "\n==========\n" - + "Force enabled tweaks:\n" + "Furnace fuel list lag fix\n" + "=========="; - } - - } diff --git a/src/main/java/com/keuin/ohmyvanillamc/OmvmExtension.java b/src/main/java/com/keuin/ohmyvanillamc/OmvmExtension.java new file mode 100644 index 0000000..e820fd6 --- /dev/null +++ b/src/main/java/com/keuin/ohmyvanillamc/OmvmExtension.java @@ -0,0 +1,26 @@ +package com.keuin.ohmyvanillamc; + +import carpet.CarpetExtension; +import carpet.CarpetServer; + +public class OmvmExtension implements CarpetExtension { + private static final OmvmExtension INSTANCE = new OmvmExtension(); + + public static OmvmExtension getInstance() { + return INSTANCE; + } + + public static void initialize() { + CarpetServer.manageExtension(INSTANCE); + } + + @Override + public void onGameStarted() { + CarpetServer.settingsManager.parseSettingsClass(OmvmSettings.class); + } + + @Override + public String version() { + return OhMyVanillaMinecraft.getVersion(); + } +} diff --git a/src/main/java/com/keuin/ohmyvanillamc/OmvmSettings.java b/src/main/java/com/keuin/ohmyvanillamc/OmvmSettings.java new file mode 100644 index 0000000..206fc22 --- /dev/null +++ b/src/main/java/com/keuin/ohmyvanillamc/OmvmSettings.java @@ -0,0 +1,51 @@ +package com.keuin.ohmyvanillamc; + +import carpet.settings.Rule; + +import static carpet.settings.RuleCategory.*; + +public class OmvmSettings { + public static final String OMVM = "OMVM"; + + @Rule( + desc = "Remove AI of laggy schooling fish (tropical fish, cod)", + category = {OMVM, FEATURE, OPTIMIZATION} + ) + public static boolean disableFishSchooling = false; + + @Rule( + desc = "Reintroduce item duping with llama on a boat", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean reintroduceLlamaItemDuplicating = false; + + @Rule( + desc = "Reintroduce Force Ripening for kelp, twisted vine and weeping vine, See MC-113809", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean enableStemForceRipening = false; + + @Rule( + desc = "Reintroduce Force Ripening for bamboo, See MC-113809", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean enableBambooForceRipening = false; + + @Rule( + desc = "Reintroduce Force Ripening for cactus, See MC-113809", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean enableCactusForceRipening = false; + + @Rule( + desc = "Reintroduce Force Ripening for chorus flower, See MC-113809", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean enableChorusFlowerForceRipening = false; + + @Rule( + desc = "Reintroduce Force Ripening for sugar cane, See MC-113809", + category = {OMVM, FEATURE, EXPERIMENTAL} + ) + public static boolean enableSugarCaneForceRipening = false; +} diff --git a/src/main/java/com/keuin/ohmyvanillamc/ReflectionUtils.java b/src/main/java/com/keuin/ohmyvanillamc/ReflectionUtils.java deleted file mode 100644 index a87632e..0000000 --- a/src/main/java/com/keuin/ohmyvanillamc/ReflectionUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.keuin.ohmyvanillamc; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; - -/** - * @Author 落叶飞翔的蜗牛 Keuin - * @Date 2018/3/10 - * @Description 常用反射函数 - */ -public final class ReflectionUtils { - - /** - * 获取私有成员变量的值 - */ - public static Object getPrivateField(Object instance, String filedName) throws NoSuchFieldException, IllegalAccessException { - Field field = instance.getClass().getDeclaredField(filedName); - field.setAccessible(true); - return field.get(instance); - } - - /** - * 设置私有成员的值 - */ - public static void setPrivateField(Object instance, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException { - Field field = instance.getClass().getDeclaredField(fieldName); - field.setAccessible(true); - field.set(instance, value); - } - - /** - * 访问私有方法 - */ - public static Object invokePrivateMethod(Object instance, String methodName, Class[] classes, Object... args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method method = instance.getClass().getDeclaredMethod(methodName, classes); - method.setAccessible(true); - return method.invoke(instance, args); - } - - /** - * 获取所有成员变量的名字 - * - * @param o 要获取成员变量的对象实例 - * @return 所有成员变量名字数组 - */ - public static String[] getFieldName(Object o) { - return Arrays.stream(o.getClass().getDeclaredFields()).map(Field::getName).toArray(String[]::new); - } -}
\ No newline at end of file diff --git a/src/main/java/com/keuin/ohmyvanillamc/config/ImmutableOmvmConfiguration.java b/src/main/java/com/keuin/ohmyvanillamc/config/ImmutableOmvmConfiguration.java deleted file mode 100644 index 4ed9d65..0000000 --- a/src/main/java/com/keuin/ohmyvanillamc/config/ImmutableOmvmConfiguration.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.keuin.ohmyvanillamc.config; - -public class ImmutableOmvmConfiguration extends OmvmConfiguration { - - public ImmutableOmvmConfiguration() { - super(); - } - - public ImmutableOmvmConfiguration(OmvmConfiguration omvmConfiguration) { - super(omvmConfiguration); - } - - public ImmutableOmvmConfiguration(boolean fixEntityTrackerEntrySpamming, boolean disableFishSchooling, - boolean disablePhantomSpawning, boolean disableWanderingTraderSpawning, - boolean reintroduceLlamaItemDuplicating, boolean reintroduceZeroTickFarm, - boolean enableStemForceRipening, boolean enableBambooForceRipening, - boolean enableCactusForceRipening, boolean enableChorusFlowerForceRipening, - boolean enableSugarCaneForceRipening) { - super(fixEntityTrackerEntrySpamming, disableFishSchooling, disablePhantomSpawning, - disableWanderingTraderSpawning, reintroduceLlamaItemDuplicating, reintroduceZeroTickFarm, - enableStemForceRipening, enableBambooForceRipening, enableCactusForceRipening, - enableChorusFlowerForceRipening, enableSugarCaneForceRipening); - } - - @Override - public void setFixEntityTrackerEntrySpamming(boolean fixEntityTrackerEntrySpamming) { - throw new UnsupportedOperationException(); - } - - @Override - public void setDisableFishSchooling(boolean disableFishSchooling) { - throw new UnsupportedOperationException(); - } - - @Override - public void setDisablePhantomSpawning(boolean disablePhantomSpawning) { - throw new UnsupportedOperationException(); - } - - @Override - public void setDisableWanderingTraderSpawning(boolean disableWanderingTraderSpawning) { - throw new UnsupportedOperationException(); - } - - @Override - public void setReintroduceLlamaItemDuplicating(boolean reintroduceLlamaItemDuplicating) { - throw new UnsupportedOperationException(); - } - - @Override - public void setReintroduceZeroTickFarm(boolean reintroduceZeroTickFarm) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/com/keuin/ohmyvanillamc/config/OmvmConfiguration.java b/src/main/java/com/keuin/ohmyvanillamc/config/OmvmConfiguration.java deleted file mode 100644 index 8f95b15..0000000 --- a/src/main/java/com/keuin/ohmyvanillamc/config/OmvmConfiguration.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.keuin.ohmyvanillamc.config; - -import java.util.Objects; - -public class OmvmConfiguration { - - private boolean fixEntityTrackerEntrySpamming; - private boolean disableFishSchooling; - private boolean disablePhantomSpawning; - private boolean disableWanderingTraderSpawning; - private boolean reintroduceLlamaItemDuplicating; - private boolean reintroduceZeroTickFarm; - private boolean enableStemForceRipening; - private boolean enableBambooForceRipening; - private boolean enableCactusForceRipening; - private boolean enableChorusFlowerForceRipening; - private boolean enableSugarCaneForceRipening; - - public OmvmConfiguration() { - this(true, false, false, false, false, false, true, true, true, true, true); - } - - public OmvmConfiguration(OmvmConfiguration omvmConfiguration) { - this.fixEntityTrackerEntrySpamming = omvmConfiguration.fixEntityTrackerEntrySpamming; - this.disableFishSchooling = omvmConfiguration.disableFishSchooling; - this.disablePhantomSpawning = omvmConfiguration.disablePhantomSpawning; - this.disableWanderingTraderSpawning = omvmConfiguration.disableWanderingTraderSpawning; - this.reintroduceLlamaItemDuplicating = omvmConfiguration.reintroduceLlamaItemDuplicating; - this.reintroduceZeroTickFarm = omvmConfiguration.reintroduceZeroTickFarm; - this.enableStemForceRipening = omvmConfiguration.enableStemForceRipening; - this.enableBambooForceRipening = omvmConfiguration.enableBambooForceRipening; - this.enableCactusForceRipening = omvmConfiguration.enableCactusForceRipening; - this.enableChorusFlowerForceRipening = omvmConfiguration.enableChorusFlowerForceRipening; - this.enableSugarCaneForceRipening = omvmConfiguration.enableSugarCaneForceRipening; - } - - public OmvmConfiguration(boolean fixEntityTrackerEntrySpamming, boolean disableFishSchooling - , boolean disablePhantomSpawning, boolean disableWanderingTraderSpawning - , boolean reintroduceLlamaItemDuplicating, boolean reintroduceZeroTickFarm - , boolean enableStemForceRipening, boolean enableBambooForceRipening - , boolean enableCactusForceRipening, boolean enableChorusFlowerForceRipening - , boolean enableSugarCaneForceRipening) { - this.fixEntityTrackerEntrySpamming = fixEntityTrackerEntrySpamming; - this.disableFishSchooling = disableFishSchooling; - this.disablePhantomSpawning = disablePhantomSpawning; - this.disableWanderingTraderSpawning = disableWanderingTraderSpawning; - this.reintroduceLlamaItemDuplicating = reintroduceLlamaItemDuplicating; - this.reintroduceZeroTickFarm = reintroduceZeroTickFarm; - this.enableStemForceRipening = enableStemForceRipening; - this.enableBambooForceRipening = enableBambooForceRipening; - this.enableCactusForceRipening = enableCactusForceRipening; - this.enableChorusFlowerForceRipening = enableChorusFlowerForceRipening; - this.enableSugarCaneForceRipening = enableSugarCaneForceRipening; - } - - public boolean isFixEntityTrackerEntrySpamming() { - return fixEntityTrackerEntrySpamming; - } - - public boolean isDisableFishSchooling() { - return disableFishSchooling; - } - - public boolean isDisablePhantomSpawning() { - return disablePhantomSpawning; - } - - public boolean isDisableWanderingTraderSpawning() { - return disableWanderingTraderSpawning; - } - - public boolean isReintroduceLlamaItemDuplicating() { - return reintroduceLlamaItemDuplicating; - } - - public boolean isReintroduceZeroTickFarm() { - return reintroduceZeroTickFarm; - } - - public boolean isEnableStemForceRipening() { - return enableStemForceRipening; - } - - public void setEnableStemForceRipening(boolean enableStemForceRipening) { - this.enableStemForceRipening = enableStemForceRipening; - } - - public boolean isEnableBambooForceRipening() { - return enableBambooForceRipening; - } - - public void setEnableBambooForceRipening(boolean enableBambooForceRipening) { - this.enableBambooForceRipening = enableBambooForceRipening; - } - - public boolean isEnableCactusForceRipening() { - return enableCactusForceRipening; - } - - public void setEnableCactusForceRipening(boolean enableCactusForceRipening) { - this.enableCactusForceRipening = enableCactusForceRipening; - } - - public boolean isEnableChorusFlowerForceRipening() { - return enableChorusFlowerForceRipening; - } - - public void setEnableChorusFlowerForceRipening(boolean enableChorusFlowerForceRipening) { - this.enableChorusFlowerForceRipening = enableChorusFlowerForceRipening; - } - - public boolean isEnableSugarCaneForceRipening() { - return enableSugarCaneForceRipening; - } - - public void setEnableSugarCaneForceRipening(boolean enableSugarCaneForceRipening) { - this.enableSugarCaneForceRipening = enableSugarCaneForceRipening; - } - - public void setFixEntityTrackerEntrySpamming(boolean fixEntityTrackerEntrySpamming) { - this.fixEntityTrackerEntrySpamming = fixEntityTrackerEntrySpamming; - } - - public void setDisableFishSchooling(boolean disableFishSchooling) { - this.disableFishSchooling = disableFishSchooling; - } - - public void setDisablePhantomSpawning(boolean disablePhantomSpawning) { - this.disablePhantomSpawning = disablePhantomSpawning; - } - - public void setDisableWanderingTraderSpawning(boolean disableWanderingTraderSpawning) { - this.disableWanderingTraderSpawning = disableWanderingTraderSpawning; - } - - public void setReintroduceLlamaItemDuplicating(boolean reintroduceLlamaItemDuplicating) { - this.reintroduceLlamaItemDuplicating = reintroduceLlamaItemDuplicating; - } - - public void setReintroduceZeroTickFarm(boolean reintroduceZeroTickFarm) { - this.reintroduceZeroTickFarm = reintroduceZeroTickFarm; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - OmvmConfiguration that = (OmvmConfiguration) o; - return fixEntityTrackerEntrySpamming == that.fixEntityTrackerEntrySpamming && - disableFishSchooling == that.disableFishSchooling && - disablePhantomSpawning == that.disablePhantomSpawning && - disableWanderingTraderSpawning == that.disableWanderingTraderSpawning && - reintroduceLlamaItemDuplicating == that.reintroduceLlamaItemDuplicating && - reintroduceZeroTickFarm == that.reintroduceZeroTickFarm && - enableStemForceRipening == that.enableStemForceRipening && - enableBambooForceRipening == that.enableBambooForceRipening && - enableCactusForceRipening == that.enableCactusForceRipening && - enableChorusFlowerForceRipening == that.enableChorusFlowerForceRipening && - enableSugarCaneForceRipening == that.enableSugarCaneForceRipening; - } - - @Override - public int hashCode() { - return Objects.hash(fixEntityTrackerEntrySpamming, disableFishSchooling, disablePhantomSpawning, disableWanderingTraderSpawning, reintroduceLlamaItemDuplicating, reintroduceZeroTickFarm, enableStemForceRipening, enableBambooForceRipening, enableCactusForceRipening, enableChorusFlowerForceRipening, enableSugarCaneForceRipening); - } - - @Override - public String toString() { - String s = ""; - s += "(BugFix) Fix Entity Tracker Entry Spamming: " + fixEntityTrackerEntrySpamming + "\n"; - s += "(Optimization) Disable Fish Schooling: " + disableFishSchooling + "\n"; - s += "(Exotic Feature) Disable Phantom Spawning: " + disablePhantomSpawning + "\n"; - s += "(Exotic Feature) Disable Wandering Trader Spawning: " + disableWanderingTraderSpawning + "\n"; - s += "(Obsolete Vanilla Feature) Reintroduce Llama Item Duplicating: " + reintroduceLlamaItemDuplicating + "\n"; - s += "(Obsolete Vanilla Feature) Reintroduce 0-tick Plants Farm: " + reintroduceZeroTickFarm + "\n"; - s += "(Zero Tick Farm) Enable Stem Force Ripening: " + enableStemForceRipening + "\n"; - s += "(Zero Tick Farm) Enable Bamboo Force Ripening: " + enableBambooForceRipening + "\n"; - s += "(Zero Tick Farm) Enable Cactus Force Ripening: " + enableCactusForceRipening + "\n"; - s += "(Zero Tick Farm) Enable Chorus Flower Force Ripening: " + enableCactusForceRipening + "\n"; - s += "(Zero Tick Farm) Enable Sugar Cane Force Ripening: " + enableSugarCaneForceRipening + "\n"; - return s; - } -} diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableEntityTrackerEntrySpamming.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/fix/disableEntityTrackerEntrySpamming/EntityTrackerEntryMixin.java index faf5c9d..5b885a0 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableEntityTrackerEntrySpamming.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/fix/disableEntityTrackerEntrySpamming/EntityTrackerEntryMixin.java @@ -1,4 +1,4 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.fix.disableEntityTrackerEntrySpamming; import com.keuin.ohmyvanillamc.DummyLogger; import net.minecraft.server.network.EntityTrackerEntry; @@ -9,12 +9,10 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(EntityTrackerEntry.class) -public class DisableEntityTrackerEntrySpamming { - - private static final Logger LOGGER_DUMMY = new DummyLogger(); +public class EntityTrackerEntryMixin { static { - setLOGGER(LOGGER_DUMMY); + setLOGGER(new DummyLogger()); } @Shadow diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java index c2de0d5..9e82f09 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.disableFishSchooling; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.entity.EntityType; import net.minecraft.entity.ai.goal.FollowGroupLeaderGoal; import net.minecraft.entity.passive.FishEntity; @@ -11,14 +11,17 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @Mixin(SchoolingFishEntity.class) -public abstract class DisableFishSchooling extends FishEntity { +public abstract class SchoolingFishEntityMixin extends FishEntity { - public DisableFishSchooling(EntityType<? extends FishEntity> type, World world) { + public SchoolingFishEntityMixin(EntityType<? extends FishEntity> type, World world) { super(type, world); } - @Shadow public abstract boolean hasLeader(); - @Shadow private SchoolingFishEntity leader; + @Shadow + public abstract boolean hasLeader(); + + @Shadow + private SchoolingFishEntity leader; /** * @reason To disable SchoolingFish schooling. @@ -26,7 +29,7 @@ public abstract class DisableFishSchooling extends FishEntity { */ @Overwrite public void moveTowardLeader() { - if (!OhMyVanillaMinecraft.getConfiguration().isDisableFishSchooling()) { + if (!OmvmSettings.disableFishSchooling) { if (this.hasLeader()) { this.getNavigation().startMovingTo(this.leader, 1.0D); } @@ -40,7 +43,7 @@ public abstract class DisableFishSchooling extends FishEntity { @Overwrite public void initGoals() { super.initGoals(); - if (!OhMyVanillaMinecraft.getConfiguration().isDisableFishSchooling()) { + if (!OmvmSettings.disableFishSchooling) { this.goalSelector.add(5, new FollowGroupLeaderGoal((SchoolingFishEntity) (Object) this)); } } diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809AbstractPlantStemBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/AbstractPlantStemBlockMixin.java index 47e2167..1092816 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809AbstractPlantStemBlockMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/AbstractPlantStemBlockMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.forceRipening; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.block.AbstractPlantPartBlock; import net.minecraft.block.AbstractPlantStemBlock; import net.minecraft.block.BlockState; @@ -17,9 +17,9 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(AbstractPlantStemBlock.class) -public abstract class Mc113809AbstractPlantStemBlockMixin extends AbstractPlantPartBlock { +public abstract class AbstractPlantStemBlockMixin extends AbstractPlantPartBlock { - protected Mc113809AbstractPlantStemBlockMixin(Settings settings, Direction growthDirection, VoxelShape outlineShape, boolean tickWater) { + protected AbstractPlantStemBlockMixin(Settings settings, Direction growthDirection, VoxelShape outlineShape, boolean tickWater) { super(settings, growthDirection, outlineShape, tickWater); } @@ -47,13 +47,13 @@ public abstract class Mc113809AbstractPlantStemBlockMixin extends AbstractPlantP * Reintroduce the MC-113809 glitch for kelp, twisted vine and weeping vine. The implementation is identical to Minecraft 1.15.2. * * @author trueKeuin - * @reason reintroduce MC-113809 for bamboo. + * @reason reintroduce MC-113809 for kelp, twisted vine and weeping vine. */ @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.canPlaceAt(world, pos)) { world.breakBlock(pos, true); - } else if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableStemForceRipening()) { + } else if (OmvmSettings.enableStemForceRipening) { realGrow(state, world, pos, random); } } @@ -67,7 +67,7 @@ public abstract class Mc113809AbstractPlantStemBlockMixin extends AbstractPlantP */ @Overwrite public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableStemForceRipening()) { + if (OmvmSettings.enableStemForceRipening) { scheduledTick(state, world, pos, random); } else { realGrow(state, world, pos, random); diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/BambooBlockMixin.java index 7e25bf1..0dd9be6 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/BambooBlockMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.forceRipening; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.block.BambooBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -17,9 +17,9 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(BambooBlock.class) -public abstract class Mc113809BambooBlockMixin extends Block { +public abstract class BambooBlockMixin extends Block { - public Mc113809BambooBlockMixin(Settings settings) { + public BambooBlockMixin(Settings settings) { super(settings); } @@ -41,7 +41,7 @@ public abstract class Mc113809BambooBlockMixin extends Block { */ @Overwrite public boolean hasRandomTicks(BlockState state) { - boolean zf = OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening(); + boolean zf = OmvmSettings.enableBambooForceRipening; return ((state.get(STAGE) == 0) && !zf) || (randomTicks && zf); } @@ -54,7 +54,7 @@ public abstract class Mc113809BambooBlockMixin extends Block { */ @Overwrite public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening()) { + if (OmvmSettings.enableBambooForceRipening) { scheduledTick(state, world, pos, random); } else { realGrow(state, world, pos, random); @@ -71,7 +71,7 @@ public abstract class Mc113809BambooBlockMixin extends Block { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.canPlaceAt(world, pos)) { world.breakBlock(pos, true); - } else if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening()) { + } else if (OmvmSettings.enableBambooForceRipening) { realGrow(state, world, pos, random); } } diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809CactusBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/CactusBlockMixin.java index f2381c2..d5feaf9 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809CactusBlockMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/CactusBlockMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.forceRipening; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.CactusBlock; @@ -15,9 +15,9 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(CactusBlock.class) -public abstract class Mc113809CactusBlockMixin extends Block { +public abstract class CactusBlockMixin extends Block { - public Mc113809CactusBlockMixin(Settings settings) { + public CactusBlockMixin(Settings settings) { super(settings); } @@ -34,7 +34,7 @@ public abstract class Mc113809CactusBlockMixin extends Block { */ @Overwrite public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableCactusForceRipening()) { + if (OmvmSettings.enableCactusForceRipening) { scheduledTick(state, world, pos, random); } else { // here goes 1.16.4 version randomTick impl. @@ -52,7 +52,7 @@ public abstract class Mc113809CactusBlockMixin extends Block { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.canPlaceAt(world, pos)) { world.breakBlock(pos, true); - } else if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableCactusForceRipening()) { + } else if (OmvmSettings.enableCactusForceRipening) { realGrow(state, world, pos); } } diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809ChorusFlowerBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/ChorusFlowerBlockMixin.java index 9f929ba..fb79848 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809ChorusFlowerBlockMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/ChorusFlowerBlockMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.forceRipening; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.block.*; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.IntProperty; @@ -17,9 +17,9 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(ChorusFlowerBlock.class) -public abstract class Mc113809ChorusFlowerBlockMixin extends Block { +public abstract class ChorusFlowerBlockMixin extends Block { - public Mc113809ChorusFlowerBlockMixin(Settings settings) { + public ChorusFlowerBlockMixin(Settings settings) { super(settings); } @@ -56,7 +56,7 @@ public abstract class Mc113809ChorusFlowerBlockMixin extends Block { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.canPlaceAt(world, pos)) { world.breakBlock(pos, true); - } else if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableChorusFlowerForceRipening()) { + } else if (OmvmSettings.enableChorusFlowerForceRipening) { realGrow(state, world, pos, random); } @@ -70,7 +70,7 @@ public abstract class Mc113809ChorusFlowerBlockMixin extends Block { */ @Overwrite public boolean hasRandomTicks(BlockState state) { - boolean zf = OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableChorusFlowerForceRipening(); + boolean zf = OmvmSettings.enableChorusFlowerForceRipening; return ((state.get(AGE) < 5) && !zf) || (randomTicks && zf); } @@ -83,7 +83,7 @@ public abstract class Mc113809ChorusFlowerBlockMixin extends Block { */ @Overwrite public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableChorusFlowerForceRipening()) { + if (OmvmSettings.enableChorusFlowerForceRipening) { scheduledTick(state, world, pos, random); } else { realGrow(state, world, pos, random); diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809SugarCaneBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/SugarCaneBlockMixin.java index 62b08b6..6cce2a3 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809SugarCaneBlockMixin.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/SugarCaneBlockMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.forceRipening; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SugarCaneBlock; @@ -15,9 +15,9 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Random; @Mixin(SugarCaneBlock.class) -public abstract class Mc113809SugarCaneBlockMixin extends Block { +public abstract class SugarCaneBlockMixin extends Block { - public Mc113809SugarCaneBlockMixin(Settings settings) { + public SugarCaneBlockMixin(Settings settings) { super(settings); } @@ -34,7 +34,7 @@ public abstract class Mc113809SugarCaneBlockMixin extends Block { */ @Overwrite public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { - if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableSugarCaneForceRipening()) { + if (OmvmSettings.enableSugarCaneForceRipening) { scheduledTick(state, world, pos, random); } else if (world.isAir(pos.up())) { // here goes 1.16.4 version randomTick impl. realGrow(state, world, pos); @@ -52,7 +52,7 @@ public abstract class Mc113809SugarCaneBlockMixin extends Block { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (!state.canPlaceAt(world, pos)) { world.breakBlock(pos, true); - } else if (world.isAir(pos.up()) && OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableSugarCaneForceRipening()) { + } else if (world.isAir(pos.up()) && OmvmSettings.enableSugarCaneForceRipening) { realGrow(state, world, pos); } } diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/ReintroduceLlamaItemDuping.java b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java index fff7aff..f4f8bec 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/mixin/ReintroduceLlamaItemDuping.java +++ b/src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java @@ -1,6 +1,6 @@ -package com.keuin.ohmyvanillamc.mixin; +package com.keuin.ohmyvanillamc.mixins.rule.reintroduceLlamaItemDuping; -import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft; +import com.keuin.ohmyvanillamc.OmvmSettings; import net.minecraft.advancement.PlayerAdvancementTracker; import net.minecraft.entity.Entity; import net.minecraft.network.Packet; @@ -26,7 +26,7 @@ import java.util.UUID; * Reintroduce MC-161754 glitch */ @Mixin(PlayerManager.class) -public abstract class ReintroduceLlamaItemDuping { +public abstract class PlayerManagerMixin { @Shadow protected abstract void savePlayerData(ServerPlayerEntity player); @@ -74,11 +74,11 @@ public abstract class ReintroduceLlamaItemDuping { player.stopRiding(); serverWorld.removeEntity(entity); // entity.removed = true - entity.removed = !OhMyVanillaMinecraft.getConfiguration().isReintroduceLlamaItemDuplicating() || entity.removed; + entity.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity.removed; Entity entity2; for (Iterator var4 = entity.getPassengersDeep().iterator(); var4.hasNext(); // entity2.removed = true - entity2.removed = !OhMyVanillaMinecraft.getConfiguration().isReintroduceLlamaItemDuplicating() || entity2.removed) { + entity2.removed = !OmvmSettings.reintroduceLlamaItemDuplicating || entity2.removed) { entity2 = (Entity) var4.next(); serverWorld.removeEntity(entity2); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 134a44c..797724d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,11 +5,12 @@ "name": "Oh My Vanilla Minecraft", "description": "What's wrong with my Minecraft?", "authors": [ - "trueKeuin" + "trueKeuin", + "Merrg1n" ], "contact": { "homepage": "https://www.keuin.cc", - "sources": "https://github.com/keuin/OhMyVanillaMinecraft" + "sources": "https://github.com/hit-mc/OhMyVanillaMinecraft" }, "license": "MIT", "icon": "assets/ohmyvanillamc/icon.png", @@ -25,7 +26,8 @@ "depends": { "fabricloader": ">=0.7.4", "fabric": "*", - "minecraft": "1.16.x" + "minecraft": "1.16.x", + "carpet": "*" }, "suggests": { "another-mod": "*" diff --git a/src/main/resources/ohmyvanillamc.mixins.json b/src/main/resources/ohmyvanillamc.mixins.json index 3a5d935..21e12d2 100644 --- a/src/main/resources/ohmyvanillamc.mixins.json +++ b/src/main/resources/ohmyvanillamc.mixins.json @@ -1,17 +1,17 @@ { "required": true, "minVersion": "0.8", - "package": "com.keuin.ohmyvanillamc.mixin", + "package": "com.keuin.ohmyvanillamc.mixins", "compatibilityLevel": "JAVA_8", "mixins": [ - "DisableEntityTrackerEntrySpamming", - "DisableFishSchooling", - "ReintroduceLlamaItemDuping", - "Mc113809SugarCaneBlockMixin", - "Mc113809CactusBlockMixin", - "Mc113809ChorusFlowerBlockMixin", - "Mc113809BambooBlockMixin", - "Mc113809AbstractPlantStemBlockMixin" + "fix.disableEntityTrackerEntrySpamming.EntityTrackerEntryMixin", + "rule.disableFishSchooling.SchoolingFishEntityMixin", + "rule.forceRipening.AbstractPlantStemBlockMixin", + "rule.forceRipening.BambooBlockMixin", + "rule.forceRipening.CactusBlockMixin", + "rule.forceRipening.ChorusFlowerBlockMixin", + "rule.forceRipening.SugarCaneBlockMixin", + "rule.reintroduceLlamaItemDuping.PlayerManagerMixin" ], "injectors": { "defaultRequire": 1 |