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.daemon=false
libzontreck=1.10.010224.1940
libzontreck=1.10.010924.1444
## 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.
mod_license=GPLv3
# 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.
# This should match the base package used for the mod sources.
# 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.util.DelayedExecutorService;
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.network.chat.Component;
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.util.DelayedExecutorService;
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.network.chat.Component;
import net.minecraft.sounds.SoundEvent;

View file

@ -1,124 +1,123 @@
package dev.zontreck.mcmods;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimerTask;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.HoverTip;
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.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
public class CheckInventory extends Task {
private static final CheckInventory inst = new CheckInventory();
public CheckInventory() {
super("checkinv", true);
}
public static CheckInventory getInstance(){
return inst;
}
@Override
public void run() {
try {
if(!WatchMyDurability.isInGame)return;
//WatchMyDurability.LOGGER.info("TICKING CHECK INVENTORY EVENT");
// Get the player inventory
Inventory inv = Minecraft.getInstance().player.getInventory();
checkList("_armor", inv.armor);
checkList("_items", inv.items);
checkList("_offhand", inv.offhand);
PushItems("_armor", inv.armor);
PushItems("_items", inv.items);
PushItems("_offhand", inv.offhand);
} catch (Exception e) {
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.");
}
}
public void PushItems(String type, List<ItemStack> stack)
{
// OK
// Push the items into the registry, replacing the existing entry
ItemRegistry.purge(type);
Map<Integer, ItemRegistry.Item> items = new HashMap<Integer, ItemRegistry.Item>();
Integer slotNum = 0;
for (ItemStack itemStack : stack) {
ItemRegistry.Item itx = WatchMyDurability.REGISTRY.GetNewItem(itemStack);
items.put(slotNum, itx);
slotNum++;
}
ItemRegistry.register(type,items);
}
public void checkList(String type, NonNullList<ItemStack> stacks){
Integer slotNum = 0;
//boolean ret=false;
for (ItemStack is1 : stacks) {
if(is1.isDamageableItem() && is1.isDamaged() && !ItemRegistry.contains(type, slotNum, WatchMyDurability.REGISTRY.GetNewItem(is1))){
int percent = 0;
int max = is1.getMaxDamage();
int val = is1.getDamageValue();
int cur = max - val;
percent = cur * 100 / max;
//WatchMyDurability.LOGGER.debug("ITEM DURABILITY: "+cur+"; MAXIMUM: "+max+"; PERCENT: "+percent);
for (Integer entry : WMDClientConfig.alertPercents.get()) {
Integer idx = WMDClientConfig.alertPercents.get().indexOf(entry);
String entryStr = WMDClientConfig.alertMessages.get().get(idx);
if(percent <= entry){
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());
SoundEvent theSound = SoundEvents.ITEM_BREAK;
WatchMyDurability.Soundify(theSound);
MutableComponent X = Component.literal(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.
}
}
}
slotNum ++;
}
//return ret;
}
}
package dev.zontreck.wmd;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.chat.HoverTip;
import dev.zontreck.wmd.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.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
public class CheckInventory extends Task {
private static final CheckInventory inst = new CheckInventory();
public CheckInventory() {
super("checkinv", true);
}
public static CheckInventory getInstance(){
return inst;
}
@Override
public void run() {
try {
if(!WatchMyDurability.isInGame)return;
//WatchMyDurability.LOGGER.info("TICKING CHECK INVENTORY EVENT");
// Get the player inventory
Inventory inv = Minecraft.getInstance().player.getInventory();
checkList("_armor", inv.armor);
checkList("_items", inv.items);
checkList("_offhand", inv.offhand);
PushItems("_armor", inv.armor);
PushItems("_items", inv.items);
PushItems("_offhand", inv.offhand);
} catch (Exception e) {
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.");
}
}
public void PushItems(String type, List<ItemStack> stack)
{
// OK
// Push the items into the registry, replacing the existing entry
ItemRegistry.purge(type);
Map<Integer, ItemRegistry.Item> items = new HashMap<Integer, ItemRegistry.Item>();
Integer slotNum = 0;
for (ItemStack itemStack : stack) {
ItemRegistry.Item itx = WatchMyDurability.REGISTRY.GetNewItem(itemStack);
items.put(slotNum, itx);
slotNum++;
}
ItemRegistry.register(type,items);
}
public void checkList(String type, NonNullList<ItemStack> stacks){
Integer slotNum = 0;
//boolean ret=false;
for (ItemStack is1 : stacks) {
if(is1.isDamageableItem() && is1.isDamaged() && !ItemRegistry.contains(type, slotNum, WatchMyDurability.REGISTRY.GetNewItem(is1))){
int percent = 0;
int max = is1.getMaxDamage();
int val = is1.getDamageValue();
int cur = max - val;
percent = cur * 100 / max;
//WatchMyDurability.LOGGER.debug("ITEM DURABILITY: "+cur+"; MAXIMUM: "+max+"; PERCENT: "+percent);
for (Integer entry : WMDClientConfig.alertPercents.get()) {
Integer idx = WMDClientConfig.alertPercents.get().indexOf(entry);
String entryStr = WMDClientConfig.alertMessages.get().get(idx);
if(percent <= entry){
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());
SoundEvent theSound = SoundEvents.ITEM_BREAK;
WatchMyDurability.Soundify(theSound);
MutableComponent X = Component.literal(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.
}
}
}
slotNum ++;
}
//return ret;
}
}

View file

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

View file

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

View file

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

View file

@ -1,141 +1,139 @@
package dev.zontreck.mcmods;
import com.mojang.logging.LogUtils;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.mcmods.configs.WMDClientConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.User;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
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 java.util.Timer;
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)
public class WatchMyDurability
{
// Define mod id in a common place for everything to reference
public static final String MODID = "watchmydurability";
// 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
public static boolean isInGame = false; // This locks the timer thread
public static ItemRegistry REGISTRY;
public static Health LastHealth;
public static Hunger LastHunger;
public static String WMDPrefix;
public WatchMyDurability()
{
WatchMyDurability.WMDPrefix = ChatColor.doColors("!Dark_Gray![!Bold!!Dark_Green!WMD!Reset!!Dark_Gray!]!reset!");
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// Register the commonSetup method for modloading
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);
}
private void commonSetup(final FMLCommonSetupEvent event)
{
// Some common setup code
//LOGGER.info("HELLO FROM COMMON SETUP");
}
public static void Soundify(SoundEvent sound)
{
//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
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.");
}
// 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)
public static class ClientModEvents
{
static Timer time = new Timer();
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
LOGGER.info(WMDPrefix+": : : CLIENT SETUP : : :");
// Some client setup code
//LOGGER.info("HELLO FROM CLIENT SETUP");
//LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
WatchMyDurability.CurrentUser = Minecraft.getInstance().getUser();
DelayedExecutorService.setup();
//time.schedule(new CheckInventory(),
//WMDClientConfig.TimerVal.get()*1000,
//WMDClientConfig.TimerVal.get()*1000);
ItemRegistry.Initialize();
}
}
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public static class ClientEvents
{
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
// Joined
//LOGGER.info("PLAYER LOGGED IN");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED IN : : :");
WatchMyDurability.isInGame=true;
DelayedExecutorService.start();
DelayedExecutorService.getInstance().scheduleRepeating(CheckInventory.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){
//LOGGER.info("PLAYER LOGGED OUT");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED OUT : : :");
WatchMyDurability.isInGame=false;
DelayedExecutorService.stop();
}
@SubscribeEvent
public static void onClone(ClientPlayerNetworkEvent.Clone event)
{
LOGGER.info(WMDPrefix+": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :");
}
}
}
package dev.zontreck.wmd;
import com.mojang.logging.LogUtils;
import dev.zontreck.ariaslib.util.DelayedExecutorService;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.wmd.configs.WMDClientConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.client.User;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
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 java.util.Timer;
import org.slf4j.Logger;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(WatchMyDurability.MODID)
public class WatchMyDurability
{
// Define mod id in a common place for everything to reference
public static final String MODID = "watchmydurability";
// 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
public static boolean isInGame = false; // This locks the timer thread
public static ItemRegistry REGISTRY;
public static Health LastHealth;
public static Hunger LastHunger;
public static String WMDPrefix;
public WatchMyDurability()
{
WatchMyDurability.WMDPrefix = ChatColor.doColors("!Dark_Gray![!Bold!!Dark_Green!WMD!Reset!!Dark_Gray!]!reset!");
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// Register the commonSetup method for modloading
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);
}
private void commonSetup(final FMLCommonSetupEvent event)
{
// Some common setup code
//LOGGER.info("HELLO FROM COMMON SETUP");
}
public static void Soundify(SoundEvent sound)
{
//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
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.");
}
// 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)
public static class ClientModEvents
{
static Timer time = new Timer();
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
LOGGER.info(WMDPrefix+": : : CLIENT SETUP : : :");
// Some client setup code
//LOGGER.info("HELLO FROM CLIENT SETUP");
//LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
WatchMyDurability.CurrentUser = Minecraft.getInstance().getUser();
DelayedExecutorService.setup();
//time.schedule(new CheckInventory(),
//WMDClientConfig.TimerVal.get()*1000,
//WMDClientConfig.TimerVal.get()*1000);
ItemRegistry.Initialize();
}
}
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public static class ClientEvents
{
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
// Joined
//LOGGER.info("PLAYER LOGGED IN");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED IN : : :");
WatchMyDurability.isInGame=true;
DelayedExecutorService.start();
DelayedExecutorService.getInstance().scheduleRepeating(CheckInventory.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){
//LOGGER.info("PLAYER LOGGED OUT");
LOGGER.info(WMDPrefix+": : : PLAYER LOGGED OUT : : :");
WatchMyDurability.isInGame=false;
DelayedExecutorService.stop();
}
@SubscribeEvent
public static void onClone(ClientPlayerNetworkEvent.Clone event)
{
LOGGER.info(WMDPrefix+": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :");
}
}
}

View file

@ -1,42 +1,42 @@
package dev.zontreck.mcmods.configs;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.common.ForgeConfigSpec;
public class WMDClientConfig {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;
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> EnableHealthAlert;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableHungerAlert;
static{
List<Integer> alerts1 = new ArrayList<>();
alerts1.add(10);
List<String> alerts2 = new ArrayList<>();
alerts2.add("!item! is about to break");
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");
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);
TimerVal = BUILDER.comment("How many seconds between timer ticks to check your inventory items?").define("Timer", 5);
BUILDER.pop();
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);
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();
}
}
package dev.zontreck.wmd.configs;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.common.ForgeConfigSpec;
public class WMDClientConfig {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;
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> EnableHealthAlert;
public static ForgeConfigSpec.ConfigValue<Boolean> EnableHungerAlert;
static{
List<Integer> alerts1 = new ArrayList<>();
alerts1.add(10);
List<String> alerts2 = new ArrayList<>();
alerts2.add("!item! is about to break");
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");
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);
TimerVal = BUILDER.comment("How many seconds between timer ticks to check your inventory items?").define("Timer", 5);
BUILDER.pop();
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);
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();
}
}