Jump to content

[1.8] [Solved] crash onImpact splash potion


Glistre

Recommended Posts

Is the problem I am having because of missing texture or the onImpact method?  NPE...

 

[11:49:12] [Client thread/WARN]: Failed to load texture: glistremod:textures/items.poison_protection_1.png
java.io.FileNotFoundException: glistremod:textures/items.poison_protection_1.png
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:70) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:34) ~[simpleTexture.class:?]
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:70) [TextureManager.class:?]
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:44) [TextureManager.class:?]
at com.glistre.glistremod.effects.potions.splash.RenderSplashPotion.bindTexture(RenderSplashPotion.java:122) [RenderSplashPotion.class:?]
at com.glistre.glistremod.effects.potions.splash.RenderSplashPotion.bindEntityTexture(RenderSplashPotion.java:115) [RenderSplashPotion.class:?]
at com.glistre.glistremod.effects.potions.splash.RenderSplashPotion.doRender(RenderSplashPotion.java:62) [RenderSplashPotion.class:?]
at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:381) [RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:338) [RenderManager.class:?]
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:305) [RenderManager.class:?]
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:657) [RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1353) [EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1266) [EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1091) [EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
[11:49:12] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking entity
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:781) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]
Caused by: java.lang.NullPointerException
at com.glistre.glistremod.effects.potions.splash.EntitySplashProjectile.onImpact(EntitySplashProjectile.java:122) ~[EntitySplashProjectile.class:?]
at com.glistre.glistremod.effects.potions.splash.EntitySplashThrowable.onUpdate(EntitySplashThrowable.java:234) ~[EntitySplashThrowable.class:?]
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2031) ~[World.class:?]
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:758) ~[WorldServer.class:?]
at net.minecraft.world.World.updateEntity(World.java:1997) ~[World.class:?]
at net.minecraft.world.World.updateEntities(World.java:1823) ~[World.class:?]
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:587) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:775) ~[MinecraftServer.class:?]
... 4 more

 

package com.glistre.glistremod.effects.potions.splash;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.init.GlistreEntityRegistry;
import com.glistre.glistremod.init.ItemRegistry;

import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntitySplashProjectile extends EntitySplashThrowable
{
    /** The damage value of the thrown potion that this EntityPotion represents. */
    private ItemStack potionDamage;
    private static final String __OBFID = "CL_00001727";

    public EntitySplashProjectile(World world)
    {
        super(world);
    }

    public EntitySplashProjectile(World world, EntityLivingBase entity, int p_i1789_3_)
    {
        this(world, entity, new ItemStack(GlistreEntityRegistry.splash_poison_protection, 1, p_i1789_3_));
    }

    public EntitySplashProjectile(World world, EntityLivingBase entity, ItemStack itemStack)
    {
        super(world, entity);
        this.potionDamage = itemStack;
    }

    @SideOnly(Side.CLIENT)
    public EntitySplashProjectile(World world, double x, double y, double z, int p_i1791_8_)
    {
        this(world, x, y, z, new ItemStack(GlistreEntityRegistry.splash_poison_protection, 1, p_i1791_8_));
    }

    public EntitySplashProjectile(World world, double x, double y, double z, ItemStack itemStack)
    {
        super(world, x, y, z);
        this.potionDamage = itemStack;
    }

    /**
     * Gets the amount of gravity to apply to the thrown entity with each tick.
     */
    protected float getGravityVelocity()
    {
        return 0.05F;
    }

    protected float func_70182_d()
    {
        return 0.5F;
    }

    protected float func_70183_g()
    {
        return -20.0F;
    }
    

    public void setPotionDamage(int potionId)
    {
        if (this.potionDamage == null)
        {
            this.potionDamage = new ItemStack(GlistreEntityRegistry.splash_poison_protection, 1, 0);
        }

        this.potionDamage.setItemDamage(potionId);
    }

    /**
     * Returns the damage value of the thrown potion that this EntityPotion represents.
     */
    public int getPotionDamage()
    {
        if (this.potionDamage == null)
        {
            this.potionDamage = new ItemStack(GlistreEntityRegistry.splash_poison_protection, 1, 0);
        }

        return this.potionDamage.getItemDamage();
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
/*   @Override
    protected void onImpact(MovingObjectPosition m)
    {
    if(m.typeOfHit == EnumMovingObjectType.ENTITY)
    m.entityHit.addPotionEffect(entity.addPotionEffect(new PotionEffect(ItemRegistry.poison_protect_potion.id, 3000, 0, false, false));
);

    	 if (!this.worldObj.isRemote)
    	 {
    		 this.setDead();
    	 }
    }*/

  @Override
    protected void onImpact(MovingObjectPosition mop)
    { 
  AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(4.0D, 4.0D, 4.0D);
      List<EntityLivingBase> entities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

      if(mop.entityHit != null ) {
      if (entities != null && !entities.isEmpty())
      {
          Iterator iterator = entities.iterator();

          while (iterator.hasNext())
          {
              EntityLivingBase hitEntity = (EntityLivingBase)iterator.next();
              double distanceToHit = this.getDistanceSqToEntity(hitEntity);

              if (distanceToHit < 16.0D)
              {
                  double durationMultiplier = 1.0D - Math.sqrt(distanceToHit) / 4.0D;

                  if (hitEntity == mop.entityHit)
                  {
                      durationMultiplier = 1.0D;
                  }

                  for (EntityLivingBase entity : entities) {
                	  entity.addPotionEffect(new PotionEffect(ItemRegistry.poison_protect_potion.id, 3000, 0, false, false));
                	  }

    	 if (!this.worldObj.isRemote)
    	 {
    		 //2002 blue water potion circles, 2003 purple expanding effect, 2004 fire , 2005 green sparkles
    		 //changed last parameter this.getPotionDamage() to 4 makes green swirls; 888888 makes particles splashing charcoal, 555555 makes orange swirls, purple/pink 777777, 333333 reddust
    		 //6 grey swirls 444444 darkredblood reddust,  2 light blue grey swirls 229911 darkblue swirls
    		 //1.8 update added BlockPos next line
    		 BlockPos pos = new BlockPos((int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ));
    		 this.worldObj.playAuxSFX(2002, pos, 4);
    		 this.setDead();
    	 }
              }
         }
        }
      }
      }
    

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
   public void readEntityFromNBT(NBTTagCompound tagCompound)
    {
        super.readEntityFromNBT(tagCompound);

        if (tagCompound.hasKey("Potion", 10))
        {
            this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("Potion"));
        }
        else
        {
            this.setPotionDamage(tagCompound.getInteger("potionValue"));
        }

        if (this.potionDamage == null)
        {
            this.setDead();
        }
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound p_70014_1_)
    {
        super.writeEntityToNBT(p_70014_1_);

        if (this.potionDamage != null)
        {
            p_70014_1_.setTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound()));
        }
    }


}

Link to comment
Share on other sites

Entity#getBoundingBox

always returns

null

unless the

Entity

subclass has overridden it (only

EntityBoat

and

EntityMincraft

override it to return a non-

null

value in vanilla).

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

Entity#getBoundingBox

always returns

null

unless the

Entity

subclass has overridden it (only

EntityBoat

and

EntityMincraft

override it to return a non-

null

value in vanilla).

 

Okay fixed that , thank you very, very much

 

#getEntityBoundingBox

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.

Announcements



×
×
  • Create New...

Important Information

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