summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java173
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/OmvmExtension.java26
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/OmvmSettings.java51
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/ReflectionUtils.java51
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/config/ImmutableOmvmConfiguration.java54
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/config/OmvmConfiguration.java183
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/fix/disableEntityTrackerEntrySpamming/EntityTrackerEntryMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/DisableEntityTrackerEntrySpamming.java)8
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/disableFishSchooling/SchoolingFishEntityMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/DisableFishSchooling.java)19
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/AbstractPlantStemBlockMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809AbstractPlantStemBlockMixin.java)14
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/BambooBlockMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java)14
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/CactusBlockMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809CactusBlockMixin.java)12
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/ChorusFlowerBlockMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809ChorusFlowerBlockMixin.java)14
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/forceRipening/SugarCaneBlockMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809SugarCaneBlockMixin.java)12
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixins/rule/reintroduceLlamaItemDuping/PlayerManagerMixin.java (renamed from src/main/java/com/keuin/ohmyvanillamc/mixin/ReintroduceLlamaItemDuping.java)10
14 files changed, 136 insertions, 505 deletions
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);
}