- 33
- 0
Привет, снова я)
При попадание в NPC (entity) происходит вылет.В чём проблема ?
лог
код
При попадание в NPC (entity) происходит вылет.В чём проблема ?
лог
Код:
---- Minecraft Crash Report ----
// On the bright side, I bought you a teddy bear!
Time: 15.06.16 23:39
Description: Ticking entity
java.lang.NullPointerException: Ticking entity
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:839)
at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:84)
at com.Mdeme.SC.EntityBullet.onUpdate(EntityBullet.java:294)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684)
at net.minecraft.world.World.updateEntity(World.java:2258)
at net.minecraft.world.World.updateEntities(World.java:2108)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:839)
at net.minecraft.entity.monster.EntityMob.attackEntityFrom(EntityMob.java:84)
at com.Mdeme.SC.EntityBullet.onUpdate(EntityBullet.java:294)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684)
at net.minecraft.world.World.updateEntity(World.java:2258)
-- Entity being ticked --
Details:
Entity Type: null (com.Mdeme.SC.EntityBullet)
Entity ID: 46
Entity Name: неизвестно
Entity's Exact location: 694,88, 2,53, -718,16
Entity's Block location: World: (694,2,-719), Chunk: (at 6,0,1 in 43,-45; contains blocks 688,0,-720 to 703,255,-705), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513)
Entity's Momentum: -0,62, 0,00, -2,85
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2108)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
-- Affected level --
Details:
Level name: Новый мир
All players: 1 total; [EntityPlayerMP['Player987'/15, l='Новый мир', x=696,63, y=1,00, z=-709,40]]
Chunk stats: ServerChunkCache: 625 Drop: 0
Level seed: 5582360020664501315
Level generator: ID 01 - flat, ver 0. Features enabled: true
Level generator options: 2;7;1;village
Level spawn location: World: (686,4,-701), Chunk: (at 14,0,3 in 42,-44; contains blocks 672,0,-704 to 687,255,-689), Region: (1,-2; contains chunks 32,-64 to 63,-33, blocks 512,0,-1024 to 1023,255,-513)
Level time: 4968 game time, 4968 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 141485 (now: false), thunder time: 167802 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (x86) version 6.1
Java Version: 1.8.0_91, Oracle Corporation
Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
Memory: 947569040 bytes (903 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 5 mods loaded, 5 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHIJAAAA sc{0.2} [Space Craft Mod] (bin)
UCHIJAAAA tc{0.0} [tc Mod] (bin)
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player987'/15, l='Новый мир', x=696,63, y=1,00, z=-709,40]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
код
Код:
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
public class EntityBullet extends Entity implements IProjectile
{
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
/** 1 if the player can pick up the arrow */
public int canBePickedUp;
/** Seems to be some sort of timer for animating an arrow. */
public int arrowShake;
/** The owner of this arrow. */
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private int xTile;
public EntityBullet(World par1World, EntityLivingBase par2EntityLivingBase, float par3)
{
super(par1World);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = par2EntityLivingBase;
if (par2EntityLivingBase instanceof EntityPlayer)
{
this.canBePickedUp = 1;
}
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY -= 0.10000000149011612D;
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
}
@Override
public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_,
float p_70186_8_)
{
float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_);
p_70186_1_ /= (double)f2;
p_70186_3_ /= (double)f2;
p_70186_5_ /= (double)f2;
p_70186_1_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_3_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_5_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
p_70186_1_ *= (double)p_70186_7_;
p_70186_3_ *= (double)p_70186_7_;
p_70186_5_ *= (double)p_70186_7_;
this.motionX = p_70186_1_;
this.motionY = p_70186_3_;
this.motionZ = p_70186_5_;
float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, (double)f3) * 180.0D / Math.PI);
this.ticksInGround = 0;
}
@Override
protected void entityInit() {
}
@Override
protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {
this.field_145791_d = p_70037_1_.getShort("xTile");
this.field_145792_e = p_70037_1_.getShort("yTile");
this.field_145789_f = p_70037_1_.getShort("zTile");
this.ticksInGround = p_70037_1_.getShort("life");
this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inData = p_70037_1_.getByte("inData") & 255;
this.arrowShake = p_70037_1_.getByte("shake") & 255;
this.inGround = p_70037_1_.getByte("inGround") == 1;
if (p_70037_1_.hasKey("pickup", 99))
{
this.canBePickedUp = p_70037_1_.getByte("pickup");
}
else if (p_70037_1_.hasKey("player", 99))
{
this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
}
}
@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
p_70014_1_.setShort("xTile", (short)this.field_145791_d);
p_70014_1_.setShort("yTile", (short)this.field_145792_e);
p_70014_1_.setShort("zTile", (short)this.field_145789_f);
p_70014_1_.setShort("life", (short)this.ticksInGround);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
p_70014_1_.setByte("inData", (byte)this.inData);
p_70014_1_.setByte("shake", (byte)this.arrowShake);
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
}
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
{
this.motionX = p_70016_1_;
this.motionY = p_70016_3_;
this.motionZ = p_70016_5_;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
public void onUpdate()
{
super.onUpdate();
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block.getMaterial() != Material.air)
{
block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
this.inGround = true;
}
this.setDead();
}
if (this.arrowShake > 0)
{
--this.arrowShake;
}
if (this.inGround)
{
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData)
{
++this.ticksInGround;
if (this.ticksInGround == 1200)
{
this.setDead();
}
}
else
{
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else
{
++this.ticksInAir;
Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null)
{
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
{
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int k = MathHelper.ceiling_double_int((double)f2);
DamageSource damagesource = null;
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
movingobjectposition.entityHit.setFire(5);
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
{
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
this.setDead();
}
}
else
{
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
if (this.field_145790_g.getMaterial() != Material.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.00F;
if (this.isInWater())
{
for (int l = 0; l < 10000; ++l)
{
f4 = 0.25F;
}
f3 = 0.8F;
}
if (this.isWet())
{
this.extinguish();
}
this.motionX *= (double)f3;
this.motionY *= (double)f3;
this.motionZ *= (double)f3;
this.motionY -= (double)f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
private double p_72869_12_(int chunkCoordX) {
return 0;
}
protected void onImpact(MovingObjectPosition p_70227_1_)
{
if (!this.worldObj.isRemote)
{
if (p_70227_1_.entityHit != null)
{
if (this.shootingEntity != null)
{
}
else
{
p_70227_1_.entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
}
if (p_70227_1_.entityHit instanceof EntityLivingBase)
{
byte b0 = 0;
if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL)
{
b0 = 10;
}
else if (this.worldObj.difficultySetting == EnumDifficulty.HARD)
{
b0 = 40;
}
if (b0 > 0)
{
((EntityLivingBase)p_70227_1_.entityHit).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * b0, 1));
}
}
}
}
}
}