Heltrato Posted December 5, 2013 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
TheGreyGhost Posted December 5, 2013 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
Heltrato Posted December 5, 2013 Author 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
GotoLink Posted December 5, 2013 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
Recommended Posts
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.