feat: improved fullbright (proper removal)

This commit is contained in:
əlemi 2023-01-29 00:03:44 +01:00
parent 27c30423de
commit 503c398ca8
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E
2 changed files with 18 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
@ -84,15 +85,19 @@ public class BoSCoVicino {
commands.setAccessible(true);
commands.set(player.connection, this.dispatcher);
LOGGER.info("Rebuild HINTS");
log("> rebuilt hints");
return 1;
} catch (NoSuchFieldException e) {
log("! no such field error");
LOGGER.error("No such field Exception while rebuilding hints");
return 0;
} catch (IllegalAccessException e) {
log("! illegal access error");
LOGGER.error("Illegal Access Exception while rebuilding hints");
return 0;
}
} else {
log("! local player is NULL");
LOGGER.error("Local player is NULL");
return 0;
}
@ -103,6 +108,10 @@ public class BoSCoVicino {
MinecraftForge.EVENT_BUS.register(this);
}
public static void log(String message) {
BoSCoVicino.minecraft.gui.getChat().addMessage(new StringTextComponent(message));
}
private void setup(final FMLCommonSetupEvent event) {
// some preinit code
LOGGER.info("HELLO FROM PREINIT");
@ -138,6 +147,7 @@ public class BoSCoVicino {
try {
LOGGER.info(String.format("Running command %s", event.getMessage()));
this.dispatcher.execute(event.getMessage().substring(1), source);
BoSCoVicino.minecraft.gui.getChat().addRecentChat(event.getMessage());
event.setCanceled(true);
} catch (CommandSyntaxException e) {
LOGGER.error(String.format("Syntax error in command : %s", e.toString()));

View file

@ -24,7 +24,14 @@ public class Fullbright extends Module {
if (BoSCoVicino.minecraft == null) return;
if (BoSCoVicino.minecraft.player == null) return;
if (this.mode.get().equals("potion")) {
BoSCoVicino.minecraft.player.addEffect(new EffectInstance(Effect.byId(16), 2));
BoSCoVicino.minecraft.player.addEffect(new EffectInstance(Effect.byId(16), 5204));
}
}
@Override
protected void onDisabled() {
if (this.mode.get().equals("potion")) {
BoSCoVicino.minecraft.player.removeEffect(Effect.byId(16));
}
}
}