Finish backporting to 1.18.2

This commit is contained in:
zontreck 2024-01-16 18:29:09 -07:00
parent 68aac66094
commit 7c1c96d2d2
14 changed files with 80 additions and 105 deletions

View file

@ -2,7 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'net.minecraftforge.gradle' version '5.1+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
@ -41,7 +41,6 @@ minecraft {
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property.
@ -54,7 +53,7 @@ minecraft {
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
// This default location is a best practice to automatically put the file in the right place in the final jar.
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
@ -169,24 +168,6 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {

View file

@ -3,22 +3,22 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
libzontreck=1.10.011524.0045
libzontreck=1.10.011624.1712
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.1
minecraft_version=1.18.2
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21)
minecraft_version_range=[1.18.2,1.19)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.2.0
forge_version=40.2.17
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
forge_version_range=[40,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
loader_version_range=[40,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
@ -36,7 +36,7 @@ loader_version_range=[47,)
mapping_channel=parchment
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=2023.09.03-1.20.1
mapping_version=2022.11.06-1.18.2
## Mod 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.011524.0055
mod_version=1.2.011624.1736
# 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
@ -57,4 +57,4 @@ mod_group_id=dev.zontreck
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=zontreck
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Watches the durability tools, and or your hunger.
mod_description=Watches the durability of tools, and or your hunger.

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -3,8 +3,4 @@ pluginManagement {
gradlePluginPortal()
maven { url = "https://maven.zontreck.com/repository/internal" }
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}

View file

@ -113,7 +113,7 @@ public class WatchMyDurability
{
@SubscribeEvent
public static void onJoin(ClientPlayerNetworkEvent.LoggingIn event){
public static void onJoin(ClientPlayerNetworkEvent.LoggedInEvent event){
// Joined
//LOGGER.info("PLAYER LOGGED IN");
LOGGER.info(": : : PLAYER LOGGED IN : : :");
@ -126,7 +126,7 @@ public class WatchMyDurability
}
@SubscribeEvent
public static void onLeave(ClientPlayerNetworkEvent.LoggingOut event){
public static void onLeave(ClientPlayerNetworkEvent.LoggedOutEvent event){
//LOGGER.info("PLAYER LOGGED OUT");
LOGGER.info(": : : PLAYER LOGGED OUT : : :");
WatchMyDurability.isInGame=false;
@ -135,7 +135,7 @@ public class WatchMyDurability
}
@SubscribeEvent
public static void onClone(ClientPlayerNetworkEvent.Clone event)
public static void onClone(ClientPlayerNetworkEvent.RespawnEvent event)
{
LOGGER.info(": : : : PLAYER RESPAWNED OR MOVED TO A NEW WORLD : : : :");

View file

@ -2,6 +2,7 @@ package dev.zontreck.wmd.checkers;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.wmd.types.Health;
import dev.zontreck.wmd.WatchMyDurability;
import dev.zontreck.wmd.configs.WMDClientConfig;
@ -40,10 +41,10 @@ public class CheckHealth extends Task
if(current.shouldGiveAlert())
{
String Msg = ChatColor.doColors("!Dark_Red!!bold!You need to eat!");
Component chat = Component.literal(Msg);
Component chat = ChatHelpers.macro(Msg);
Minecraft.getInstance().player.displayClientMessage(chat, false);
SoundEvent sv = SoundEvents.WARDEN_ROAR; // It sounds like a growling stomach
SoundEvent sv = SoundEvents.ENDER_DRAGON_GROWL;
Helpers.Soundify(sv);
}

View file

@ -2,6 +2,7 @@ package dev.zontreck.wmd.checkers;
import dev.zontreck.ariaslib.terminal.Task;
import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.wmd.types.Hunger;
import dev.zontreck.wmd.WatchMyDurability;
import dev.zontreck.wmd.configs.WMDClientConfig;
@ -36,10 +37,10 @@ public class CheckHunger extends Task
{
String Msg = ChatColor.doColors("!Dark_Red!!bold!You need to eat!");
Component chat = Component.literal(Msg);
Component chat = ChatHelpers.macro(Msg);
Minecraft.getInstance().player.displayClientMessage(chat, false);
SoundEvent sv = SoundEvents.WARDEN_ROAR; // It sounds like a growling stomach
SoundEvent sv = SoundEvents.ENDER_DRAGON_GROWL; // It sounds like a growling stomach
Helpers.Soundify(sv);
}

View file

@ -106,7 +106,7 @@ public class CheckInventory extends Task {
MutableComponent X = Component.literal(replaced);
MutableComponent X = ChatHelpers.macro(replaced);
HoverEvent he = HoverTip.getItem(is1);
Style s = Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(he);

View file

@ -1,6 +1,7 @@
package dev.zontreck.wmd.commands.impl;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.wmd.networking.ModMessages;
import dev.zontreck.wmd.networking.packets.s2c.RequestClientConfig;
import net.minecraft.commands.CommandSourceStack;
@ -15,7 +16,11 @@ public class SettingsCommand
public static int settingsPrompt(CommandSourceStack sender)
{
ModMessages.sendToPlayer(new RequestClientConfig(), sender.getPlayer());
try {
ModMessages.sendToPlayer(new RequestClientConfig(), sender.getPlayerOrException());
} catch (CommandSyntaxException e) {
throw new RuntimeException(e);
}
return 0;
}
}

View file

@ -31,31 +31,31 @@ public class ModMessages
net.messageBuilder(WMDServerAvailable.class, id(), NetworkDirection.PLAY_TO_CLIENT)
.encoder(WMDServerAvailable::toBytes)
.decoder(WMDServerAvailable::new)
.consumerMainThread(WMDServerAvailable::handle)
.consumer(WMDServerAvailable::handle)
.add();
net.messageBuilder(S2CResetConfig.class, id(), NetworkDirection.PLAY_TO_CLIENT)
.encoder(S2CResetConfig::toBytes)
.decoder(S2CResetConfig::new)
.consumerMainThread(S2CResetConfig::handle)
.consumer(S2CResetConfig::handle)
.add();
net.messageBuilder(RequestClientConfig.class, id(), NetworkDirection.PLAY_TO_CLIENT)
.encoder(RequestClientConfig::toBytes)
.decoder(RequestClientConfig::new)
.consumerMainThread(RequestClientConfig::handle)
.consumer(RequestClientConfig::handle)
.add();
net.messageBuilder(ClientConfigResponse.class, id(), NetworkDirection.PLAY_TO_SERVER)
.encoder(ClientConfigResponse::toBytes)
.decoder(ClientConfigResponse::new)
.consumerMainThread(ClientConfigResponse::handle)
.consumer(ClientConfigResponse::handle)
.add();
net.messageBuilder(PushClientConfigUpdate.class, id(), NetworkDirection.PLAY_TO_CLIENT)
.encoder(PushClientConfigUpdate::toBytes)
.decoder(PushClientConfigUpdate::new)
.consumerMainThread(PushClientConfigUpdate::handle)
.consumer(PushClientConfigUpdate::handle)
.add();
}

View file

@ -18,6 +18,7 @@ import dev.zontreck.wmd.networking.packets.s2c.S2CResetConfig;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@ -60,7 +61,7 @@ public class ClientConfigResponse {
try {
ChestGUI prompt = ChestGUI.builder().withGUIId(new ChestGUIIdentifier("wmdsettings")).withPlayer(player.getUUID()).withTitle("WMD Settings");
ItemStack wtd = new ItemStack(Items.DIAMOND_PICKAXE, 1);
wtd.setHoverName(Component.literal("Watch Tool Durability"));
wtd.setHoverName(new TextComponent("Watch Tool Durability"));
prompt.withButton(new ChestGUIButton(wtd, (stack, container, lore) -> {
var wd = !tag.getBoolean("watchDurability");
@ -79,7 +80,7 @@ public class ClientConfigResponse {
);
ItemStack wmhunger = new ItemStack(Items.APPLE, 1);
wmhunger.setHoverName(Component.literal("Watch My Hunger"));
wmhunger.setHoverName(new TextComponent("Watch My Hunger"));
prompt.withButton(new ChestGUIButton(wmhunger, (stack, container, lore) -> {
var eh = !tag.getBoolean("watchMyHunger");
@ -94,7 +95,7 @@ public class ClientConfigResponse {
.withInfo(new LoreEntry.Builder().text(ChatColor.doColors("!Dark_Green!Status: " + (enableHunger ? "!Dark_Green!Enabled" : "!Dark_Red!Disabled"))).build())
);
ItemStack wmhealth = new ItemStack(Items.PUFFERFISH, 1);
wmhealth.setHoverName(Component.literal("Watch My Health"));
wmhealth.setHoverName(new TextComponent("Watch My Health"));
prompt.withButton(new ChestGUIButton(wmhealth, (stack, container, lore) -> {
var eh = !tag.getBoolean("watchMyHealth");

View file

@ -29,16 +29,16 @@ public class S2CResetConfig
ctx.enqueueWork(()->
{
WMDClientConfig.WMD_PREFIX.set(WMDClientConfig.WMD_PREFIX.getDefault());
WMDClientConfig.WMD_PREFIX.set("!Dark_Gray![!Bold!!Dark_Green!WMD!Reset!!Dark_Gray!]!Reset!");
WMDClientConfig.WMD_PREFIX.save();
WMDClientConfig.EnableHealthAlert.set(WMDClientConfig.EnableHealthAlert.getDefault());
WMDClientConfig.EnableHealthAlert.set(false);
WMDClientConfig.EnableHealthAlert.save();
WMDClientConfig.EnableHungerAlert.set(WMDClientConfig.EnableHungerAlert.getDefault());
WMDClientConfig.EnableHungerAlert.set(false);
WMDClientConfig.EnableHealthAlert.save();
WMDClientConfig.EnableToolWatcher.set(WMDClientConfig.EnableToolWatcher.getDefault());
WMDClientConfig.EnableToolWatcher.set(true);
WMDClientConfig.EnableToolWatcher.save();
});
}

View file

@ -6,71 +6,61 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="${mod_license}"
license="GPLv2"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
issueTrackerURL="https://github.com/zontreck/WatchMyDurability/issues" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
modId="watchmydurability" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
displayName="WatchMyDurability" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png" #optional
#logoFile="logo.png" #optional
# A text field displayed in the mod UI
#credits="" #optional
credits="zontreck, PossumTheWarrior" #optional
# A text field displayed in the mod UI
authors="${mod_authors}" #optional
authors="zontreck" #optional
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
displayTest="IGNORE_ALL_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
# The description text for the mod (multi line!) (#mandatory)
description='''${mod_description}'''
description='''
Watches the durability of your tools, and your health!
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.${mod_id}]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH"
[[dependencies.watchmydurability]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[40,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="libzontreck"
mandatory=true
versionRange="[1.10,1.11)"
ordering="NONE"
side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"
[[dependencies.watchmydurability]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.18.2,1.19)"
ordering="NONE"
side="BOTH"

View file

@ -1,8 +1,8 @@
{
"pack": {
"description": {
"text": "${mod_id} resources"
},
"pack_format": 15
"description": "WatchMyDurability resources",
"pack_format": 9,
"forge:resource_pack_format": 8,
"forge:data_pack_format": 9
}
}