Jump to content

[1.12.2][SOLVED]Adding Drops to Vanilla Blocks


Mufark

Recommended Posts

Hey Guys,

 

I Have created a custom loot drop table and its working for entities but when I try and add drops to vanilla blocks it doesn't seem to be working. Keep in mind that I am a complete Java noob. I usually program in C and C++. Similar but different. Anyways. My code I am using is below. I know the top part is right. But I cant work out a way to ID the block I want the drop to be added to.

 

    @SubscribeEvent
    public void onHarvestEvent(HarvestDropsEvent event)
    {
         if (event.getHarvester() != null)                      //Checks to make sure player is harvesting.
         {
             if(event.equals(Blocks.STONE))                //Is meant to confirm which block is being broken.
             {

                 //This will add my item to the block as it drops with 100% drop rate while I am testing.
                 event.setDropChance((float) 1.0F);
                 event.getDrops().add(new ItemStack(ModItems.DOLLAR_BILL,1));
             }
         }
    }

 

Not sure if the second half works yet but I am 100% certain that the if(event.equals(Blocks.STONE) is incorrect. Someone with some knowledge on working with Forge 1.12.2 would be much appreciated.

Edited by Mufark
Problem solved thanka to help.
Link to comment
Share on other sites

16 minutes ago, Mufark said:

if(event.equals(Blocks.STONE))

Well obviously this won't work. An Event can't be equal to a Block, this is basic OOP. The event has a getter that will get you the IBlockState of the block being broken and you can then get the block with IBlockState#getBlock and compare that.

 

16 minutes ago, Mufark said:

//This will add my item to the block as it drops with 100% drop rate while I am testing.
event.setDropChance((float) 1.0F);

The drop chance applies to all the items at the same time, not to the one you've added. If you want a chance for your item to drop then only add the item to the list if the random check succeeds.

  • Thanks 1
Link to comment
Share on other sites

Thanks Heaps. That is really helpful. Good to know that the second part would have an overall effect on the item drop for the block too. I'll change it and see how I go.

 

EDIT: I'll just add an if statement that will create a random number that will give me a chance to drop.

Edited by Mufark
New Info
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
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I just resolved deleting the serverconfig folder thank you a lot, but where do i find the debug.log in the settings?  
    • One of your configuration files is invalid/corrupted. You can find it in the world/serverconfig folder. If you don't have a backup of the file, you can delete it and the file will be recreated with default values.
    • Hello, i am encountering a problem with my minecraft modpack, when i try to load a saved world (already made in that modpack) the game crash on the loading screen with the following specs:  ModLoader: Forge - 43.2.0 GameVersion: 1.19.2 MODS:   Just Enough Items (JEI) (by mezz) Waystones (by BlayTheNinth) ESSENTIAL Mod (by SparkUniverse_) Enchantment Descriptions (by DarkhaxDev) YUNG's Better Strongholds (Forge) (by YUNGNICKYOUNG) Xaero's World Map (by xaero96) Bookshelf (by DarkhaxDev) Curios API (Forge) (by TheIllusiveC4) GeckoLib (by Gecko) AppleSkin (by squeek502) ProjectE (by SinKillerJ) Deeper and Darker (by KyaniteMods) Just Enough Resources (JER) (by way2muchnoise) Balm (Forge Edition) (by BlayTheNinth) Create Stuff & Additions (by Furti_Two) Storage Drawers (by Texelsaur) Croptopia (by thethonk) Create Deco (by talrey) YUNG's Better Dungeons (Forge) (by YUNGNICKYOUNG) Inventory HUD+ (by dmitrylovin) OpenBlocks Elevator (by vsngarcia) Tree Harvester (by Serilum) Mouse Tweaks (by YaLTeR) Elytra Slot (Fabric/Forge/Quilt) (by TheIllusiveC4) Iron Furnaces [FORGE] (by XenoMustache) Controlling (by Jaredlll08) The Twilight Forest (by Benimatic) Just Enough Professions (JEP) (by Mrbysco) YUNG's Better Desert Temples (Forge) (by YUNGNICKYOUNG) Collective (by Serilum) YUNG's Better Mineshafts (Forge) (by YUNGNICKYOUNG) Create (by simibubi) Caelus API (Forge) (by TheIllusiveC4) Clumps (by Jaredlll08) YUNG's Better Ocean Monuments (Forge) (by YUNGNICKYOUNG) Fast Leaf Decay (by olafskiii) YUNG's API (Forge) (by YUNGNICKYOUNG) The crash report i am getting is the following   ---- Minecraft Crash Report ---- // My bad. Time: 2023-03-25 11:27:34 Description: Exception in server tick loop net.minecraftforge.fml.config.ConfigFileTypeHandler$ConfigLoadingException: Failed loading config file curios-server.toml of type SERVER for modid curios     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:47) ~[fmlcore-1.19.2-43.2.0.jar%23224!/:?] {}     at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:60) ~[fmlcore-1.19.2-43.2.0.jar%23224!/:?] {}     at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:50) ~[fmlcore-1.19.2-43.2.0.jar%23224!/:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:computing_frames,re:mixin}     at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2131) ~[?:?] {}     at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:50) ~[fmlcore-1.19.2-43.2.0.jar%23224!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:90) ~[forge-1.19.2-43.2.0-universal.jar%23228!/:?] {re:classloading}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.optifine.reflect.Reflector.callBoolean(Reflector.java:707) ~[OptiFine_1.19.2_HD_U_I1%20(1).jar%23241!/:?] {re:classloading}     at net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:79) ~[client-1.19.2-20220805.130853-srg.jar%23223!/:?] {re:mixin,xf:OptiFine:default,re:classloading,xf:OptiFine:default,pl:mixin:APP:mixins.essential.json:server.integrated.MixinIntegratedServer,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:625) ~[client-1.19.2-20220805.130853-srg.jar%23223!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:feature.sps.Mixin_IntegratedServerResourcePack,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:244) ~[client-1.19.2-20220805.130853-srg.jar%23223!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:APP:mixins.essential.json:feature.sps.Mixin_IntegratedServerResourcePack,pl:mixin:APP:mixins.essential.json:server.MinecraftServerMixin_PvPGameRule,pl:mixin:APP:mixins.essential.json:server.Mixin_PublishServerStatusResponse,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) [?:?] {re:mixin} Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available     at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.4.jar%2385!/:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.4.jar%2385!/:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.4.jar%2385!/:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.4.jar%2385!/:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.4.jar%2385!/:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.4.jar%2384!/:?] {}     at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.4.jar%2384!/:?] {}     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:43) ~[fmlcore-1.19.2-43.2.0.jar%23224!/:?] {}     ... 15 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.19.2     Minecraft Version ID: 1.19.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.3, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 1015485096 bytes (968 MiB) / 2977955840 bytes (2840 MiB) up to 12884901888 bytes (12288 MiB)     CPUs: 12     Processor Vendor: AuthenticAMD     Processor Name: AMD Ryzen 5 3600 6-Core Processor                   Identifier: AuthenticAMD Family 23 Model 113 Stepping 0     Microarchitecture: Zen 2     Frequency (GHz): 3.60     Number of physical packages: 1     Number of physical CPUs: 6     Number of logical CPUs: 12     Graphics card #0 name: Radeon RX 570 Series     Graphics card #0 vendor: Advanced Micro Devices, Inc. (0x1002)     Graphics card #0 VRAM (MB): 4095.00     Graphics card #0 deviceId: 0x67df     Graphics card #0 versionInfo: DriverVersion=31.0.12027.9000     Memory slot #0 capacity (MB): 8192.00     Memory slot #0 clockSpeed (GHz): 3.00     Memory slot #0 type: DDR4     Memory slot #1 capacity (MB): 8192.00     Memory slot #1 clockSpeed (GHz): 3.00     Memory slot #1 type: DDR4     Virtual memory max (MB): 28113.59     Virtual memory used (MB): 15054.18     Swap memory total (MB): 11776.00     Swap memory used (MB): 61.59     JVM Flags: 4 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx12288m -Xms256m     Server Running: true     Player Count: 0 / 8; []     Data Packs: vanilla, mod:betterdungeons, mod:mousetweaks, mod:jei (incompatible), mod:paragon, mod:betteroceanmonuments, mod:flywheel (incompatible), mod:create, mod:createdeco (incompatible), mod:waystones (incompatible), mod:create_sa, mod:storagedrawers (incompatible), mod:yungsapi, mod:elevatorid (incompatible), mod:betterstrongholds, mod:betterdeserttemples, mod:deeperdarker, mod:balm (incompatible), mod:jeresources, mod:forge, mod:appleskin, mod:fastleafdecay, mod:bettermineshafts, mod:twilightforest (incompatible), mod:geckolib3 (incompatible), mod:essential (incompatible), mod:enchdesc (incompatible), mod:ironfurnaces (incompatible), mod:treeharvester, mod:projecte, mod:croptopia (incompatible), mod:collective, mod:controlling (incompatible), mod:justenoughprofessions, mod:inventoryhud, mod:bookshelf (incompatible), mod:xaeroworldmap, mod:elytraslot, mod:caelus (incompatible), mod:curios, mod:clumps (incompatible)     World Generation: Experimental     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'     Launched Version: forge-43.2.0     OptiFine Version: OptiFine_1.19.2_HD_U_I1     OptiFine Build: 20221213-150857     Render Distance Chunks: 2     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 3.2.0 Core Profile Context 22.20.27.09.230321     OpenGlRenderer: Radeon RX 570 Series     OpenGlVendor: ATI Technologies Inc.     CpuCount: 12     ModLauncher: 10.0.8+10.0.8+main.0ef7e830     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:          mixin-0.8.5.jar mixin PLUGINSERVICE          eventbus-6.0.3.jar eventbus PLUGINSERVICE          fmlloader-1.19.2-43.2.0.jar slf4jfixer PLUGINSERVICE          fmlloader-1.19.2-43.2.0.jar object_holder_definalize PLUGINSERVICE          fmlloader-1.19.2-43.2.0.jar runtime_enum_extender PLUGINSERVICE          fmlloader-1.19.2-43.2.0.jar capability_token_subclass PLUGINSERVICE          accesstransformers-8.0.4.jar accesstransformer PLUGINSERVICE          fmlloader-1.19.2-43.2.0.jar runtimedistcleaner PLUGINSERVICE          modlauncher-10.0.8.jar mixin TRANSFORMATIONSERVICE          modlauncher-10.0.8.jar OptiFine TRANSFORMATIONSERVICE          modlauncher-10.0.8.jar essential-loader TRANSFORMATIONSERVICE          modlauncher-10.0.8.jar fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         lowcodefml@null         kotlinforforge@3.6.0         javafml@null     Mod List:          client-1.19.2-20220805.130853-srg.jar             |Minecraft                     |minecraft                     |1.19.2              |DONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         elytraslot-forge-6.1.0+1.19.2.jar                 |Elytra Slot                   |elytraslot                    |6.1.0+1.19.2        |DONE      |Manifest: NOSIGNATURE         YungsBetterDungeons-1.19.2-Forge-3.2.2.jar        |YUNG's Better Dungeons        |betterdungeons                |1.19.2-Forge-3.2.2  |DONE      |Manifest: NOSIGNATURE         EnchantmentDescriptions-Forge-1.19.2-13.0.14.jar  |EnchantmentDescriptions       |enchdesc                      |13.0.14             |DONE      |Manifest: eb:c4:b1:67:8b:f9:0c:db:dc:4f:01:b1:8e:61:64:39:4c:10:85:0b:a6:c4:c7:48:f0:fa:95:f2:cb:08:3a:e5         MouseTweaks-forge-mc1.19-2.23.jar                 |Mouse Tweaks                  |mousetweaks                   |2.23                |DONE      |Manifest: NOSIGNATURE         ironfurnaces-1.19.2-3.6.5.jar                     |Iron Furnaces                 |ironfurnaces                  |3.6.5               |DONE      |Manifest: NOSIGNATURE         treeharvester-1.19.2-8.0.jar                      |Tree Harvester                |treeharvester                 |8.0                 |DONE      |Manifest: NOSIGNATURE         jei-1.19.2-forge-11.6.0.1013.jar                  |Just Enough Items             |jei                           |11.6.0.1013         |DONE      |Manifest: NOSIGNATURE         paragon-forge-3.0.2-1.19x.jar                     |Paragon                       |paragon                       |3.0.2               |DONE      |Manifest: NOSIGNATURE         YungsBetterOceanMonuments-1.19.2-Forge-2.1.0.jar  |YUNG's Better Ocean Monuments |betteroceanmonuments          |1.19.2-Forge-2.1.0  |DONE      |Manifest: NOSIGNATURE         ProjectE-1.19.2-PE1.0.1B.jar                      |ProjectE                      |projecte                      |1.0.1B              |DONE      |Manifest: NOSIGNATURE         caelus-forge-1.19.2-3.0.0.6.jar                   |Caelus API                    |caelus                        |1.19.2-3.0.0.6      |DONE      |Manifest: NOSIGNATURE         curios-forge-1.19.2-5.1.3.0.jar                   |Curios API                    |curios                        |1.19.2-5.1.3.0      |DONE      |Manifest: NOSIGNATURE         flywheel-forge-1.19.2-0.6.8.a-14.jar              |Flywheel                      |flywheel                      |0.6.8.a-14          |DONE      |Manifest: NOSIGNATURE         create-1.19.2-0.5.0.i.jar                         |Create                        |create                        |0.5.0.i             |DONE      |Manifest: NOSIGNATURE         createdeco-1.2.12-1.19.2.jar                      |Create Deco                   |createdeco                    |1.2.12-1.19.2       |DONE      |Manifest: NOSIGNATURE         waystones-forge-1.19.2-11.3.1.jar                 |Waystones                     |waystones                     |11.3.1              |DONE      |Manifest: NOSIGNATURE         Croptopia-1.19.2-FORGE-2.2.2.jar                  |Croptopia                     |croptopia                     |2.2.2               |DONE      |Manifest: NOSIGNATURE         create-stuff-additions1.19.2_v2.0.2b.jar          |Create Stuff & Additions      |create_sa                     |2.0.2               |DONE      |Manifest: NOSIGNATURE         collective-1.19.2-6.53.jar                        |Collective                    |collective                    |6.53                |DONE      |Manifest: NOSIGNATURE         Clumps-forge-1.19.2-9.0.0+14.jar                  |Clumps                        |clumps                        |9.0.0+14            |DONE      |Manifest: NOSIGNATURE         XaerosWorldMap_1.29.2_Forge_1.19.1.jar            |Xaero's World Map             |xaeroworldmap                 |1.29.2              |DONE      |Manifest: NOSIGNATURE         Controlling-forge-1.19.2-10.0+7.jar               |Controlling                   |controlling                   |10.0+7              |DONE      |Manifest: NOSIGNATURE         JustEnoughProfessions-forge-1.19.2-2.0.2.jar      |Just Enough Professions (JEP) |justenoughprofessions         |2.0.2               |DONE      |Manifest: NOSIGNATURE         StorageDrawers-1.19-11.1.2.jar                    |Storage Drawers               |storagedrawers                |11.1.2              |DONE      |Manifest: NOSIGNATURE         YungsApi-1.19.2-Forge-3.8.9.jar                   |YUNG's API                    |yungsapi                      |1.19.2-Forge-3.8.9  |DONE      |Manifest: NOSIGNATURE         elevatorid-1.19.2-1.8.9.jar                       |Elevator Mod                  |elevatorid                    |1.19.2-1.8.9        |DONE      |Manifest: NOSIGNATURE         invhud.forge.1.19-3.4.7.jar                       |Inventory HUD+(Forge edition) |inventoryhud                  |3.4.7               |DONE      |Manifest: NOSIGNATURE         YungsBetterStrongholds-1.19.2-Forge-3.2.0.jar     |YUNG's Better Strongholds     |betterstrongholds             |1.19.2-Forge-3.2.0  |DONE      |Manifest: NOSIGNATURE         Bookshelf-Forge-1.19.2-16.2.18.jar                |Bookshelf                     |bookshelf                     |16.2.18             |DONE      |Manifest: eb:c4:b1:67:8b:f9:0c:db:dc:4f:01:b1:8e:61:64:39:4c:10:85:0b:a6:c4:c7:48:f0:fa:95:f2:cb:08:3a:e5         YungsBetterDesertTemples-1.19.2-Forge-2.2.2.jar   |YUNG's Better Desert Temples  |betterdeserttemples           |1.19.2-Forge-2.2.2  |DONE      |Manifest: NOSIGNATURE         deeperdarker-forge-1.1.6-forge.jar                |Deeper and Darker             |deeperdarker                  |1.1.6               |DONE      |Manifest: NOSIGNATURE         balm-forge-1.19.2-4.5.7.jar                       |Balm                          |balm                          |4.5.7               |DONE      |Manifest: NOSIGNATURE         JustEnoughResources-1.19.2-1.2.2.200.jar          |Just Enough Resources         |jeresources                   |1.2.2.200           |DONE      |Manifest: NOSIGNATURE         forge-1.19.2-43.2.0-universal.jar                 |Forge                         |forge                         |43.2.0              |DONE      |Manifest: 84:ce:76:e8:45:35:e4:0e:63:86:df:47:59:80:0f:67:6c:c1:5f:6e:5f:4d:b3:54:47:1a:9f:7f:ed:5e:f2:90         appleskin-forge-mc1.19-2.4.2.jar                  |AppleSkin                     |appleskin                     |2.4.2+mc1.19        |DONE      |Manifest: NOSIGNATURE         FastLeafDecay-30.jar                              |FastLeafDecay                 |fastleafdecay                 |30                  |DONE      |Manifest: NOSIGNATURE         YungsBetterMineshafts-1.19.2-Forge-3.2.0.jar      |YUNG's Better Mineshafts      |bettermineshafts              |1.19.2-Forge-3.2.0  |DONE      |Manifest: NOSIGNATURE         twilightforest-1.19.2-4.2.1518-universal.jar      |The Twilight Forest           |twilightforest                |4.2.1518            |DONE      |Manifest: NOSIGNATURE         geckolib-forge-1.19-3.1.40.jar                    |GeckoLib                      |geckolib3                     |3.1.40              |DONE      |Manifest: NOSIGNATURE         Essential (forge_1.19.2).jar                      |Essential                     |essential                     |12135+deploy-staging|DONE      |Manifest: NOSIGNATURE     Flywheel Backend: GL33 Instanced Arrays     Crash Report UUID: 3ae29fd2-576c-4551-8170-18f8e716e3fd     FML: 43.2     Forge: net.minecraftforge:43.2.0 Does anyone know hot to solve this problem?  
    • Issue with the player skills mod. Looks like it needs the KubeJS mod installed?
  • Topics

×
×
  • Create New...

Important Information

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