Jump to content

Recommended Posts

Posted

Hello, I'm attempting to rewrite a minecraftforge method in net.minecraft.block.Block,

boolean removeBlockByPlayer(World, EntityPlayer, Int, Int, Int)

 

I start by first removing the original method with a ClassVisitor and an overloaded visitMethod that returns null.  I then try to use a MethodVisitor to rewrite the bytecode.  Unfortunately, it seems to be rewriting the net.minecraft.block.Block constructor rather than the intended function, though I have determined that removeBlockByPlayer is indeed deleted by iterating through the ClassNode.methods list.

 

My code is as follows:

 

 

  Reveal hidden contents

 

 

FML output is as follows:

 

 

  Reveal hidden contents

 

 

I apologize for any silly mistakes I may have made.  I primarily code in C/C++ and have only recently taken an interest in Minecraft modding.

Posted

In the future, use spoiler, not hidden ;)

 

Also, judging from what you're trying to do, the best way to do it would be to add a function call, rather than rewriting the entire method. You might want to have a look at the source code for my mod, which does something similar, but uses ItemInWorldManager (so it's server-side only).

 

If you want more help, PM me (I think I've worked out how to do this ASM stuff)

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

  Reveal hidden contents

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Posted

I was able to come up with a solution to my issue, and I would like to make my solution visible to this community.  It is as follows:

 

 

  Reveal hidden contents

 

 

Keepcalm, I did end up going a different direction, but I do appreciate your advice and example code.  It is always helpful to see how other programmers are accomplishing similar problems.

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



×
×
  • Create New...

Important Information

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