Jump to content

Recommended Posts

Posted

Override the onItemUse() method in your Item... It will give you coordinates and a world object...

Then just break the blocks around the item

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

1. Learn Java, if you don't know it already

 

2. Do what Busti said.

 

3. Once you have the block coordinates, use World#destroyBlock(x, y, z, true/false) to destroy the block. It is called "func_147480_a" in 1.7.2, if that's the version you are using.

 

4. If you want to destroy more than one block, destroy the blocks +/- 1 each from x and z to get your 3x3 pattern, as in (x + 1, y, z), (x + 1, y, z + 1), (x - 1, y, z - 1) <-- that's one row, you need three

Posted

@Override
    public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) {
        for (int ix = -1; x < 2; x++) {
            for (int iy = -1; x < 2; x++) {
                for (int iz = -1; x < 2; x++) {
                    //Do all the block break stuff...
                    world.setBlock(x+ix, y+iy, z+iz, Blocks.air); //This will just delete the blocks in a 3x3 area around the broken block but it won't drop anything.
                }
            }
        }
    }

 

EDIT: @coolAlias Oh I haven't noticed the destroyBlock method in World...

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted
  On 4/4/2014 at 11:48 AM, Busti said:

EDIT: @coolAlias Oh I haven't noticed the destroyBlock method in World...

Did you see my note? If you are working in 1.7.2, "destroyBlock" is called "func_147480_a".

 

The final boolean parameter determines whether the block will drop items, so if you pass true, you can destroy the blocks and get the drops, or false to just destroy the blocks. Using the destroyBlock (a.k.a func_147480_a in 1.7.2) will also automatically give you a sound and particle effects.

Posted
  On 4/4/2014 at 1:26 PM, Fergoman007 said:

Where exactly would I put the onBlockDestroyedByPlayer method

You don't, unless you are making a custom Block instead of an Item, but you're making a Hammer, right? Use what Busti suggested earlier, the onItemUse method in the Item class. The example with onBlockDestroyedByPlayer was likely just some code he had sitting around to demonstrate how to break all the blocks in a 3x3 area using "for" loops, but that's not the method you want.

Posted

You could also use the onBlockDestroyed() method wich is called when a Block is broken by the Item and not when the Item is Used (right clicked...)

Your full code would be:

@Override
    public boolean onBlockDestroyed(ItemStack item, World world, Block destroyedBlock, int x, int y, int z, EntityLivingBase entity) {
        for (int ix = -1; x < 2; x++) {
            for (int iy = -1; x < 2; x++) {
                for (int iz = -1; x < 2; x++) {
                    world.func_147480_a(x+ix, y+iy, z+iz, true);
                }
            }
        }
        return true;
    }

 

You could also damage the ItemStack after that happens...

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted
  On 4/4/2014 at 2:40 PM, Busti said:

You could also use the onBlockDestroyed() method wich is called when a Block is broken by the Item and not when the Item is Used (right clicked...)

Your full code would be:

@Override
    public boolean onBlockDestroyed(ItemStack item, World world, Block destroyedBlock, int x, int y, int z, EntityLivingBase entity) {
        for (int ix = -1; x < 2; x++) {
            for (int iy = -1; x < 2; x++) {
                for (int iz = -1; x < 2; x++) {
                    world.func_147480_a(x+ix, y+iy, z+iz, true);
                }
            }
        }
        return true;
    }

 

You could also damage the ItemStack after that happens...

Oh right, derp... forgot there is also that method in Item! Lol, sorry about that. @OP just listen to Busti, he knows what's up.

Posted

@Fergoman, instead of asking other people to write all your code for you, you'll only learn modding by trying things.  People here then will be happy to help you out.  But you need to show what you've tried.

 

If you want to make a special hammer, can you show your code so far?  Even if the hammer doesn't do the 3x3 block damage yet, show what you have and what you've tried.

 

Some of the things you'll need to do before getting to the breaking part:

- create and register your hammer item class, either as an extension of vanilla hammer or depending on how much different you want it to be an extension of a generic tool class.

- make sure it works as a regular hammer -- is it registered, breaking blocks normally, does it show up in the creative tab you want, does it have the right model and texture you want, does it have the right sounds you want?

- create and register the crafting recipe to make it.

- make sure the crafting recipe works

 

Have you done all that already?

 

Only after all the above works, should you be trying to make it do special stuff like the 3x3 destruction.  And usually, if you have all the above working, it will be pretty obvious what needs to be modified (i.e. find the method activated when you break blocks normally and then modify that) -- in this case the onBlockDestroyed() method looks promising as indicated by Busti.

 

So can you post your code you've got so far (even if it only works like vanilla hammer so far) so we can better help you?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

ok this is what i have tried

 

this has not worked

 

public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz)
    {
        boolean isCobble =  world.getBlock(x, y, z) == Blocks.cobblestone;
        boolean isStone = world.getBlock(x, y, z) == Blocks.stone;
        boolean isStoneBrick = world.getBlock(x, y, z) == Blocks.stonebrick;
        if(isCobble || isStone || isStoneBrick){

            for (int ix = -1; x < 2; x++) {
                for (int iy = -1; x < 2; x++) {
                    for (int iz = -1; x < 2; x++) {
                        world.func_147480_a(x + ix, y + iy, z + iz, true);
                    }
                }
            }
            return true;
        }
        else
        {
            System.out.println("[FergoTools] False");
            return false;
        }
    }

Posted

what i meant was that it is breaking two sets of 3x3 on the x/z

 

public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase elb)
    {
        // Vanilla Blocks
        boolean isCobble =  world.getBlock(x, y, z) == Blocks.cobblestone;
        boolean isStone = world.getBlock(x, y, z) == Blocks.stone;
        boolean isStoneBrick = world.getBlock(x, y, z) == Blocks.stonebrick;
        boolean isSandtone = world.getBlock(x, y, z) == Blocks.sandstone;

        boolean isOreExperience = world.getBlock(x, y, z) == ModBlocks.oreExperience;
        boolean isOreObsidian = world.getBlock(x, y, z) == ModBlocks.oreObsidian;
        boolean isOreEmeraldCrystal = world.getBlock(x, y, z) == ModBlocks.oreEmeraldCrystal;
        boolean isOreLapisCrystal = world.getBlock(x, y, z) == ModBlocks.oreLapisCrystal;
        boolean isOreBronze = world.getBlock(x, y, z) == ModBlocks.oreBronze;
        boolean isOreAdamantium = world.getBlock(x, y, z) == ModBlocks.oreAdamantium;

        boolean[] vanillaBlocks = new boolean[]{isCobble, isStone, isStoneBrick, isSandtone};
        boolean[] fergoToolsOres = new boolean[]{isOreExperience, isOreObsidian, isOreEmeraldCrystal, isOreLapisCrystal, isOreBronze, isOreAdamantium};


        if(vanillaBlocks[0] || vanillaBlocks[1] || vanillaBlocks[2] || fergoToolsOres[0] || fergoToolsOres[1] || fergoToolsOres[2] || fergoToolsOres[3] || fergoToolsOres[4] || fergoToolsOres[5] || world.getBlock(x, y, z) != Blocks.bedrock)
        {
            for(int ix = -1; ix < 2; ++ix)
            {
                for (int iy = -1; iy < 2; ++iy)
                {
                    for (int iz = -1; iz < 2; ++iz)
                    {
                        world.func_147480_a(x + ix, y + iy, z + iz, true);
                        stack.setItemDamage(stack.getItemDamage() - 9);
                    }
                }
            }

            return true;
        }
        else
        {
            return false;
        }
    }

 

Edit: added Code to Reply

Posted

Yes, the way you have your code it will break one 3x3 layer where you strike, plus one 3x3 layer both above and below that position, but the one above you'd only notice if you hit next to a wall or something. That's caused by the 'y' for loop that I pointed out earlier.

 

One other point: you should only add/destroy blocks on the server (when the world is not remote), otherwise you can get ghost blocks - ones that either look like they exist but don't (when you add on the client), or are invisible but still block your path (when destroyed on the client).

Posted
  On 4/5/2014 at 8:48 AM, Fergoman007 said:

it played around with it a bit and still getting the the extra set of 3x3

 

Edit corrected spelling

Did you try removing the y loop like I suggested? Like this:

for(int ix = -1; ix < 2; ++ix) {
        for (int iz = -1; iz < 2; ++iz) {
                world.func_147480_a(x + ix, y, z + iz, true);
                stack.setItemDamage(stack.getItemDamage() - 9);
         }
}

Posted

@Fergoman

 

Your current code breaks a 3x3x3 cube of blocks, but sounds like you only want to break one vertical layer in a 3x3 area?  Like CoolAlias says, you don't need three loops in your code then, you just want to loop in the two dimensions you want the break to occur. 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Honestly I do not understand why anyone is helping this person. He/She clearly does not know Java or doesn't know how to mod or is lazy and should figure this simple task out him/her self. The rules for the modders support also say that you should know Java to post. If you just give him/her the code he/she will learn nothing and this part of his/her mod would be your work, not theirs. I ask of everyone to please not responding to people who what other people to do all the work for them because it's a waste of time and they will get the idea that they can get other people to do work for them.

Don't be afraid to ask question when modding, there are no stupid question! Unless you don't know java then all your questions are stupid!

Posted
  On 4/5/2014 at 9:08 PM, Mecblader said:

Honestly I do not understand why anyone is helping this person. He/She clearly does not know Java or doesn't know how to mod or is lazy and should figure this simple task out him/her self. The rules for the modders support also say that you should know Java to post. If you just give him/her the code he/she will learn nothing and this part of his/her mod would be your work, not theirs. I ask of everyone to please not responding to people who what other people to do all the work for them because it's a waste of time and they will get the idea that they can get other people to do work for them.

I say its fine if we help him through this, as long as we don't give him code directly. He will at least learn something that way.

I like to make mods, just like you. Here's one worth checking out

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

    • I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com   I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com
    • There is an issue with Modular Force Field System (mffs) Remove it or try other builds
    • I never imagined I would be writing this kind of testimony, but I feel it’s important to share my experience with Malice Cyber Recovery and how they helped me recover $230,000 I lost to crypto scammers. A few months ago, I got involved in a crypto investment opportunity that seemed legitimate at first. The scammers were incredibly convincing. They showed me impressive returns, sent regular updates, and even gave me access to what looked like a real trading platform. I was initially cautious, but after seeing the returns, I began to invest more, ultimately transferring over $230,000. Unfortunately, after a few weeks, when I tried to withdraw my funds, I found that the platform had disappeared, and I could no longer contact anyone involved. It was clear I had been scammed, and I felt completely helpless. For weeks, I tried everything to get my money back—contacting the authorities, reaching out to the platform’s so-called support team (who of course were unreachable), and trying to trace the transactions myself. But everything led to dead ends. The more I researched, the more I realized just how hard it was to recover stolen crypto. I began to lose hope. That’s when I came across Malice Cyber Recovery. At first, I was skeptical. Could they really help me recover my funds after everything I had been through? I decided to reach out anyway, just to see if they could offer any guidance. From the very first conversation, their team was not only professional but also deeply empathetic. They understood exactly how I was feeling and immediately made it clear that they were dedicated to helping me recover my lost funds. Malice Cyber Recovery’s team got to work quickly. They walked me through every step of the process, explaining the methods they would use to track down my stolen crypto. Their knowledge of blockchain technology and how to trace crypto transactions was incredibly impressive. They didn’t just give me vague promises they showed me the action they were taking and the progress they were making, which gave me hope that my money wasn’t gone forever. One of the most reassuring aspects of working with Malice Cyber Recovery was their transparency. They kept me updated regularly, letting me know what they were doing, what obstacles they encountered, and how they were overcoming them. It wasn’t an easy process; tracing funds through blockchain and dealing with scammers who hide behind fake identities and complex networks is incredibly difficult. But Malice Cyber Recovery’s team was relentless. They used advanced tools and techniques to trace the flow of my funds, and within just a few weeks, they managed to locate a significant portion of my lost funds. I couldn’t believe it when they informed me that they had successfully recovered a large chunk of my money. I never thought I’d see that $230,000 again. The recovery process wasn’t instantaneous it  took time, patience, and persistence but Malice Cyber Recovery delivered on their promise.  
    • Almost, just the java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui and if that doesn't work, try java --version
    • What so just copy and paste " java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui Pause >nul " into a cmd terminal? If that's what you mean, nothing happens
  • Topics

×
×
  • Create New...

Important Information

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