From 4dad5fc27145593c14425b3e673b924155903585 Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 28 Dec 2020 22:53:31 +0800 Subject: Version 1.3.0: add switches for all disable features. Fixed the vanilla bug that the entity trackers sometimes spam in the console. --- .../keuin/ohmyvanillamc/OhMyVanillaMinecraft.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java') diff --git a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java index c1dc4af..a3d5c90 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java +++ b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java @@ -1,10 +1,33 @@ package com.keuin.ohmyvanillamc; import net.fabricmc.api.ModInitializer; +import net.minecraft.server.network.EntityTrackerEntry; + +import java.lang.reflect.Field; public class OhMyVanillaMinecraft implements ModInitializer { public static boolean disableFishSchooling = true; + public static boolean disablePhantomSpawning = false; + public static boolean disableWanderingTraderSpawning = false; + + private static void disableEntityTrackerEntrySpamming() { + try { + //获取该类的字节码对象 + Class clazz = EntityTrackerEntry.class; + + //获取其私有成员 + Field name = clazz.getDeclaredField("LOGGER"); + + //暴力反射 + name.setAccessible(true); + + //重新赋值 参数一:实力 参数二:值 +// name.set(EntityTrackerEntry, "小鸭鸭"); + } catch (NoSuchFieldException ignored) { + // never mind + } + } @Override public void onInitialize() { @@ -13,5 +36,6 @@ public class OhMyVanillaMinecraft implements ModInitializer { // Proceed with mild caution. System.out.println("OhMyVanillaMinecraft is loading..."); + } } -- cgit v1.2.3