Jump to content

Creating Spawn Eggs


Willatendo

Recommended Posts

36 minutes ago, Willatendo said:

If some has the code for it, please send it my way.

That's not a good way to problem solve. Asking for the answer without even showing an attempt is just bad. I'll explain the process that's needed; however, someone else can just give you the code.

 

There are a few things to note. First, you can't use the normal spawn egg method as it doesn't contain supplier for later access. Items are registered before entities so they will not go into a spawn egg. So basically, you need to create your own SpawnEggItem extension that takes in a supplier, passes in a null value for the original, overrides the default entity type gotten from the egg, and adds the unadded eggs to the original list using via reflection after entity types have been registered. You might want to take a look at how SpawnEggs are stored and how their dispenser behavior is handled before attempting this.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey guys, I was playing on my mod pack (1.16.5) and recently got this error when I wanted to enter the game and I don't understand it. I updated the mod thinking that was the problem, but it didn't work either, could someone so nice help me? Thank you --- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 5/12/23 9:01 Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed     at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:71) [?:?] {re:classloading}     at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:174) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft$$Lambda$5349/73334840.run(Unknown Source) [?:?] {}     at net.minecraft.util.Util.func_215077_a(Util.java:430) [?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft$$Lambda$5082/1010480754.accept(Unknown Source) [?:?] {}     at net.minecraft.client.gui.ResourceLoadProgressGui.func_230430_a_(ResourceLoadProgressGui.java:172) [?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:802) [?:?] {re:classloading,pl:accesstransformer:B,xf:OptiFine:default}     at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:977) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:37) [forge-1.16.5-36.2.39.jar:36.2] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$532/615830852.call(Unknown Source) [forge-1.16.5-36.2.39.jar:36.2] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1409376656 bytes (1344 MB) / 2046820352 bytes (1952 MB) up to 2097152000 bytes (2000 MB)     CPUs: 2     JVM Flags: 9 total; -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=16M -Xmx1992m -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -XX:+IgnoreUnrecognizedVMOptions     ModLauncher: 8.1.3+8.1.3+main-8.1.x.c94d18ec     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.4.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.2.39.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.2.39.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.2.39.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.2.39.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.4.jar mixin TRANSFORMATIONSERVICE          /OptiFine_1.16.5_HD_U_G8.jar OptiFine TRANSFORMATIONSERVICE          /forge-1.16.5-36.2.39.jar fml TRANSFORMATIONSERVICE      FML: 36.2     Forge: net.minecraftforge:36.2.39     FML Language Providers:          javafml@36.2         minecraft@1     Mod List:          forge-1.16.5-36.2.39-client.jar                   |Minecraft                     |minecraft                     |1.16.5              |CREATE_REG|Manifest: NOSIGNATURE         YungsExtras-Forge-1.16.4-1.0.jar                  |YUNG's Extras                 |yungsextras                   |Forge-1.16.4-1.0    |CREATE_REG|Manifest: NOSIGNATURE         YungsApi-1.16.4-Forge-13.jar                      |YUNG's API                    |yungsapi                      |1.16.4-Forge-13     |CREATE_REG|Manifest: NOSIGNATURE         mowziesmobs-1.5.27.jar                            |Mowzie's Mobs                 |mowziesmobs                   |1.5.27              |CREATE_REG|Manifest: NOSIGNATURE         BetterDungeons-1.16.4-1.2.1.jar                   |YUNG's Better Dungeons        |betterdungeons                |1.16.4-1.2.1        |CREATE_REG|Manifest: NOSIGNATURE         BetterStrongholds-1.16.4-1.2.1.jar                |YUNG's Better Strongholds     |betterstrongholds             |1.16.4-1.2.1        |CREATE_REG|Manifest: NOSIGNATURE         sophisticatedbackpacks-1.16.5-3.15.20.755.jar     |Sophisticated Backpacks       |sophisticatedbackpacks        |1.16.5-3.15.20.755  |CREATE_REG|Manifest: NOSIGNATURE         jei-1.16.5-7.8.0.1009.jar                         |Just Enough Items             |jei                           |7.8.0.1009          |CREATE_REG|Manifest: NOSIGNATURE         byg-1.3.6.jar                                     |Oh The Biomes You'll Go       |byg                           |1.3.4               |CREATE_REG|Manifest: NOSIGNATURE         betternether_reforged-1.2.jar                     |Better Nether Reforged        |betternether                  |1.2                 |CREATE_REG|Manifest: NOSIGNATURE         forge-1.16.5-36.2.39-universal.jar                |Forge                         |forge                         |36.2.39             |CREATE_REG|Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         twilightforest-1.16.5-4.0.546-universal.jar       |The Twilight Forest           |twilightforest                |NONE                |CREATE_REG|Manifest: NOSIGNATURE         BetterMineshafts-Forge-1.16.4-2.0.4.jar           |YUNG's Better Mineshafts      |bettermineshafts              |1.16.4-2.0.4        |CREATE_REG|Manifest: NOSIGNATURE         BetterCaves-Forge-1.16.4-1.1.2.jar                |YUNG's Better Caves           |bettercaves                   |1.16.4-1.1.2        |CREATE_REG|Manifest: NOSIGNATURE         geckolib-forge-1.16.5-3.0.106.jar                 |GeckoLib                      |geckolib3                     |3.0.106             |CREATE_REG|Manifest: NOSIGNATURE         DynamicSurroundings-1.16.5-4.0.5.0.jar            |§3Dynamic Surroundings        |dsurround                     |4.0.5.0             |CREATE_REG|Manifest: NOSIGNATURE         journeymap-1.16.5-5.8.3.jar                       |Journeymap                    |journeymap                    |5.8.3               |CREATE_REG|Manifest: NOSIGNATURE         DungeonsArise-1.16.5-2.1.49-beta.jar              |When Dungeons Arise           |dungeons_arise                |2.1.49              |CREATE_REG|Manifest: NOSIGNATURE         citadel-1.8.1-1.16.5.jar                          |Citadel                       |citadel                       |1.8.1               |CREATE_REG|Manifest: NOSIGNATURE         untamedwilds-1.16.5-1.5.8.jar                     |Untamed Wilds                 |untamedwilds                  |1.5.8               |ERROR     |Manifest: NOSIGNATURE         iceandfire-2.1.12-1.16.5-patch-1.jar              |Ice and Fire                  |iceandfire                    |2.1.12-1.16.5-patch-|CREATE_REG|Manifest: NOSIGNATURE     Crash Report UUID: 5cfb2f17-4508-427f-9ef7-055c47f08891     OptiFine Version: OptiFine_1.16.5_HD_U_G8     OptiFine Build: 20210515-161946     Render Distance Chunks: 8     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 4.0.0 - Build 10.18.10.4358     OpenGlRenderer: Intel(R) HD Graphics     OpenGlVendor: Intel     CpuCount: 2
    • idk how to reply here but no im not coding any mod, all of them are downloaded but its only gfs computer, on mine its ok and i was looking all around the internet and never seen anything similiar atleast  
    • I changed it to public static void but I can't find anyway to get level from the event even if it isn't a listener parameter. @JimiIT92
    • I didn't yet see this happening on 1.20.2 forge, but sadly, I noticed that my mod is incompatible with this version because of this event handler: @SubscribeEvent public static void onPlayerRightClickItem(PlayerInteractEvent.RightClickItem e) { if (e.getItemStack().getItem() instanceof EggItem) { List<ThrownEgg> eggs = e.getLevel().getEntitiesOfClass(ThrownEgg.class, new AABB(e.getEntity().blockPosition().immutable() .below(5) .north(5) .west(5), e.getEntity().blockPosition().immutable() .above(10) .south(5) .east(5))); if (!eggs.isEmpty()) { eggs.forEach(ThrownEgg::discard); if (!e.getEntity().getAbilities().instabuild) e.getItemStack().grow(1); } if (!e.getEntity().level().isClientSide) { ((ServerPlayer) e.getEntity()).connection.send( new ClientboundStopSoundPacket(SoundEvents.EGG_THROW.getLocation(), SoundSource.PLAYERS)); // Minecraft Forge 1.20.2 crashes because of NoSuchMethodError here } e.setCancellationResult(InteractionResult.SUCCESS); e.setCanceled(true); } }  
    • It might just be a misleading log, if you run the command while debugging what's the outcome?  I've tried checking the item inside the RightClickBlock event and it works just fine private static final Ingredient FOOD_ITEMS = Ingredient.of(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD); @SubscribeEvent public static void onRightClickBlock(final PlayerInteractEvent.RightClickBlock event) { final ItemStack itemStack = event.getItemStack(); LOGGER.info(FOOD_ITEMS.test(itemStack) + ""); } When I right click a block with an Item it checks if is one of the ingredients of FOOD_ITEMS. Clicking with an empty hand (air) logs false, as expected. Tip: please use the "spoiler" tags for long code snippets and don't merge all your classes into one code snippet EDIT: just noticed you are on 1.20.1. Maybe is just a bug with the Forge version? Try update to the latest Forge 1.20.2 and see if it still occurs
  • Topics

×
×
  • Create New...

Important Information

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