Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

My entity doesn't explode if it hits a block while a say it has to ,, am i using the wrong if statement?

 

package invizzble.mods.nc.entities.projectiles;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.effect.EntityWeatherEffect;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityStaffODarknessAmmo extends EntityThrowable{

    public EntityStaffODarknessAmmo(World par1World)
    {
        super(par1World);
    }
    
    public EntityStaffODarknessAmmo(World par1World,EntityLivingBase par2EntityLivingBase) {
        super(par1World, par2EntityLivingBase);

    }
    
    private int explosionRadius= 3;
    
    @Override
    protected void onImpact(MovingObjectPosition par1Movingobjectposition) {
        
        if (par1Movingobjectposition.entityHit != null)
        {
            byte b0 = 30;

            par1Movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
            this.setDead();
        }
        if(!this.worldObj.isRemote){ // i found the !this.worldObj.isRemote int the entityEgg and the EntitySnowball, why doesn't it explode?
            this.worldObj.createExplosion(this, this.chunkCoordX, this.chunkCoordY, this.chunkCoordZ, explosionRadius, true);
        }
        
        
    }
    
    @Override
    protected float getGravityVelocity()
    {
        return 0F;
    }

}

this.worldObj.createExplosion(this, this.chunkCoordX, this.chunkCoordY, this.chunkCoordZ, explosionRadius, true);

Surely you want .posX, .posY, and .posZ?

You were also telling the entity to die before it even checked that wether it was client or server... You are supposed to this.setDead(); in the if(!this.worldObj.isRemote) statement

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.