Jump to content

Recommended Posts

Posted

I have a mob, but his / her loot table isn't working

Loot table class:

package com.Egietje.degeweldigemod.mobs;

import java.util.Set;

import net.minecraft.world.storage.loot.LootTableList;

import com.Egietje.degeweldigemod.Reference;
import com.google.common.collect.Sets;

import net.minecraft.util.ResourceLocation;

public class LootTables extends LootTableList {
public static final ResourceLocation ENTITIES_CHEESE_COW = register("cheese_cow");

private static ResourceLocation register(String id) {
        return register(new ResourceLocation(Reference.MODID, id));
    }
}

Loot table json:

{
{
"pools":
	[
		{
			"rolls":1,
			"entries":
			[
				{
					"type": "item",
					"name":"dgm:cheese",
					"weight":1,
					"functions":
					[
						{
							"function":"set_count",
							"count":
							{
								"min":1,"max":5
							}
						},
						{
							"function":"furnace_smelt",
							"conditions":
							[
								{
									"condition":"entity_properties",
									"entity":"this",
									"properties":
									{
										"on_fire":true
									}
								}
							]
						}
					]
				},
				{
					"type":"item",
					"name":"dgm:cheese_apple",
					"weight":1,
					"functions":
					[
						{
						"function":"set_data",
						"data":0
						},
						{
							"function":"set_count",
							"count":1,
							"conditions":
							[
								{
									"condition":"random_chance_with_looting",
									"chance":0.01,"
									looting_multiplier":0.02
								}
							]
						}
					]
				}
			]
		}
	]
}
}

Eclipse console:

[server thread/ERROR]: Couldn't load loot table dgm:cheese_cow from file:/C:/Users/Thomas/Desktop/Coding/DeGeweldigeMod%201.10.2/bin/assets/dgm/loot_tables/cheese_cow.json
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected name at line 2 column 2
at com.google.gson.internal.Streams.parse(Streams.java:56) ~[streams.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) ~[TreeTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:768) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:717) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:689) ~[Gson.class:?]
at net.minecraftforge.common.ForgeHooks.loadLootTable(ForgeHooks.java:1029) ~[ForgeHooks.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.loadBuiltinLootTable(LootTableManager.java:148) [LootTableManager$Loader.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:71) [LootTableManager$Loader.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:52) [LootTableManager$Loader.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at net.minecraft.world.storage.loot.LootTableManager.getLootTableFromLocation(LootTableManager.java:39) [LootTableManager.class:?]
at net.minecraft.entity.EntityLiving.dropLoot(EntityLiving.java:596) [EntityLiving.class:?]
at net.minecraft.entity.EntityLivingBase.onDeath(EntityLivingBase.java:1191) [EntityLivingBase.class:?]
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:1066) [EntityLivingBase.class:?]
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:80) [EntityAnimal.class:?]
at net.minecraft.entity.projectile.EntityArrow.onHit(EntityArrow.java:390) [EntityArrow.class:?]
at net.minecraft.entity.projectile.EntityArrow.onUpdate(EntityArrow.java:285) [EntityArrow.class:?]
at net.minecraft.entity.projectile.EntityTippedArrow.onUpdate(EntityTippedArrow.java:88) [EntityTippedArrow.class:?]
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106) [World.class:?]
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) [WorldServer.class:?]
at net.minecraft.world.World.updateEntity(World.java:2073) [World.class:?]
at net.minecraft.world.World.updateEntities(World.java:1886) [World.class:?]
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]
Caused by: com.google.gson.stream.MalformedJsonException: Expected name at line 2 column 2
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) ~[JsonReader.class:?]
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:502) ~[JsonReader.class:?]
at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:403) ~[JsonReader.class:?]
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:666) ~[TypeAdapters$25.class:?]
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:642) ~[TypeAdapters$25.class:?]
at com.google.gson.internal.Streams.parse(Streams.java:44) ~[streams.class:?]
... 35 more

 

Posted

It looks to me like you have an extra set of curly braces around everything.

Try removing 1 set from the top/bottom and see if that helps.

 

This is the loot json for a mob I made when I was tinkering around with stuff, and it worked:

{
    "pools": [
        {
            "rolls": {
                "min": 1,
                "max": 2
            },
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:feather",
                    "weight": 1,
                    "functions": [
                        {
                            "function": "minecraft:set_count",
                            "count": {
                                "min": 1,
                                "max": 2
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

Posted

{
"pools":
	[
		{
			"rolls":1,
			"entries":
			[
				{
					"type": "item",
					"name":"dgm:cheese",
					"weight":1,
					"functions":
					[
						{
							"function":"set_count",
							"count":
							{
								"min":1,"max":5
							}
						},
						{
							"function":"furnace_smelt",
							"conditions":
							[
								{
									"condition":"entity_properties",
									"entity":"this",
									"properties":
									{
										"on_fire":true
									}
								}
							]
						}
					]
				},
				{
					"type":"item",
					"name":"dgm:cheese_apple",
					"weight":1,
					"functions":
					[
						{
						"function":"set_data",
						"data":0
						},
						{
							"function":"set_count",
							"count":1,
							"conditions":
							[
								{
									"condition":"random_chance_with_looting",
									"chance":0.01,"
									looting_multiplier":0.02
								}
							]
						}
					]
				}
			]
		}
	]
}

[pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@7ee547dc[id=dc4e436a-deac-3fcd-b3ce-7013be63ef4d,name=Player830,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3060) [Minecraft.class:?]
at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:131) [skinManager$3.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_77]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_77]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]
[13:30:07] [server thread/ERROR]: Couldn't load loot table dgm:cheese_cow from file:/C:/Users/Thomas/Desktop/Coding/DeGeweldigeMod%201.10.2/bin/assets/dgm/loot_tables/cheese_cow.json
com.google.gson.JsonParseException: Loot Table "dgm:cheese_cow" Missing `name` entry for pool #0
at net.minecraftforge.common.ForgeHooks.readPoolName(ForgeHooks.java:1105) ~[ForgeHooks.class:?]
at net.minecraft.world.storage.loot.LootPool$Serializer.deserialize(LootPool.java:152) ~[LootPool$Serializer.class:?]
at net.minecraft.world.storage.loot.LootPool$Serializer.deserialize(LootPool.java:147) ~[LootPool$Serializer.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) ~[TypeAdapterRuntimeTypeWrapper.class:?]
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72) ~[ArrayTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:868) ~[Gson.class:?]
at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[Gson$1.class:?]
at net.minecraft.util.JsonUtils.deserializeClass(JsonUtils.java:378) ~[JsonUtils.class:?]
at net.minecraft.util.JsonUtils.deserializeClass(JsonUtils.java:400) ~[JsonUtils.class:?]
at net.minecraft.world.storage.loot.LootTable$Serializer.deserialize(LootTable.java:209) ~[LootTable$Serializer.class:?]
at net.minecraft.world.storage.loot.LootTable$Serializer.deserialize(LootTable.java:204) ~[LootTable$Serializer.class:?]
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:768) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:717) ~[Gson.class:?]
at com.google.gson.Gson.fromJson(Gson.java:689) ~[Gson.class:?]
at net.minecraftforge.common.ForgeHooks.loadLootTable(ForgeHooks.java:1029) ~[ForgeHooks.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.loadBuiltinLootTable(LootTableManager.java:148) [LootTableManager$Loader.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:71) [LootTableManager$Loader.class:?]
at net.minecraft.world.storage.loot.LootTableManager$Loader.load(LootTableManager.java:52) [LootTableManager$Loader.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at net.minecraft.world.storage.loot.LootTableManager.getLootTableFromLocation(LootTableManager.java:39) [LootTableManager.class:?]
at net.minecraft.entity.EntityLiving.dropLoot(EntityLiving.java:596) [EntityLiving.class:?]
at net.minecraft.entity.EntityLivingBase.onDeath(EntityLivingBase.java:1191) [EntityLivingBase.class:?]
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:1066) [EntityLivingBase.class:?]
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:80) [EntityAnimal.class:?]
at net.minecraft.entity.projectile.EntityArrow.onHit(EntityArrow.java:390) [EntityArrow.class:?]
at net.minecraft.entity.projectile.EntityArrow.onUpdate(EntityArrow.java:285) [EntityArrow.class:?]
at net.minecraft.entity.projectile.EntityTippedArrow.onUpdate(EntityTippedArrow.java:88) [EntityTippedArrow.class:?]
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106) [World.class:?]
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872) [WorldServer.class:?]
at net.minecraft.world.World.updateEntity(World.java:2073) [World.class:?]
at net.minecraft.world.World.updateEntities(World.java:1886) [World.class:?]
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]

Posted

/bin/assets/dgm/loot_tables/cheese_cow.json
com.google.gson.JsonParseException: Loot Table "dgm:cheese_cow" Missing `name` entry for pool #0

 

That's the error, but I honestly don't know where you went wrong.

My loot table is in assets\newmod\loot_tables\entities, called "DeathJaw.json".

I never extended the LootTable class, I just have this line in a basic class that I planned to use for storing all my loot table registrations:

public static final ResourceLocation ENTITIES_DEATHJAW = LootTableList.register(new ResourceLocation("newmod","entities/DeathJaw"));

 

The only thing I can think to give a try based on what I see is try changing dgm:cheese to dgm:cheese_cow in your loot table json.

*edit: but that doesn't even make sense, since name as far as I can tell is what you want to drop. What is the name of your loot table json, and where is it located?

Posted

I honestly have no idea; my advice would be to trim down your loot table so that it only drops 1 simple item, then slowly build up from there.

 

Also, where you have set_count, I have "minecraft:set_count", not sure if that makes a difference or not, but might be worth a try if it keeps giving you trouble.

Posted
  On 7/7/2016 at 12:11 PM, Egietje said:

Didn't help

 

Did you try trimming down your loot table to make it simple, to see if it works with just dropping 1 single simple item? For example, try using the loot table I posted that just drops a feather or 2. If that works, start changing 1 small thing at a time and testing.

Posted
  Quote
[13:30:07] [server thread/ERROR]: Couldn't load loot table dgm:cheese_cow from file:/C:/Users/Thomas/Desktop/Coding/DeGeweldigeMod%201.10.2/bin/assets/dgm/loot_tables/cheese_cow.json

com.google.gson.JsonParseException: Loot Table "dgm:cheese_cow" Missing `name` entry for pool #0

at net.minecraftforge.common.ForgeHooks.readPoolName(ForgeHooks.java:1105) ~[ForgeHooks.class:?]

 

Forge requires non-vanilla loot tables to provide a

"name"

entry for each loot pool. You can see a working loot table here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I'm not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.