Jump to content

Recommended Posts

Posted (edited)

I have an item tool that extends ItemPickaxe. Every method I override gets called twice. No matter which method it is. For example

override def onBlockDestroyed (stack: ItemStack, worldIn: World, state: IBlockState, pos: BlockPos, entityLiving: EntityLivingBase): Boolean = {
    System.out.println ("Block destroyed")
    return true;
  }

 

It doesn't matter if I return true or false. Neither it matters if I call super. It always gets called twice. This is Scala, but it also happens if I use Java. I take it the language doesn't matter. If I do

override def onItemUse(player: EntityPlayer, worldIn: World, pos: BlockPos, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): EnumActionResult = {
      System.out.println ("Item used")
      return EnumActionResult.SUCCESS
  }

 

It also happens. Regardless of returning EnumActionResult.SUCCESS or EnumActionResult.FAIL or calling super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ). I get double code execution.

 

All overridden methods are called twice. Is there any fix for this?

 

 

Edited by ctbe
Language code syntax highlighter change
Posted

Thanks.

 

If I do

override def onBlockDestroyed(stack: ItemStack, worldIn: World, state: IBlockState, pos: BlockPos, entityLiving: EntityLivingBase): Boolean = {
	if (worldIn.isRemote) {
		System.out.println("Block destroyed")
		return true
	}
    return false
  }

 

Then it gets executed only once. Fixing my original problem. But now I have another doubt. Does this means that if someone installs my mod on a server, that println in this specific code or whatever is inside will not execute? I ask because according to https://mcforge.readthedocs.io/en/latest/concepts/sides/

  Quote

It follows that the physical server will always contain false in this field...

Expand  

 

And the definition of physical server is

  Quote

Often known as the dedicated server, the physical server is the entire program that runs whenever you launch any sort of minecraft_server.jar that does not bring up a playable GUI.

Expand  

 

I'm not sure if I should post a new thread for this other question that arose connected to my original problem since my original problem is solved.

Posted
  Quote
/**
 * True if the world is a 'slave' client; changes will not be saved or propagated from this world. For example,
 * server worlds have this set to false, client worlds have this set to true.
 */
Expand  

the javadoc for isRemote

if you want it on the server side you need to do it like so    if (!worldIn.isRemote)

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

    • A few months ago, I was approached online by a so-called investment broker. Everything looked professional — flashy websites, fake but convincing reviews, even video calls with people who seemed legitimate. They promised unbelievable returns on Bitcoin investments, and I, eager to grow my crypto holdings, fell for it. Over a few weeks, I transferred Bitcoin worth around $360,000 to what I thought was a secured investment wallet. The “broker” kept assuring me my money was growing, even showing fake dashboards with fabricated profits. But when I tried to withdraw my funds, they demanded additional fees — taxes, account, activation, and release charges. That’s when the truth hit me I had been scammed. Devastated, I started searching for solutions. But then, a glimmer of hope. A cybersecurity contact muttered Try Dexdert Net Recovery. They hunt crypto ghosts. Dexdert Net had real testimonials, detailed explanations of their process, and most importantly, they didn’t ask for any suspicious upfront fees. After contacting them, their team patiently walked me through the steps gathering all evidence of the scam, tracking the Bitcoin transactions on the blockchain, and using legal recovery channels and cyber forensic methods. They kept me updated at every stage. 4 days later, I got the email I’ll never forget: Funds Recovered. Dexdert Net Recovery successfully trace and retrieve the entire $360,000 worth of Bitcoin from the scammer’s wallets. Thanks to Dexdert Net Pro Recovery, not only did I reclaim my lost Bitcoin, but I also regained a sense of justice — and a serious lesson learned. If you’re ever in a situation like I was, know this: there’s hope, and there are real experts out there who can help. Dexdert Net Recovery proved it to me. CONTACT DEXDERT NET RECOVERY VIA INFORMATION BELOW   Telegram: (@Dexdertprorecovery)      
    • So I just try to remove mods and see what works?
    • Hello, I want to change some things about a specific mod. I made some small mods for myself before, but I don't know how to use other mods as a dependencie and add the repositories. My build.gradle file looks something like this:   repositories { flatDir { dirs 'libs' } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation fg.deobf("libs:create-1.20.1:0.5.1.f") implementation fg.deobf("libs:create-stuff-additions1.20.1:2.0.4a") } I have the folder libs in my root folder. If I start the gradlew.exe, I get the following output: > Configure project : Java: 17.0.15, JVM: 17.0.15+6 (Eclipse Adoptium), Arch: amd64 files(...) dependencies are not deobfuscated. Use a flatDir repository instead: https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver Cannot deobfuscate dependency of type DefaultSelfResolvingDependency_Decorated, using obfuscated version! files(...) dependencies are not deobfuscated. Use a flatDir repository instead: https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver Cannot deobfuscate dependency of type DefaultSelfResolvingDependency_Decorated, using obfuscated version! I don't know why this warning occurs or how to fix it. If I try to build the whole thing, I get the same message, but this time as an error and the build process crashes. I looked at the gradle dependencies website (https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html), but everything I tried did not work.   I use the Minecaft version 1.20.1 and the Forge version 47.2.17. Both mods don't have other dependencies and work perfectly fine if I start the game normaly.   Can someone explain to me why it does not work and/or where I can get help? Something like a documentation would be enough.
    • im just going to play without shaders(my friends will be dissapointed)
    • crashed the game // Embeddium instance tainted by mods: [oculus] // Please do not reach out for Embeddium support without removing these mods first. // ------- // Why did you do that? flywheel is needed for oculus but when i go into mc it then says sodium is 0.5.3(rubidum fork of sodium ported to forge)
  • Topics

×
×
  • Create New...

Important Information

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