Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Grenade with a Blindness on Explode Help ! Please
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Heltrato

Grenade with a Blindness on Explode Help ! Please

By Heltrato, December 5, 2013 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 258 posts
Posted December 5, 2013

Hi everyone im trying to make a grenade that blinds entities in the are but

i mess with codes somehow but no luck it dont work

 

package MHF.Net.Client.Entity.Projectile;


import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import MHF.Net.Client.Item.MHFItem;

public class MHFEntityGrenadeIncenerate extends MHFEntityBombMaterial
{
    protected String BOUNCE_SOUND;
    
    static final double MAX_DISTANCE = 32D;
    static final double MIN_DISTANCE = 8D;
    static final float MAX_ANGLE = 180F;
    static final float MIN_PITCH_ANGLE = 15F;
    static final float MIN_YAW_ANGLE = 15F;
    public static final int MAX_FLASH_TIME_PLAYER = 500;
    public static final int MAX_FLASH_TIME_ENTITY = 200;

    public MHFEntityGrenadeIncenerate(World world)
    {
        super(world);
        setEntityItemStack(new ItemStack(MHFItem.MHFIncenerateBomb, 1, 0));
    }

    public MHFEntityGrenadeIncenerate(World world, double d, double d1, double d2)
    {
        super(world, d, d1, d2);
        setEntityItemStack(new ItemStack(MHFItem.MHFIncenerateBomb, 1, 0));
    }

    public MHFEntityGrenadeIncenerate(World world, EntityLivingBase entityliving)
    {
        super(world, entityliving);
        setEntityItemStack(new ItemStack(MHFItem.MHFIncenerateBomb, 1, 0));
    }

    public void onUpdate()
    {
        super.onUpdate();
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox);

        if (list.size() > 0)
        {
            Entity entity = (Entity)list.get(0);

            if (entity instanceof EntityLiving)
            {
            	((EntityLiving) entity).addPotionEffect((new PotionEffect(Potion.blindness.id, 100, 6)));
                entity.setFire(300);
                explode();
            }
        }
    }

    protected void handleBounce()
    {
        explode();
    }

    protected void explode()
    {
        if (!exploded)
        {
            exploded = true;
            worldObj.playSoundAtEntity(this, Block.glass.stepSound.getBreakSound(), (Block.glass.stepSound.getVolume() + 1.0F) / 2.0F, Block.glass.stepSound.getPitch() * 0.8F);
            int i = (int)Math.floor(posX);
            int j = (int)Math.floor(posY);
            int k = (int)Math.floor(posZ);

            for (int l = -2; l <= 2; l++)
            {
                for (int i1 = -2; i1 <= 2; i1++)
                {
                    for (int j1 = -2; j1 <= 2; j1++)
                    {
                        int k1 = Math.abs(l) + Math.abs(i1) + Math.abs(j1);

                        if (k1 <= 2 && worldObj.isAirBlock(i + l, j + i1, k + j1))
                        {
                            worldObj.setBlock(i + l, j + i1, k + j1, Block.fire.blockID);
                        }
                    }
                }
            }

            setDead();
        }
    }
}



  • Quote

Share this post


Link to post
Share on other sites

TheGreyGhost    711

TheGreyGhost

TheGreyGhost    711

  • Reality Controller
  • TheGreyGhost
  • Members
  • 711
  • 2805 posts
Posted December 5, 2013

Hi

 

I'm having a bit of trouble seeing how your code is supposed to work.

As far as I can tell, you use onUpdate to see if any living entities touch the grenade (collide with the boundingbox), and when they do, apply a blindness effect and explode the grenade.

 

Is that what you intended?  And if so, what doesn't work?

 

-TGG

  • Quote

Share this post


Link to post
Share on other sites

Heltrato    1

Heltrato

Heltrato    1

  • Diamond Finder
  • Heltrato
  • Members
  • 1
  • 258 posts
Posted December 5, 2013

So you mean that my boundingBox is whenever the entity touched the grenade that is thrown ?

 

Im kinda confuse a little but what i want is when the grenade is thrown all entities in the area that seen the grenade will be blind

  • Quote

Share this post


Link to post
Share on other sites

GotoLink    381

GotoLink

GotoLink    381

  • World Shaper
  • GotoLink
  • Members
  • 381
  • 2012 posts
Posted December 5, 2013

boundingBox is set by Entity#setSize(...).

I assume you don't want your grenade to be bigger, so I'd recommend using AxisAlignedBB#expand(double,double,double) on boundingBox.

By the way, EntityPlayer is not an EntityLiving in recent Minecraft versions, you may want to check for EntityLivingBase instead.

You will probably need a counter too, to avoid the grenade exploding in the player hands.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • solitone
      Distinguish singleplayer vs. multiplayer

      By solitone · Posted 13 minutes ago

      So doesn’t it cause the server to crash, in contrast to what Draco18s said?
    • shadowmaster530
      Unable to register Item texture can someone help?

      By shadowmaster530 · Posted 40 minutes ago

      So I am currently coding in a item and can’t get its texture to properly connect. Here is my code:   package assets.testmod.textures.items;   import com.shadowmaster.testmod.reference.Reference; import net.minecraft.item.Item; import net.minecraft.ItemStack;  import net.minecraftforge.fml.relauncher.Side;  import net.minecraftforge.fml.relauncher.SideOnly;     public class ItemSTM extends Item{      public ItemSTM(){            super();      }      @Override      public String getUnlocalizedName(){            return String.format(“item.%s%s”, Reference.MOD_ID.toLowerCase() + “:”, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));      }        @Override      public String getUnlocalizedName(ItemStack itemStack){            return String.format(“item.%s%s”, Reference.MOD_ID.toLowerCase() + “:”, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));      }        @Override      @SideOnly(Side.CLIENT)       public void registerIcons(IIconRegister iconRegister){             itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(getUnlocalizedName().indexOf(“.”) + 1);   \* This is the piece having the issue but I can’t figure out why or how to fix it *\       }      protected String getUnwrappedUnlocalizedName(String unlocalizedName){           return unlocalizedName.substring(unlocalizedName.indexOf(“.”) + 1);      } }
    • tdude0317
      Dragon Mounts:Reborn

      By tdude0317 · Posted 1 hour ago

      Hello there, I am the Lead developer for a WIP mod named Dragon Mounts:Reborn. Some of you may have heard of Dragon Mounts or Dragon mounts 2, both of which have been stopped. Dragon Mounts:Reborn is a spiritual successor  to these two mods and we are hoping to make it bigger and better. We are looking for anybody willing to help with the mod, especially coders. Please, if you have any interest joining our team, join our discord to learn more,meet the rest of us, and hopefully join us. https://discord.gg/RhgkQjp  
    • DavidM
      Distinguish singleplayer vs. multiplayer

      By DavidM · Posted 1 hour ago

      That code from the original mod is not going to work regardless of the side it is on, as spawning ItemEntity in the world must be done on the server side. However, the Minecraft class (used in your if statement) is client side only.   In your case, you might want to look at how proxies work.
    • DragonITA
      [1.14.4] Add a Tab to the Player Inventory Gui in Survival Modus

      By DragonITA · Posted 1 hour ago

      And how to make a survival tab, like a creative tab just on survival?
  • Topics

    • solitone
      4
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started 11 hours ago

    • shadowmaster530
      0
      Unable to register Item texture can someone help?

      By shadowmaster530
      Started 40 minutes ago

    • tdude0317
      0
      Dragon Mounts:Reborn

      By tdude0317
      Started 1 hour ago

    • DragonITA
      2
      [1.14.4] Add a Tab to the Player Inventory Gui in Survival Modus

      By DragonITA
      Started 9 hours ago

    • saxon564
      1
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564
      Started 2 hours ago

  • Who's Online (See full list)

    • JetCobblestone
    • vaartis
    • Cerandior
    • KittRiderTV
    • solitone
    • SerpentDagger
    • Lea9ue
    • bsrgin
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Grenade with a Blindness on Explode Help ! Please
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community