Upgrade to 1.18.2

This commit is contained in:
Aria 2023-02-22 02:42:55 -07:00
parent 0f250f76bb
commit 5a47daf797
7 changed files with 34 additions and 20 deletions

View file

@ -7,11 +7,16 @@ import java.util.TimerTask;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.ChatColorFactory;
import dev.zontreck.libzontreck.chat.HoverTip;
import dev.zontreck.libzontreck.chat.ChatColor.ColorOptions;
import dev.zontreck.mcmods.configs.WMDClientConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.player.Inventory;
@ -56,9 +61,10 @@ public class CheckInventory extends TimerTask
if(current.shouldGiveAlert())
{
String Msg = ChatColor.doColors("!Dark_Red!!bold!You need to eat!");
Minecraft.getInstance().player.displayClientMessage(Component.literal(Msg), false);
Component chat = new TextComponent(Msg);
Minecraft.getInstance().player.displayClientMessage(chat, false);
SoundEvent sv = SoundEvents.WARDEN_ROAR; // It sounds like a growling stomach
SoundEvent sv = SoundEvents.WOLF_GROWL; // It sounds like a growling stomach
Soundify(sv);
}
@ -115,7 +121,14 @@ public class CheckInventory extends TimerTask
Soundify(theSound);
Component X = Component.literal(replaced);
MutableComponent X = new TextComponent(replaced);
HoverEvent he = HoverTip.getItem(is1);
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he);
X=X.withStyle(s);
Minecraft.getInstance().player.displayClientMessage(X, false);
break; // Rule applies, break out of this loop, move to next item.
}

View file

@ -4,7 +4,6 @@ import com.mojang.logging.LogUtils;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.mcmods.configs.WMDClientConfig;
import dev.zontreck.mcmods.gui.HeartsRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.User;
import net.minecraftforge.common.MinecraftForge;
@ -18,6 +17,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedInEvent;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent.LoggedOutEvent;
import java.util.Timer;
@ -51,7 +52,7 @@ public class WatchMyDurability
modEventBus.addListener(this::commonSetup);
ModLoadingContext.get().registerConfig(Type.CLIENT, WMDClientConfig.SPEC, "watchmydurability-client.toml");
MinecraftForge.EVENT_BUS.register(new HeartsRenderer());
//MinecraftForge.EVENT_BUS.register(new HeartsRenderer());
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
@ -97,7 +98,7 @@ public class WatchMyDurability
{
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
public static void onJoin(LoggedInEvent event){
// Joined
//LOGGER.info("PLAYER LOGGED IN");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED IN : : :");
@ -105,14 +106,14 @@ public class WatchMyDurability
}
@SubscribeEvent
public static void onLeave(ClientPlayerNetworkEvent.LoggingOut event){
public static void onLeave(LoggedOutEvent event){
//LOGGER.info("PLAYER LOGGED OUT");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED OUT : : :");
WatchMyDurability.isInGame=false;
}
@SubscribeEvent
public static void onClone(ClientPlayerNetworkEvent.Clone event)
public static void onClone(ClientPlayerNetworkEvent.RespawnEvent event)
{
LOGGER.info(WMDPrefix+": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :");

View file

@ -12,7 +12,7 @@ public class WMDClientConfig {
public static ForgeConfigSpec.ConfigValue<List<Integer>> alertPercents;
public static ForgeConfigSpec.ConfigValue<List<String>> alertMessages;
public static ForgeConfigSpec.ConfigValue<Integer> TimerVal;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableExtraHearts;
//public static ForgeConfigSpec.ConfigValue<Boolean> EnableExtraHearts;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableHealthAlert;
static{
@ -33,7 +33,7 @@ public class WMDClientConfig {
BUILDER.pop();
BUILDER.push("General");
EnableExtraHearts = BUILDER.comment("Whether to enable the extra hearts rendering").define("compress_hearts", false);
//EnableExtraHearts = BUILDER.comment("Whether to enable the extra hearts rendering").define("compress_hearts", false);
EnableHealthAlert = BUILDER.comment("The following was added for a friend. If you need reminders to eat in order to heal, turn the below option on").define("watchMyHunger", false);