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.

[1.10.2] Change ground to Ice after entity hit by entity NullPoint error ...~

Featured Replies

Posted

Hello@All ..

 

everything works fine ... if i want to throw and entity on the other entity and make it explode .. it work perfectly ...

 

but if i want to hit an entity with another entity AND change the ground to ICE it wont work ... i get an error .. :S

 

hopefully someone can help me

 

EntityClass:

 

public class IceBall extends EntityThrowable
{
  public IceBall(World par1World)
  {
    super(par1World);
  }
  
  public IceBall(World par1World, EntityPlayer par3EntityPlayer)
  {
    super(par1World, par3EntityPlayer);
  }
  
  public IceBall(World par1World, double par2, double par4, double par6)
  {
    super(par1World, par2, par4, par6);
  }
  
  public int explosionRadius = 5;
  public int ticks = 300;
  
  public void onEntityUpdate()
  {
    if (this.ticks <= 0)
    {
      this.ticks = 300;
      setDead();
    }
    else
    {
      this.ticks -= 1;
    }
  }

  public int quantityDropped(Random random)
  {
      return 0; //Returns 0 item drop on destruction
  }

  public void changeToIce(BlockPos location, int radius) {
	for (int x = location.getX() - radius; x <= location.getX() + radius; x++) {
		for (int y = location.getY() - radius; y <= location.getY() + radius; y++) {
			for (int z = location.getZ() - radius; z <= location.getZ() + radius; z++) {
				BlockPos pos = new BlockPos(x, y, z);
				if (pos.distanceSq(location) <= radius) {
					IBlockState blockState = worldObj.getBlockState(pos);
					if (blockState != Blocks.AIR
							.getDefaultState()) {
						worldObj.setBlockState(pos, CustomBlocks.IceBlock1.getDefaultState());
					}
				}
			}
		}
	}
}
  
  @Override
protected void onImpact(RayTraceResult result)

{
    if (result.entityHit != null)
    {
        int i = 0;
        if (result.entityHit instanceof EntityLivingBase)
        {
            i = 150;
        }
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
        worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.8F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
    }
    for (int j = 0; j < 8; ++j)
    {
    	  this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, true);
	        changeToIce(result.getBlockPos(), 100);
    }
    if (!this.worldObj.isRemote)
    {
        this.setDead();
        worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.7F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
    }		
}
  
protected float getGravityVelocity() {
	return 0.001F;
}
}

 

ErrorLog:

---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 17.11.16 00:40
Description: Ticking entity

java.lang.Error: Unresolved compilation problem: 
The type IceBall must implement the inherited abstract method EntityThrowable.onImpact(RayTraceResult)

at DevilFruitSkills.IceBall.onImpact(IceBall.java:22)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:266)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2108)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:873)
at net.minecraft.world.World.updateEntity(World.java:2075)
at net.minecraft.world.World.updateEntities(World.java:1888)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:645)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)

Are you sure you posted the right crash report? The one you posted is an unresolved compilation problem, not a

NullPointerException

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Are you sure you posted the right crash report? The one you posted is an unresolved compilation problem, not a

NullPointerException

.

 

 

im sorry, heres the right one:

---- Minecraft Crash Report ----
// But it works on my machine.

Time: 17.11.16 00:52
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
at DevilFruitSkills.IceBall.changeToIce(IceBall.java:61)
at DevilFruitSkills.IceBall.onImpact(IceBall.java:94)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:266)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2108)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:873)
at net.minecraft.world.World.updateEntity(World.java:2075)
at net.minecraft.world.World.updateEntities(World.java:1888)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:645)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)

A

NullPointerException

is thrown when you try to access a field or call a method of a

null

value.

 

Look at line 61 of

IceBall

, which values could be

null

?

 

If you're not sure which one is

null

, set a breakpoint on that line and run Minecraft in debug mode. When the breakpoint is hit, look at the values used on line 61 and see which one is

null

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

A

NullPointerException

is thrown when you try to access a field or call a method of a

null

value.

 

Look at line 61 of

IceBall

, which values could be

null

?

 

If you're not sure which one is

null

, set a breakpoint on that line and run Minecraft in debug mode. When the breakpoint is hit, look at the values used on line 61 and see which one is

null

.

 

i will give my best

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.