Jump to content

[1.8.9] Stopping a player from harvesting a block


blahblahbal

Recommended Posts

So I've set bedrock to breakable, but I only want it breakable with one tool. I know I have to subscribe to PlayerEvent.BreakSpeed, and I've looked at it in the source, but how do I cancel the event? (It says it's 'Cancelable')

 

And what file should I put the code for this in? I have a ModEventHandler.java, I'm assuming there?

Link to comment
Share on other sites

If I recall correctly, you set the event's newSpeed to zero to prevent the player from breaking the block (he never makes any progress). I don't think you need to cancel the event.

 

Put the event handler with its @SubscribeEvent annotation into a listener class, which may have multiple events. Your main postInit method needs to register an instance of each listener class with the bus(es) firing its event(s).

 

Example:

  @EventHandler
  public void postInit(FMLPostInitializationEvent e) {
    NethergemEventSubs ES = new NethergemEventSubs ();

    super.postInit (e);
    MinecraftForge.EVENT_BUS.register (ES);
    FMLCommonHandler.instance ().bus ().register (ES);
}

 

If you have events from multiple busses, then you could be very clever and create a separate listener class for each bus. I'm too lazy to do that, so I bundle all my events into one class and then register its instance on every possible bus until all of my events work.

 

Each registration's reflection code seems to be smart enough to pick out its own events without interference from other methods. You might even be able to nest an event handler method inside a block or item class and then register its instance with a bus.  Then your method would have field and method visibility from inside the block or item. I'll have to try that sometime to see "What could possibly go wrong?"

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Well the PlayerEvent.BreakSpeed is a Player event, so it will naturally give you the player involved.  From that you can figure out what item they're holding.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.