Rename package!

This commit is contained in:
zontreck 2024-01-09 14:52:40 -07:00
parent bb135ebd65
commit d3cbcc3f36
9 changed files with 435 additions and 438 deletions

View file

@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
libzontreck=1.10.010224.1940 libzontreck=1.10.010924.1444
## Environment Properties ## Environment Properties
@ -49,7 +49,7 @@ mod_name=WatchMyDurability
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.2.010224.1806 mod_version=1.2.010924.1451
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -1,9 +1,9 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import dev.zontreck.ariaslib.terminal.Task; import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.mcmods.configs.WMDClientConfig; import dev.zontreck.wmd.configs.WMDClientConfig;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;

View file

@ -1,9 +1,9 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import dev.zontreck.ariaslib.terminal.Task; import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.mcmods.configs.WMDClientConfig; import dev.zontreck.wmd.configs.WMDClientConfig;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;

View file

@ -1,124 +1,123 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimerTask;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.terminal.Task; import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.HoverTip;
import dev.zontreck.libzontreck.chat.HoverTip; import dev.zontreck.wmd.configs.WMDClientConfig;
import dev.zontreck.mcmods.configs.WMDClientConfig; import net.minecraft.client.Minecraft;
import net.minecraft.client.Minecraft; import net.minecraft.core.NonNullList;
import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.Style; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemStack;
public class CheckInventory extends Task {
public class CheckInventory extends Task { private static final CheckInventory inst = new CheckInventory();
private static final CheckInventory inst = new CheckInventory();
public CheckInventory() {
public CheckInventory() { super("checkinv", true);
super("checkinv", true); }
}
public static CheckInventory getInstance(){
public static CheckInventory getInstance(){ return inst;
return inst; }
} @Override
@Override public void run() {
public void run() {
try {
try {
if(!WatchMyDurability.isInGame)return;
if(!WatchMyDurability.isInGame)return;
//WatchMyDurability.LOGGER.info("TICKING CHECK INVENTORY EVENT");
//WatchMyDurability.LOGGER.info("TICKING CHECK INVENTORY EVENT"); // Get the player inventory
// Get the player inventory Inventory inv = Minecraft.getInstance().player.getInventory();
Inventory inv = Minecraft.getInstance().player.getInventory();
checkList("_armor", inv.armor);
checkList("_armor", inv.armor); checkList("_items", inv.items);
checkList("_items", inv.items); checkList("_offhand", inv.offhand);
checkList("_offhand", inv.offhand);
PushItems("_armor", inv.armor);
PushItems("_armor", inv.armor); PushItems("_items", inv.items);
PushItems("_items", inv.items); PushItems("_offhand", inv.offhand);
PushItems("_offhand", inv.offhand); } catch (Exception e) {
} catch (Exception e) { WatchMyDurability.LOGGER.warn(": : : : [ERROR] : : : :");
WatchMyDurability.LOGGER.warn(": : : : [ERROR] : : : :"); WatchMyDurability.LOGGER.warn("A error in the WatchMyDurability timer code has occurred. This could happen with hub worlds and the server transfers that occur. If this happened in another instance, please report this error to the developer, along with what you were doing.");
WatchMyDurability.LOGGER.warn("A error in the WatchMyDurability timer code has occurred. This could happen with hub worlds and the server transfers that occur. If this happened in another instance, please report this error to the developer, along with what you were doing."); }
}
}
}
public void PushItems(String type, List<ItemStack> stack)
public void PushItems(String type, List<ItemStack> stack) {
{ // OK
// OK // Push the items into the registry, replacing the existing entry
// Push the items into the registry, replacing the existing entry ItemRegistry.purge(type);
ItemRegistry.purge(type); Map<Integer, ItemRegistry.Item> items = new HashMap<Integer, ItemRegistry.Item>();
Map<Integer, ItemRegistry.Item> items = new HashMap<Integer, ItemRegistry.Item>(); Integer slotNum = 0;
Integer slotNum = 0; for (ItemStack itemStack : stack) {
for (ItemStack itemStack : stack) { ItemRegistry.Item itx = WatchMyDurability.REGISTRY.GetNewItem(itemStack);
ItemRegistry.Item itx = WatchMyDurability.REGISTRY.GetNewItem(itemStack);
items.put(slotNum, itx);
items.put(slotNum, itx); slotNum++;
slotNum++;
}
}
ItemRegistry.register(type,items);
ItemRegistry.register(type,items); }
}
public void checkList(String type, NonNullList<ItemStack> stacks){
public void checkList(String type, NonNullList<ItemStack> stacks){ Integer slotNum = 0;
Integer slotNum = 0; //boolean ret=false;
//boolean ret=false; for (ItemStack is1 : stacks) {
for (ItemStack is1 : stacks) { if(is1.isDamageableItem() && is1.isDamaged() && !ItemRegistry.contains(type, slotNum, WatchMyDurability.REGISTRY.GetNewItem(is1))){
if(is1.isDamageableItem() && is1.isDamaged() && !ItemRegistry.contains(type, slotNum, WatchMyDurability.REGISTRY.GetNewItem(is1))){
int percent = 0;
int percent = 0; int max = is1.getMaxDamage();
int max = is1.getMaxDamage(); int val = is1.getDamageValue();
int val = is1.getDamageValue(); int cur = max - val;
int cur = max - val; percent = cur * 100 / max;
percent = cur * 100 / max;
//WatchMyDurability.LOGGER.debug("ITEM DURABILITY: "+cur+"; MAXIMUM: "+max+"; PERCENT: "+percent);
//WatchMyDurability.LOGGER.debug("ITEM DURABILITY: "+cur+"; MAXIMUM: "+max+"; PERCENT: "+percent); for (Integer entry : WMDClientConfig.alertPercents.get()) {
for (Integer entry : WMDClientConfig.alertPercents.get()) { Integer idx = WMDClientConfig.alertPercents.get().indexOf(entry);
Integer idx = WMDClientConfig.alertPercents.get().indexOf(entry); String entryStr = WMDClientConfig.alertMessages.get().get(idx);
String entryStr = WMDClientConfig.alertMessages.get().get(idx);
if(percent <= entry){
if(percent <= entry){ String replaced = WatchMyDurability.WMDPrefix + ChatColor.DARK_RED + entryStr.replaceAll("!item!", is1.getDisplayName().getString());
String replaced = WatchMyDurability.WMDPrefix + ChatColor.DARK_RED + entryStr.replaceAll("!item!", is1.getDisplayName().getString()); WatchMyDurability.LOGGER.info("Enqueue alert for an item. Playing sound for item: "+is1.getDisplayName().getString());
WatchMyDurability.LOGGER.info("Enqueue alert for an item. Playing sound for item: "+is1.getDisplayName().getString());
SoundEvent theSound = SoundEvents.ITEM_BREAK;
SoundEvent theSound = SoundEvents.ITEM_BREAK; WatchMyDurability.Soundify(theSound);
WatchMyDurability.Soundify(theSound);
MutableComponent X = Component.literal(replaced);
MutableComponent X = Component.literal(replaced);
HoverEvent he = HoverTip.getItem(is1);
HoverEvent he = HoverTip.getItem(is1); Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he);
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he); X=X.withStyle(s);
X=X.withStyle(s);
Minecraft.getInstance().player.displayClientMessage(X, false);
Minecraft.getInstance().player.displayClientMessage(X, false); break; // Rule applies, break out of this loop, move to next item.
break; // Rule applies, break out of this loop, move to next item. }
} }
} }
}
slotNum ++;
slotNum ++; }
} //return ret;
//return ret; }
}
}
}

View file

@ -1,36 +1,36 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
public class Health { public class Health {
public float maximum; public float maximum;
public float current; public float current;
public int asPercent() public int asPercent()
{ {
return (int)Math.round(Math.abs((current * 100 / maximum))); return (int)Math.round(Math.abs((current * 100 / maximum)));
} }
public Health lastHealthState; public Health lastHealthState;
public static Health of(Player player){ public static Health of(Player player){
Health obj = new Health(); Health obj = new Health();
obj.current = player.getHealth(); obj.current = player.getHealth();
obj.maximum = player.getMaxHealth(); obj.maximum = player.getMaxHealth();
return obj; return obj;
} }
public boolean shouldGiveAlert() public boolean shouldGiveAlert()
{ {
if(asPercent()<=50){ if(asPercent()<=50){
return true; return true;
}else return false; }else return false;
} }
public boolean identical(Health other) public boolean identical(Health other)
{ {
if(other.current == current && other.maximum == maximum)return true; if(other.current == current && other.maximum == maximum)return true;
else return false; else return false;
} }
} }

View file

@ -1,4 +1,4 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;

View file

@ -1,88 +1,88 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class ItemRegistry { public class ItemRegistry {
public class Item { public class Item {
public String Name; public String Name;
public int PercentDamaged; public int PercentDamaged;
public int Count; public int Count;
public boolean Compare(Item other) public boolean Compare(Item other)
{ {
if(other.Name.equals(Name) && Count == other.Count){ if(other.Name.equals(Name) && Count == other.Count){
if(PercentDamaged != other.PercentDamaged) return false; if(PercentDamaged != other.PercentDamaged) return false;
else return true; else return true;
}else return false; }else return false;
} }
} }
public class Health { public class Health {
} }
public Map<String,Map<Integer, Item>> CachedItems; public Map<String,Map<Integer, Item>> CachedItems;
public ItemRegistry() public ItemRegistry()
{ {
CachedItems = new HashMap<String,Map<Integer,Item>>(); CachedItems = new HashMap<String,Map<Integer,Item>>();
} }
public static void Initialize() public static void Initialize()
{ {
WatchMyDurability.REGISTRY = new ItemRegistry(); WatchMyDurability.REGISTRY = new ItemRegistry();
} }
public static void purge(String type) { public static void purge(String type) {
if(WatchMyDurability.REGISTRY.CachedItems.containsKey(type)) if(WatchMyDurability.REGISTRY.CachedItems.containsKey(type))
WatchMyDurability.REGISTRY.CachedItems.remove(type); WatchMyDurability.REGISTRY.CachedItems.remove(type);
} }
public Item GetNewItem(ItemStack itemStack) { public Item GetNewItem(ItemStack itemStack) {
Item x = new Item(); Item x = new Item();
x.Name = itemStack.getDisplayName().getString(); x.Name = itemStack.getDisplayName().getString();
if(itemStack.isDamageableItem() && itemStack.isDamaged()){ if(itemStack.isDamageableItem() && itemStack.isDamaged()){
int max = itemStack.getMaxDamage(); int max = itemStack.getMaxDamage();
int val = itemStack.getDamageValue(); int val = itemStack.getDamageValue();
int cur = max-val; int cur = max-val;
int percent = cur * 100 /max; int percent = cur * 100 /max;
x.PercentDamaged=percent; x.PercentDamaged=percent;
} }
x.Count = itemStack.getCount(); x.Count = itemStack.getCount();
//WatchMyDurability.LOGGER.debug("ITEM: "+x.Name + "; "+x.PercentDamaged+"; "+x.Type+"; "+x.Count); //WatchMyDurability.LOGGER.debug("ITEM: "+x.Name + "; "+x.PercentDamaged+"; "+x.Type+"; "+x.Count);
return x; return x;
} }
public static void register(String type, Map<Integer, Item> items) { public static void register(String type, Map<Integer, Item> items) {
WatchMyDurability.REGISTRY.CachedItems.put(type, items); WatchMyDurability.REGISTRY.CachedItems.put(type, items);
} }
public static boolean contains(String type, Integer slot, Item getNewItem) { public static boolean contains(String type, Integer slot, Item getNewItem) {
ItemRegistry reg = WatchMyDurability.REGISTRY; ItemRegistry reg = WatchMyDurability.REGISTRY;
if(reg.CachedItems.containsKey(type)){ if(reg.CachedItems.containsKey(type)){
//WatchMyDurability.LOGGER.debug("Registry contains "+type); //WatchMyDurability.LOGGER.debug("Registry contains "+type);
Map<Integer,Item> items = reg.CachedItems.get(type); Map<Integer,Item> items = reg.CachedItems.get(type);
if(items.containsKey(slot)){ if(items.containsKey(slot)){
//WatchMyDurability.LOGGER.debug("ItemRegistry contains slot: "+slot); //WatchMyDurability.LOGGER.debug("ItemRegistry contains slot: "+slot);
Item x = items.get(slot); Item x = items.get(slot);
if(x.Compare(getNewItem)){ if(x.Compare(getNewItem)){
//WatchMyDurability.LOGGER.debug("Items are identical!"); //WatchMyDurability.LOGGER.debug("Items are identical!");
// Items are identical // Items are identical
return true; return true;
}else { }else {
//WatchMyDurability.LOGGER.debug("ITEMS ARE NOT IDENTICAL"); //WatchMyDurability.LOGGER.debug("ITEMS ARE NOT IDENTICAL");
return false; return false;
} }
}else return false; }else return false;
} }
return false; return false;
} }
} }

View file

@ -1,141 +1,139 @@
package dev.zontreck.mcmods; package dev.zontreck.wmd;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.mcmods.configs.WMDClientConfig; import dev.zontreck.wmd.configs.WMDClientConfig;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.User; import net.minecraft.client.User;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.config.ModConfig.Type; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import java.util.Timer;
import java.util.Timer;
import org.slf4j.Logger;
import net.minecraftforge.network.NetworkEvent;
import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file
@Mod(WatchMyDurability.MODID)
// The value here should match an entry in the META-INF/mods.toml file public class WatchMyDurability
@Mod(WatchMyDurability.MODID) {
public class WatchMyDurability // Define mod id in a common place for everything to reference
{ public static final String MODID = "watchmydurability";
// Define mod id in a common place for everything to reference // Directly reference a slf4j logger
public static final String MODID = "watchmydurability"; public static final Logger LOGGER = LogUtils.getLogger();
// Directly reference a slf4j logger
public static final Logger LOGGER = LogUtils.getLogger(); /// DO NOT USE FROM ANY THIRD PARTY PACKAGES
public static User CurrentUser = null; // This is initialized by the client
/// DO NOT USE FROM ANY THIRD PARTY PACKAGES public static boolean isInGame = false; // This locks the timer thread
public static User CurrentUser = null; // This is initialized by the client public static ItemRegistry REGISTRY;
public static boolean isInGame = false; // This locks the timer thread public static Health LastHealth;
public static ItemRegistry REGISTRY; public static Hunger LastHunger;
public static Health LastHealth; public static String WMDPrefix;
public static Hunger LastHunger;
public static String WMDPrefix;
public WatchMyDurability()
{
public WatchMyDurability() WatchMyDurability.WMDPrefix = ChatColor.doColors("!Dark_Gray![!Bold!!Dark_Green!WMD!Reset!!Dark_Gray!]!reset!");
{
WatchMyDurability.WMDPrefix = ChatColor.doColors("!Dark_Gray![!Bold!!Dark_Green!WMD!Reset!!Dark_Gray!]!reset!"); IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); // Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
// Register the commonSetup method for modloading ModLoadingContext.get().registerConfig(Type.CLIENT, WMDClientConfig.SPEC, "watchmydurability-client.toml");
modEventBus.addListener(this::commonSetup);
ModLoadingContext.get().registerConfig(Type.CLIENT, WMDClientConfig.SPEC, "watchmydurability-client.toml"); // Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
// Register ourselves for server and other game events we are interested in }
MinecraftForge.EVENT_BUS.register(this);
} private void commonSetup(final FMLCommonSetupEvent event)
{
private void commonSetup(final FMLCommonSetupEvent event) // Some common setup code
{ //LOGGER.info("HELLO FROM COMMON SETUP");
// Some common setup code }
//LOGGER.info("HELLO FROM COMMON SETUP");
}
public static void Soundify(SoundEvent sound)
{
public static void Soundify(SoundEvent sound) //WatchMyDurability.LOGGER.info("PLAY ALERT SOUND");
{ Minecraft.getInstance().player.playSound(sound, 1.0f, 1.0f);
//WatchMyDurability.LOGGER.info("PLAY ALERT SOUND"); }
Minecraft.getInstance().player.playSound(sound, 1.0f, 1.0f); // You can use SubscribeEvent and let the Event Bus discover methods to call
} @SubscribeEvent
// You can use SubscribeEvent and let the Event Bus discover methods to call public void onServerStarting(ServerStartingEvent event)
@SubscribeEvent {
public void onServerStarting(ServerStartingEvent event) // Do something when the server starts
{ //LOGGER.warn("If this is running on a server, it is doing absolutely nothing, please remove me.");
// Do something when the server starts }
//LOGGER.warn("If this is running on a server, it is doing absolutely nothing, please remove me.");
} // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent public static class ClientModEvents
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD) {
public static class ClientModEvents static Timer time = new Timer();
{
static Timer time = new Timer(); @SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
@SubscribeEvent {
public static void onClientSetup(FMLClientSetupEvent event) LOGGER.info(WMDPrefix+": : : CLIENT SETUP : : :");
{ // Some client setup code
LOGGER.info(WMDPrefix+": : : CLIENT SETUP : : :"); //LOGGER.info("HELLO FROM CLIENT SETUP");
// Some client setup code //LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
//LOGGER.info("HELLO FROM CLIENT SETUP"); WatchMyDurability.CurrentUser = Minecraft.getInstance().getUser();
//LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); DelayedExecutorService.setup();
WatchMyDurability.CurrentUser = Minecraft.getInstance().getUser();
DelayedExecutorService.setup();
//time.schedule(new CheckInventory(),
//WMDClientConfig.TimerVal.get()*1000,
//time.schedule(new CheckInventory(), //WMDClientConfig.TimerVal.get()*1000);
//WMDClientConfig.TimerVal.get()*1000,
//WMDClientConfig.TimerVal.get()*1000); ItemRegistry.Initialize();
ItemRegistry.Initialize(); }
} }
} @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public static class ClientEvents
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) {
public static class ClientEvents
{ @SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
@SubscribeEvent // Joined
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){ //LOGGER.info("PLAYER LOGGED IN");
// Joined LOGGER.info(WMDPrefix+": : : PLAYER LOGGED IN : : :");
//LOGGER.info("PLAYER LOGGED IN"); WatchMyDurability.isInGame=true;
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED IN : : :"); DelayedExecutorService.start();
WatchMyDurability.isInGame=true;
DelayedExecutorService.start(); DelayedExecutorService.getInstance().scheduleRepeating(CheckInventory.getInstance(), WMDClientConfig.TimerVal.get());
DelayedExecutorService.getInstance().scheduleRepeating(CheckHealth.getInstance(), WMDClientConfig.TimerVal.get());
DelayedExecutorService.getInstance().scheduleRepeating(CheckInventory.getInstance(), WMDClientConfig.TimerVal.get()); DelayedExecutorService.getInstance().scheduleRepeating(CheckHunger.getInstance(), WMDClientConfig.TimerVal.get());
DelayedExecutorService.getInstance().scheduleRepeating(CheckHealth.getInstance(), WMDClientConfig.TimerVal.get()); }
DelayedExecutorService.getInstance().scheduleRepeating(CheckHunger.getInstance(), WMDClientConfig.TimerVal.get());
} @SubscribeEvent
public static void onLeave(ClientPlayerNetworkEvent.LoggingOut event){
@SubscribeEvent //LOGGER.info("PLAYER LOGGED OUT");
public static void onLeave(ClientPlayerNetworkEvent.LoggingOut event){ LOGGER.info(WMDPrefix+": : : PLAYER LOGGED OUT : : :");
//LOGGER.info("PLAYER LOGGED OUT"); WatchMyDurability.isInGame=false;
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED OUT : : :"); DelayedExecutorService.stop();
WatchMyDurability.isInGame=false; }
DelayedExecutorService.stop();
} @SubscribeEvent
public static void onClone(ClientPlayerNetworkEvent.Clone event)
@SubscribeEvent {
public static void onClone(ClientPlayerNetworkEvent.Clone event) LOGGER.info(WMDPrefix+": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :");
{
LOGGER.info(WMDPrefix+": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :"); }
}
} }
}
}

View file

@ -1,42 +1,42 @@
package dev.zontreck.mcmods.configs; package dev.zontreck.wmd.configs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
public class WMDClientConfig { public class WMDClientConfig {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC; public static final ForgeConfigSpec SPEC;
public static ForgeConfigSpec.ConfigValue<List<Integer>> alertPercents; public static ForgeConfigSpec.ConfigValue<List<Integer>> alertPercents;
public static ForgeConfigSpec.ConfigValue<List<String>> alertMessages; public static ForgeConfigSpec.ConfigValue<List<String>> alertMessages;
public static ForgeConfigSpec.ConfigValue<Integer> TimerVal; public static ForgeConfigSpec.ConfigValue<Integer> TimerVal;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableExtraHearts; public static ForgeConfigSpec.ConfigValue<Boolean> EnableExtraHearts;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableHealthAlert; public static ForgeConfigSpec.ConfigValue<Boolean> EnableHealthAlert;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableHungerAlert; public static ForgeConfigSpec.ConfigValue<Boolean> EnableHungerAlert;
static{ static{
List<Integer> alerts1 = new ArrayList<>(); List<Integer> alerts1 = new ArrayList<>();
alerts1.add(10); alerts1.add(10);
List<String> alerts2 = new ArrayList<>(); List<String> alerts2 = new ArrayList<>();
alerts2.add("!item! is about to break"); alerts2.add("!item! is about to break");
BUILDER.push("Alerts"); BUILDER.push("Alerts");
BUILDER.comment("Both of the following lists must have the same number of entries. NOTE: Percents do NOT stack. After the first rule is applied, it will move to the next item, so please make the list ascend, and not descend. Example: 10, 50").define("VERSION", "1.1.1.1"); BUILDER.comment("Both of the following lists must have the same number of entries. NOTE: Percents do NOT stack. After the first rule is applied, it will move to the next item, so please make the list ascend, and not descend. Example: 10, 50").define("VERSION", "1.1.1.1");
alertPercents = BUILDER.comment("The list of alerts you want at what percentages of remaining durability").define("Percents", alerts1); alertPercents = BUILDER.comment("The list of alerts you want at what percentages of remaining durability").define("Percents", alerts1);
alertMessages = BUILDER.comment("The messages you want displayed when a alert is triggered. You must have the same amount of messages as alerts").define("Messages", alerts2); alertMessages = BUILDER.comment("The messages you want displayed when a alert is triggered. You must have the same amount of messages as alerts").define("Messages", alerts2);
TimerVal = BUILDER.comment("How many seconds between timer ticks to check your inventory items?").define("Timer", 5); TimerVal = BUILDER.comment("How many seconds between timer ticks to check your inventory items?").define("Timer", 5);
BUILDER.pop(); BUILDER.pop();
BUILDER.push("General"); BUILDER.push("General");
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("watchMyHealth", 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("watchMyHealth", false);
EnableHungerAlert = BUILDER.comment("This is a newer setting to watch your hunger status instead of your hunger to alert when you need to eat").define("watchMyHunger", true); EnableHungerAlert = BUILDER.comment("This is a newer setting to watch your hunger status instead of your hunger to alert when you need to eat").define("watchMyHunger", true);
SPEC=BUILDER.build(); SPEC=BUILDER.build();
} }
} }