From c6ff1afbdc0e6bef149017181ee0130d9d5ddeb0 Mon Sep 17 00:00:00 2001 From: Aria Date: Fri, 21 Apr 2023 03:44:40 -0700 Subject: [PATCH] Upgrade back to 1.19.4 Increment API version + LibAC - Lightmans Currency - Parchment (Temporary) --- build.gradle | 13 ++++++++---- gradle.properties | 12 ++++++----- .../dev/zontreck/libzontreck/LibZontreck.java | 3 +++ .../zontreck/libzontreck/chat/HoverTip.java | 4 ++-- .../libzontreck/commands/GetHead.java | 2 +- .../libzontreck/currency/CurrencyHelper.java | 14 +++++++++++++ .../events/CurrencyBalanceCheckEvent.java | 20 +++++++++++++++++++ .../events/ForgeEventHandlers.java | 18 ++++++++++++++--- .../packets/S2CPlaySoundPacket.java | 2 +- .../libzontreck/types/ModMenuTypes.java | 2 +- .../libzontreck/util/ChatHelpers.java | 5 ++--- .../zontreck/libzontreck/util/ItemUtils.java | 14 +++++++++---- .../libzontreck/util/heads/CreditsEntry.java | 4 ++-- .../libzontreck/util/heads/HeadCache.java | 4 ++-- .../zontreck/libzontreck/vectors/Vector3.java | 8 +++++++- src/main/resources/META-INF/mods.toml | 6 +++--- 16 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 src/main/java/dev/zontreck/libzontreck/currency/CurrencyHelper.java create mode 100644 src/main/java/dev/zontreck/libzontreck/currency/events/CurrencyBalanceCheckEvent.java diff --git a/build.gradle b/build.gradle index c5b9706..20cb97b 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,9 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'parchment', version: "${parchment_version}-${mc_version}" + // mappings channel: 'parchment', version: "${parchment_version}-${mc_version}" + mappings channel: 'official', version: "${mc_version}" + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. @@ -139,11 +141,13 @@ dependencies { // Examples using mod jars from ./libs // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") //compileOnly ("net.luckperms:api:${luckperms_api_version}") - //runtimeOnly fg.deobf("curse.maven:luckperms-431733:3828099") + //runtimeOnly fg.deobf("curse.maven:luckperms-431733:4443551") //implementation fg.deobf("blank:LuckPerms:Forge-5.4.12") - provided "dev.zontreck:LibAC:1.1.1" - implementation "dev.zontreck:LibAC:1.1.1" + provided "dev.zontreck:LibAC:${libac}" + implementation "dev.zontreck:LibAC:${libac}" + minecraftLibrary "dev.zontreck:LibAC:${libac}" + // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html @@ -168,6 +172,7 @@ jar { } } + compileJava.finalizedBy('devJar') // Example configuration to allow publishing using the maven-publish plugin // This is the preferred method to reobfuscate your jar file diff --git a/gradle.properties b/gradle.properties index 87aa10d..36d7f57 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,10 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mc_version=1.18.2 -forge_version=40.2.1 -myversion=1.0.6.0420232221 -parchment_version=2022.11.06 -luckperms_api_version=5.4 \ No newline at end of file +mc_version=1.19.4 +forge_version=45.0.46 +myversion=1.0.7.0421230342 +parchment_version=2023.03.12 +luckperms_api_version=5.4 + +libac=1.1.3 diff --git a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java index 7cf1c1d..6715d3b 100644 --- a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java +++ b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java @@ -7,6 +7,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import dev.zontreck.ariaslib.events.EventBus; +import dev.zontreck.libzontreck.currency.CurrencyHelper; import org.slf4j.Logger; import com.mojang.logging.LogUtils; @@ -72,6 +74,7 @@ public class LibZontreck { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers()); MinecraftForge.EVENT_BUS.register(new Commands()); + EventBus.BUS.register(CurrencyHelper.class); } private void setup(final FMLCommonSetupEvent event) diff --git a/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java b/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java index d73b714..2eafb13 100644 --- a/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java +++ b/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java @@ -1,7 +1,7 @@ package dev.zontreck.libzontreck.chat; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; -import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.HoverEvent.Action; import net.minecraft.world.item.ItemStack; @@ -17,7 +17,7 @@ public class HoverTip { */ public static HoverEvent get(String text) { - return new HoverEvent(Action.SHOW_TEXT, new TextComponent(text)); + return new HoverEvent(Action.SHOW_TEXT, Component.literal(text)); } /** diff --git a/src/main/java/dev/zontreck/libzontreck/commands/GetHead.java b/src/main/java/dev/zontreck/libzontreck/commands/GetHead.java index ade30aa..7aa2f40 100644 --- a/src/main/java/dev/zontreck/libzontreck/commands/GetHead.java +++ b/src/main/java/dev/zontreck/libzontreck/commands/GetHead.java @@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack; public class GetHead { public static void register(CommandDispatcher dispatch) { - dispatch.register(Commands.literal("aria_debug_get_head").executes(c-> getHead(c.getSource(), c.getSource().getEntity().getName().getContents())).then(Commands.argument("name", StringArgumentType.string()).executes(c -> getHead(c.getSource(), StringArgumentType.getString(c, "name"))))); + dispatch.register(Commands.literal("aria_debug_get_head").executes(c-> getHead(c.getSource(), c.getSource().getEntity().getName().getString())).then(Commands.argument("name", StringArgumentType.string()).executes(c -> getHead(c.getSource(), StringArgumentType.getString(c, "name"))))); } diff --git a/src/main/java/dev/zontreck/libzontreck/currency/CurrencyHelper.java b/src/main/java/dev/zontreck/libzontreck/currency/CurrencyHelper.java new file mode 100644 index 0000000..8dc1168 --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/currency/CurrencyHelper.java @@ -0,0 +1,14 @@ +package dev.zontreck.libzontreck.currency; + +import dev.zontreck.ariaslib.events.annotations.Subscribe; +import dev.zontreck.libzontreck.currency.events.CurrencyBalanceCheckEvent; + +import java.util.List; + +public class CurrencyHelper { + @Subscribe + public static void onCurrencyBalanceCheck(CurrencyBalanceCheckEvent ev) + { + + } +} diff --git a/src/main/java/dev/zontreck/libzontreck/currency/events/CurrencyBalanceCheckEvent.java b/src/main/java/dev/zontreck/libzontreck/currency/events/CurrencyBalanceCheckEvent.java new file mode 100644 index 0000000..dc857f2 --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/currency/events/CurrencyBalanceCheckEvent.java @@ -0,0 +1,20 @@ +package dev.zontreck.libzontreck.currency.events; + +import dev.zontreck.ariaslib.events.Event; +import net.minecraft.world.entity.player.Player; + + +public class CurrencyBalanceCheckEvent extends Event +{ + public final Player player; + public String balance; + + public CurrencyBalanceCheckEvent(Player player) + { + this.player=player; + } + @Override + public boolean isCancellable() { + return false; + } +} diff --git a/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java index bf89fef..147ff6c 100644 --- a/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java +++ b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java @@ -1,13 +1,17 @@ package dev.zontreck.libzontreck.events; +import dev.zontreck.ariaslib.events.Event; +import dev.zontreck.ariaslib.events.EventBus; +import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.libzontreck.LibZontreck; +import dev.zontreck.libzontreck.currency.events.CurrencyBalanceCheckEvent; import dev.zontreck.libzontreck.memory.PlayerContainer; import dev.zontreck.libzontreck.profiles.Profile; import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -16,7 +20,7 @@ import net.minecraftforge.fml.common.Mod; public class ForgeEventHandlers { @SubscribeEvent - public void onPlayerTick(LivingUpdateEvent ev) + public void onPlayerTick(LivingEvent.LivingTickEvent ev) { if(ev.getEntity().level.isClientSide)return; @@ -40,11 +44,19 @@ public class ForgeEventHandlers { { if(ev.getEntity().level.isClientSide)return; - ServerPlayer player = (ServerPlayer)ev.getPlayer(); + ServerPlayer player = (ServerPlayer)ev.getEntity(); Profile prof = Profile.factory(player); ServerLevel level = player.getLevel(); MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof, player, level)); + + DelayedExecutorService.getInstance().schedule(new Runnable() { + @Override + public void run() { + CurrencyBalanceCheckEvent event= new CurrencyBalanceCheckEvent(ev.getEntity()); + EventBus.BUS.post(event); + } + }, 10); } @SubscribeEvent diff --git a/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java b/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java index 30e9f47..0b5f17e 100644 --- a/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java +++ b/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java @@ -49,7 +49,7 @@ public class S2CPlaySoundPacket implements IPacket ctx.enqueueWork(()->{ // We are on the client now, enqueue the sound! - SoundEvent ev = new SoundEvent(sound); + SoundEvent ev = SoundEvent.createFixedRangeEvent(sound, 2.0f); // Play sound for player! Minecraft.getInstance().player.playSound(ev, 1, BinUtil.getARandomInstance().nextFloat(0, 1)); }); diff --git a/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java b/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java index 16c9b43..d2dedb0 100644 --- a/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java +++ b/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java @@ -7,7 +7,7 @@ import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class ModMenuTypes { - public static DeferredRegister> REGISTER = DeferredRegister.create(ForgeRegistries.CONTAINERS, LibZontreck.MOD_ID); + public static DeferredRegister> REGISTER = DeferredRegister.create(ForgeRegistries.MENU_TYPES, LibZontreck.MOD_ID); public static void register(IEventBus bus) { diff --git a/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java b/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java index 86d7623..fb0859d 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java +++ b/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java @@ -5,7 +5,6 @@ import java.util.UUID; import dev.zontreck.libzontreck.LibZontreck; import dev.zontreck.libzontreck.chat.ChatColor; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; @@ -78,9 +77,9 @@ public class ChatHelpers { * @param inputs Entries to replace with in input * @return */ - public static TextComponent macro(String input, String... inputs) + public static Component macro(String input, String... inputs) { - return new TextComponent(macroize(input,inputs)); + return Component.literal(macroize(input,inputs)); } /** * Returns the output with colors applied, and chat entries replaced using [number] as the format diff --git a/src/main/java/dev/zontreck/libzontreck/util/ItemUtils.java b/src/main/java/dev/zontreck/libzontreck/util/ItemUtils.java index 0c8e04f..f1ef6f1 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/ItemUtils.java +++ b/src/main/java/dev/zontreck/libzontreck/util/ItemUtils.java @@ -2,6 +2,7 @@ package dev.zontreck.libzontreck.util; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import net.minecraft.core.Registry; @@ -11,25 +12,30 @@ import net.minecraft.nbt.Tag; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraftforge.registries.ForgeRegistries; public class ItemUtils { public static Map getEnchantments(ItemStack stack) { - ListTag enchants = stack.getEnchantmentTags(); - Map enchantments = new HashMap<>(); + //ListTag enchants = stack.getEnchantmentTags(); + Map enchantments = EnchantmentHelper.getEnchantments(stack); + return enchantments; + + /*Map enchantments = new HashMap<>(); Iterator enchantsIterator = enchants.iterator(); while(enchantsIterator.hasNext()) { CompoundTag theTag = (CompoundTag)enchantsIterator.next(); - Enchantment ench = Registry.ENCHANTMENT.getOptional(EnchantmentHelper.getEnchantmentId(theTag)).get(); + Enchantment enchant = EnchantmentHelper. + Enchantment ench = .getOptional(EnchantmentHelper.getEnchantmentId(theTag)).get(); Integer level = EnchantmentHelper.getEnchantmentLevel(theTag); enchantments.put(ench, level); } - return enchantments; + return enchantments;*/ } public static Integer getEnchantmentLevel(Enchantment ench, ItemStack stack) diff --git a/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java b/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java index aa020cc..6a7e46f 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java +++ b/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java @@ -4,7 +4,7 @@ import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.lore.LoreContainer; import dev.zontreck.libzontreck.lore.LoreEntry; import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; public class CreditsEntry { @@ -27,7 +27,7 @@ public class CreditsEntry { public ItemStack compile() { ItemStack stack = player.getAsItem(); - stack.setHoverName(new TextComponent(name)); + stack.setHoverName(Component.literal(name)); LoreContainer contain = new LoreContainer(stack); LoreEntry entry = new LoreEntry(); entry.text = ChatColor.doColors("!Dark_Purple!Role: "+role); diff --git a/src/main/java/dev/zontreck/libzontreck/util/heads/HeadCache.java b/src/main/java/dev/zontreck/libzontreck/util/heads/HeadCache.java index 44e8fdb..6dc7702 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/heads/HeadCache.java +++ b/src/main/java/dev/zontreck/libzontreck/util/heads/HeadCache.java @@ -12,7 +12,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.PlayerHeadItem; @@ -66,7 +66,7 @@ public class HeadCache skullOwner.put("Properties", properties); head.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, skullOwner); - TextComponent headname = ChatHelpers.macro("[0]'s Head", name); + Component headname = ChatHelpers.macro("[0]'s Head", name); head.setHoverName(headname); return head; diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java b/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java index 68b2481..c1cf9ee 100644 --- a/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java +++ b/src/main/java/dev/zontreck/libzontreck/vectors/Vector3.java @@ -5,6 +5,7 @@ import java.util.List; import dev.zontreck.libzontreck.exceptions.InvalidDeserialization; import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.phys.Vec3; @@ -21,9 +22,14 @@ public class Vector3 return new Vec3(x, y, z); } + public Vec3i asMinecraftVec3i() + { + return new Vec3i((int) Math.round(x), (int) Math.round(y), (int) Math.round(z)); + } + public BlockPos asBlockPos() { - return new BlockPos(asMinecraftVector()); + return new BlockPos(asMinecraftVec3i()); } public Vector3() diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8156823..77cdaf5 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # 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="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[45,)" #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="GPLv3" @@ -52,7 +52,7 @@ This mod provides common code to all of zontreck's mods. # 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 + versionRange="[45,)" #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 @@ -62,6 +62,6 @@ This mod provides common code to all of zontreck's mods. 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)" + versionRange="[1.19.4,1.20)" ordering="NONE" side="BOTH"