Jump to content

Recommended Posts

Posted

I made a custom bow, with its own custom arrow and arrow entity. I made an enchantment that can be put on any bow, and I know a way to make my custom arrow explode (in the custom arrow entity class). I have see in the bow class that it tests for enchantments there, and if it has an enchantment like power it will tell the EntityArrow.class to make it damage more. Is there a way I can check if it has my enchantment, and then if it does change this:

if (this.inGround)
        {
            int j = this.worldObj.getBlockMetadata(this.field_145791_d,       this.field_145792_e, this.field_145789_f);

        if (block == this.field_145790_g && j == this.inData)
        {
            ++this.ticksInGround;

            if (this.ticksInGround == 1200) //set to 1 for explosion
            {
                this.setDead();
              //this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 5.0F, true);
            }
        }
        else
        {
            this.inGround = false;
            this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
            this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
            this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
            this.ticksInGround = 0;
            this.ticksInAir = 0;
        }

 

to the parameters needed to make the arrow explode? Thank you for your help, I am new to modding!

 

Posted

I don't really see your truble. If you want to make arrow have specific effect depending on what kind of bow was it shot from you can simply pass argument into arrow entity the moment you shoot it (when you spawn entity to world). What is your problem? Checking enchantment? Passing argument? Making boom? Synchronizing server with client? Maybe reading NBT from bow (your ench)?

1.7.10 is no longer supported by forge, you are on your own.

Posted

Nevermind, I thought about it and wrote some code that should work, but doesn't. I basically made a new boolean in my bow class called explosive and set it to false. Then I told it to check if there was my enchantment on the bow, and if so, set explosive to true. Then, in my arrow entity, I told it to check if explosive was set to true, and if so, explode when it hits the ground. If it isn't true it is supposed to act like a normal arrow. My problem is that even when the bow doesn't have my enchantment, the arrow explodes. Can anyone tell me what I am doing wrong? Here is my custom arrow: http://pastebin.com/FDLLh5GM Here is my bow class: http://pastebin.com/3AEd1wsj And here is my main registry class where I register the enchantment: http://pastebin.com/XwWLbcv4 Tell me if you need more code than this, Thank you for any help provided!

Posted

Your problem is actually your lack of knowledge about java, cmon man - learn something, don't code blindly. :P

 

As to problem:

1. Your enchantment can't be saved in bow instance, there is only one item instance per game so making boolean inside bow class will cause it to be shared between all bows. What you need to use is NBT in ItemStack.

http://www.minecraftforge.net/wiki/Creating_NBT_for_items

 

2. When you shoot arrow you need to read enchantment value from bow's NBT and pass it into arrow entity.

Pseudocode:

ArrowEntity arrow = new arrow.... bla bla

arrow.setMyEnch(getBooleanFromMyBowsNBT) // which will set it to true/false

arrow.spawnEntityInWorld...

 

3. When you are extending some class, you don't need to copy everything what is inside, that's why there is inheritance (extends).

1.7.10 is no longer supported by forge, you are on your own.

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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