Jump to content

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


terraya

Recommended Posts

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)

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ok, I removed the littletiles mod and the server was opened, my problem was solved, thank you very much again.
    • The code is written by a neural network, but no matter how much I try to do damage or fire effect, either everything stops working, or the particles stop pointing at creatures. package net.tndax.thaumcraft.item.custom; import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.damagesource.DamageSource; import java.util.List; import net.minecraft.world.damagesource.DamageType; public class ProtectiveItem extends Item { public ProtectiveItem(Properties pProperties) { super(pProperties); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { if (level.isClientSide()) { new Thread(() -> { double radius = 2.0; // Радиус вращения double heightOffset = 1.5; // Высота вращения частиц относительно игрока int duration = 20000; // Продолжительность эффекта в миллисекундах int steps = 200; // Количество шагов в одном круге (увеличено для большей плотности частиц) long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < duration) { for (int step = 0; step < steps; step++) { try { Thread.sleep(5); // Время между шагами уменьшено для увеличения скорости } catch (InterruptedException e) { e.printStackTrace(); } double angle = 2 * Math.PI * step / steps; for (int i = 0; i < 5; i++) { // Добавляем несколько частиц с небольшими смещениями double offset = i * 0.1; double randomFactorX = Math.sin(Math.toRadians(step * 7 % 360 + offset)); double randomFactorY = Math.sin(Math.toRadians(step * 13 % 360 + offset)); double randomFactorZ = Math.sin(Math.toRadians(step * 17 % 360 + offset)); double x = player.getX() + radius * Math.cos(angle) * randomFactorX; double y = player.getY() + heightOffset + radius * Math.sin(angle) * randomFactorY; double z = player.getZ() + radius * Math.sin(angle) * randomFactorZ; level.addParticle(ParticleTypes.FLAME, x, y, z, 0, 0, 0); } // Проверяем наличие сущностей в радиусе 5 блоков List<Entity> nearbyEntities = level.getEntities(player, player.getBoundingBox().inflate(10), entity -> entity instanceof LivingEntity && entity != player); if (!nearbyEntities.isEmpty()) { Entity target = nearbyEntities.get(0); // Берём первую ближайшую сущность double targetX = target.getX(); double targetY = target.getY() + target.getEyeHeight(); double targetZ = target.getZ(); // Направляем частицы к цели for (int i = 0; i < 20; i++) { double t = i / 20.0; double particleX = player.getX() + t * (targetX - player.getX()); double particleY = player.getY() + heightOffset + t * (targetY - (player.getY() + heightOffset)); double particleZ = player.getZ() + t * (targetZ - player.getZ()); level.addParticle(ParticleTypes.FLAME, particleX, particleY, particleZ, 0, 0, 0); try { Thread.sleep(5); // Пауза между частицами } catch (InterruptedException e) { e.printStackTrace(); } } // Возвращаем частицы обратно к игроку for (int i = 0; i < 20; i++) { double t = i / 20.0; double particleX = targetX + t * (player.getX() - targetX); double particleY = targetY + t * (player.getY() + heightOffset - targetY); double particleZ = targetZ + t * (player.getZ() - targetZ); level.addParticle(ParticleTypes.FLAME, particleX, particleY, particleZ, 0, 0, 0); try { Thread.sleep(5); // Пауза между частицами } catch (InterruptedException e) { e.printStackTrace(); } } } } } }).start(); } return new InteractionResultHolder<>(InteractionResult.SUCCESS, player.getItemInHand(hand)); } }  
    • physicsmod is conflicting with embeddium - try other builds of both mods
  • Topics

×
×
  • Create New...

Important Information

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