Merge the 1.19 changes into the 1.20 codebase

This commit is contained in:
Zontreck 2024-02-13 22:43:36 -07:00
parent c5637d7c44
commit c3d9096e63
7 changed files with 54 additions and 54 deletions

View file

@ -7,8 +7,8 @@ org.gradle.daemon=false
parchment_version=2023.09.03
# luckperms_api_version=5.4
libac=1.4.18
eventsbus=1.0.31
libac=1.4.46
eventsbus=1.0.45
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
# 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.10.011524.0045
mod_version=1.10.021324.2257
# 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

@ -13,13 +13,11 @@ import dev.zontreck.eventsbus.Bus;
import dev.zontreck.libzontreck.chestgui.ChestGUIRegistry;
import dev.zontreck.libzontreck.currency.Bank;
import dev.zontreck.libzontreck.currency.CurrencyHelper;
import dev.zontreck.libzontreck.items.CreativeModeTabs;
import dev.zontreck.libzontreck.items.ModItems;
import dev.zontreck.libzontreck.menus.ChestGUIScreen;
import dev.zontreck.libzontreck.types.ModMenuTypes;
import dev.zontreck.libzontreck.networking.NetworkEvents;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraftforge.registries.RegisterEvent;
import org.slf4j.Logger;
import com.mojang.logging.LogUtils;

View file

@ -1,5 +1,6 @@
package dev.zontreck.libzontreck.chat;
import dev.zontreck.libzontreck.util.ChatHelpers;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.HoverEvent.Action;
@ -17,7 +18,7 @@ public class HoverTip {
*/
public static HoverEvent get(String text)
{
return new HoverEvent(Action.SHOW_TEXT, Component.literal(text));
return new HoverEvent(Action.SHOW_TEXT, ChatHelpers.macro(text));
}
/**

View file

@ -7,6 +7,7 @@ import dev.zontreck.libzontreck.items.ModItems;
import dev.zontreck.libzontreck.menus.ChestGUIMenu;
import dev.zontreck.libzontreck.networking.ModMessages;
import dev.zontreck.libzontreck.networking.packets.S2CCloseChestGUI;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.util.ServerUtilities;
import dev.zontreck.libzontreck.vectors.Vector2;
import dev.zontreck.libzontreck.vectors.Vector2i;
@ -198,7 +199,7 @@ public class ChestGUI
{
updateUtilityButtons();
MinecraftForge.EVENT_BUS.post(new OpenGUIEvent(id, player, this));
NetworkHooks.openScreen(ServerUtilities.getPlayerByID(player.toString()), new SimpleMenuProvider(ChestGUIMenu.getServerMenu(this), Component.literal((MenuTitle != "") ? MenuTitle : "No Title")));
NetworkHooks.openScreen(ServerUtilities.getPlayerByID(player.toString()), new SimpleMenuProvider(ChestGUIMenu.getServerMenu(this), ChatHelpers.macro((MenuTitle != "") ? MenuTitle : "No Title")));
}
}

View file

@ -1,46 +0,0 @@
package dev.zontreck.libzontreck.items;
import dev.zontreck.libzontreck.LibZontreck;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
//@Mod.EventBusSubscriber(modid = LibZontreck.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class CreativeModeTabs
{
public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, LibZontreck.MOD_ID);
public static final List<Supplier<? extends ItemLike>> LZ_MOD_ITEMS = new ArrayList<>();
public static final RegistryObject<CreativeModeTab> LIBZONTRECK_TAB = REGISTRY.register("libzontreck", ()->CreativeModeTab.builder()
.title(Component.translatable("itemGroup.tabs.libzontreck"))
.icon(Items.BARRIER::getDefaultInstance)
.displayItems((display,output)->LZ_MOD_ITEMS.forEach(it->output.accept(it.get())))
.build()
);
public static <T extends Item> RegistryObject<T> addToLZTab(RegistryObject<T> item)
{
LZ_MOD_ITEMS.add(item);
return item;
}
public static void register(IEventBus bus)
{
REGISTRY.register(bus);
}
}

View file

@ -0,0 +1,45 @@
package dev.zontreck.libzontreck.util;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.zontreck.ariaslib.util.FileIO;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import java.io.File;
import java.nio.file.Path;
/**
* Provides helpers for reading and writing snbt to file
*/
public class SNbtIo
{
/**
* Read the file at the path, and deserialize from snbt
* @param path The file to load
* @return The deserialized compound tag, or a blank tag
*/
public static CompoundTag loadSnbt(Path path)
{
if(!path.toFile().exists())
return new CompoundTag();
else {
File fi = path.toFile();
try {
return NbtUtils.snbtToStructure(FileIO.readFile(fi.getAbsolutePath()));
} catch (CommandSyntaxException e) {
return new CompoundTag();
}
}
}
/**
* Writes the tag to the file specified
* @param path The file to write
* @param tag The tag to serialize
*/
public static void writeSnbt(Path path, CompoundTag tag)
{
String snbt = NbtUtils.structureToSnbt(tag);
FileIO.writeFile(path.toFile().getAbsolutePath(), snbt);
}
}

View file

@ -4,6 +4,7 @@ import dev.zontreck.libzontreck.chat.ChatColor;
import dev.zontreck.libzontreck.lore.ExtraLore;
import dev.zontreck.libzontreck.lore.LoreContainer;
import dev.zontreck.libzontreck.lore.LoreEntry;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
@ -28,7 +29,7 @@ public class CreditsEntry {
public ItemStack compile()
{
ItemStack stack = player.getAsItem("");
stack.setHoverName(Component.literal(name));
stack.setHoverName(ChatHelpers.macro(name));
LoreContainer contain = new LoreContainer(stack);
contain.clear();
LoreEntry.Builder builder = new LoreEntry.Builder();