Jump to content

[1.14.4] onBlockActivated not firing when sneaking + set to allow in event


JayZX535

Recommended Posts

Hey all,

Got a bit of a stumper.  I have a custom block that's supposed to run an interaction when clicked with a certain item.  That's fine and great, I got that part working.  However, because I'm using the onBlockActivated method, it doesn't fire when shift clicking  (which I want it to do because I want it to activate a different function when shift clicked with that item).  I looked it up and saw that this is an intended function, and that I need to override the PlayerInteractEvent.RightClickBlock event to make it allow the click.  Which I did.  Except no matter what I try, I can't get it to actually register the onBlockActivated event.  It works as intended with a normal click.  It's just shift clicking that's not working.  My code is as follows:

@SubscribeEvent
public static void playerRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
       	if (event.getWorld().getBlockState(event.getPos()).getBlock() instanceof WCFoodBowlBlock)
       	{
       		if (WCFoodBowlTileEntity.isValidFood(event.getItemStack()))
       		{
       			System.out.println("Right Clicked on food bowl with valid item");
       			event.setUseBlock(Event.Result.ALLOW);
       		}
       	}
    }

That print statement does fire.  So the event is getting caught and running properly, and none of those if statements are throwing it off.  I can only assume I either got the wrong event somehow, am using the wrong function to make the onBlockActivated method fire even while sneaking, or Forge itself has a bug.  I'm using the latest stable version so if so, it must be something pretty recent...

Thank you for your time, and have a great day!

Link to comment
Share on other sites

Bump.  Issue still persists, not sure what's causing it.  Also worth noting, I'm checking if the function is running via a print statement in onBlockActivated within my block.  The ones here in the event run, but the one in that function does not.  Since there's no if statements or anything to interfere with onBlockActivated, I assume this issue has to be with the event either not being sent properly, or with me needing to use a different method or something.  Does PlayerInteractEvent.RightClickBlock actually call onBlockActivated?  Or do I have the wrong event/method?

Link to comment
Share on other sites

In this case, you can forget about Block#onBlockActivated and implement the entire behavior in the RightClickBlock event subscriber.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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

    • KLIK DISINI UNTUK DAFTAR       WsoSlot88 Situs Bandar Togel Terpercaya dengan Hadiah 4D Tertinggi yaitu 10 juta WsoSlot88 adalah BO Agen Togel Terpercaya yang sudah berdiri sejak tahun 2016 yang terkenal dengan proses transaksi deposit dan withdraw yang super cepat serta jaminan pembayaran untuk berapa pun kemenangan yang didapat oleh para member nya. Jadi anda para pecinta game Togel Online dan Slot Gacor tidak perlu takut atau ragu bermain di BO WsoSlot88, karena jika anda Jackpot Paus berapapun, pasti akan dibayar lunas oleh WsoSlot88.   67 Pasaran Togel yang paling dicari oleh para pecinta Togel Online yaitu : - Pasaran Togel Hongkong (HK) - Pasaran Togel Sydney (SDY) - Pasaran Togel Singapore (SGP) - Pasaran Togel Cambodia (CM) - Pasaran Togel Taiwan (TW) - Pasaran Togel Jepang (JPN) - Pasaran Togel China (CN) - Pasaran Togel Chicago - Pasaran Togel Malaysia - Pasaran Togel Vegas - Pasaran Togel Miami - Pasaran Togel Vietnam - Pasaran Togel Carolina - Pasaran Togel Bullseye - Dan masih banyak pasaran togel terkenal lainnya
    • I can play my server & others can connect to it but it cannot load certain chunks & times out because it's bottlenecked by the default 4GB. I know this to be the case because when copy+pastaing the exact server world into curseforge singleplayer with 8G+, all the heavy chunks load in fine.  I have JavaSDK 17.0.9 x64-bit & reinstalled twice already as well as trying with Java 8 also installed & without.  I tried using: java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.20.1-47.2.0/win_args.txt %* pause but all that gives me is: Error: Could not find or load main class java Caused by: java.lang.ClassNotFoundException: java  Any ideas or help would be appreciate. 
    • KLIK DISINI UNTUK DAFTAR     Situs Slot Thailand Terpercaya adalah situs yang menyediakan permainan slot online dengan tema dan layanan yang sesuai dengan kebutuhan dan preferensi pemain asal Thailand. Situs-situs ini biasanya menawarkan permainan slot dengan server khusus yang berasal dari Thailand, yang diklaim memiliki tingkat kemenangan yang tinggi dan mudah mendapatkan jackpot. Beberapa situs juga menyediakan permainan slot dengan server dari negara lain, seperti Rusia dan Singapura, yang juga populer di kalangan pemain Thailand.  
    • I was trying to use viaforge (latest version) on forge 1.20.2 and then it crashed showing exit code 1 heres the log : 04Dec2023 11:40:52.058] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Goldenretriver, --version, 1.16.5-forge-36.2.34, --gameDir, C:\Users\rashr\AppData\Roaming\.minecraft, --assetsDir, C:\Users\rashr\AppData\Roaming\.minecraft\assets, --assetIndex, 1.16, --uuid, a688ba406e4f4635a428d7555a467474, --accessToken, ????????, --userType, msa, --versionType, release, --launchTarget, fmlclient, --fml.forgeVersion, 36.2.34, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550] [04Dec2023 11:40:52.061] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_51 by Oracle Corporation [04Dec2023 11:40:52.071] [main/DEBUG] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Found launch services [minecraft,testharness,fmlclient,fmlserver] [04Dec2023 11:40:52.075] [main/WARN] [cpw.mods.modlauncher.SecureJarHandler/]: LEGACY JDK DETECTED, SECURED JAR HANDLING DISABLED [04Dec2023 11:40:52.082] [main/DEBUG] [cpw.mods.modlauncher.NameMappingServiceHandler/MODLAUNCHER]: Found naming services : [] [04Dec2023 11:40:52.118] [main/DEBUG] [cpw.mods.modlauncher.LaunchPluginHandler/MODLAUNCHER]: Found launch plugins: [mixin,eventbus,object_holder_definalize,runtime_enum_extender,accesstransformer,capability_inject_definalize,runtimedistcleaner] [04Dec2023 11:40:52.125] [main/DEBUG] [cpw.mods.modlauncher.TransformationServicesHandler/MODLAUNCHER]: Discovering transformation services [04Dec2023 11:40:52.132] [main/DEBUG] [cpw.mods.modlauncher.TransformationServicesHandler/MODLAUNCHER]: Found additional transformation services from discovery services: [C:\Users\rashr\AppData\Roaming\.minecraft\mods\viaforge-1.12.2-3.4.3.jar]
  • Topics

×
×
  • Create New...

Important Information

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