From 483a878b8bcf1feb789cb5fd9374d0a060cc4d8a Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Wed, 20 Apr 2011 19:05:14 +0200 Subject: Update for 1.4_00_01 -- if you bypassed Bukkit, you will most likely break. --- .../java/net/minecraft/server/EntityHuman.java | 124 ++++++++++----------- 1 file changed, 61 insertions(+), 63 deletions(-) (limited to 'src/main/java/net/minecraft/server/EntityHuman.java') diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index f77ea7cf..a33b0fe6 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -40,9 +40,7 @@ public abstract class EntityHuman extends EntityLiving { public boolean fauxSleeping; // CraftBukkit end private ChunkCoordinates b; - // CraftBukkit start - public int sleepTicks; - // CraftBukkit end + public int sleepTicks; // CraftBukkit (public) public float z; public float A; private ChunkCoordinates d; @@ -54,9 +52,9 @@ public abstract class EntityHuman extends EntityLiving { this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic); this.activeContainer = this.defaultContainer; this.height = 1.62F; - ChunkCoordinates chunkcoordinates = world.m(); + ChunkCoordinates chunkcoordinates = world.getSpawn(); - this.c((double) chunkcoordinates.a + 0.5D, (double) (chunkcoordinates.b + 1), (double) chunkcoordinates.c + 0.5D, 0.0F, 0.0F); + this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F); this.health = 20; this.P = "humanoid"; this.O = 180.0F; @@ -70,7 +68,7 @@ public abstract class EntityHuman extends EntityLiving { } public void f_() { - if (this.F()) { + if (this.isSleeping()) { ++this.sleepTicks; if (this.sleepTicks > 100) { this.sleepTicks = 100; @@ -133,7 +131,7 @@ public abstract class EntityHuman extends EntityLiving { } protected boolean p_() { - return this.health <= 0 || this.F(); + return this.health <= 0 || this.isSleeping(); } protected void u() { @@ -161,7 +159,7 @@ public abstract class EntityHuman extends EntityLiving { } public void r() { - if (this.world.j == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) { + if (this.world.spawnMonsters == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) { this.b(1); } @@ -208,7 +206,7 @@ public abstract class EntityHuman extends EntityLiving { public void a(Entity entity) { super.a(entity); this.b(0.2F, 0.2F); - this.a(this.locX, this.locY, this.locZ); + this.setPosition(this.locX, this.locY, this.locZ); this.motY = 0.10000000149011612D; if (this.name.equals("Notch")) { this.a(new ItemStack(Item.APPLE, 1), true); @@ -216,8 +214,8 @@ public abstract class EntityHuman extends EntityLiving { this.inventory.h(); if (entity != null) { - this.motX = (double) (-MathHelper.b((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - this.motZ = (double) (-MathHelper.a((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motX = (double) (-MathHelper.cos((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motZ = (double) (-MathHelper.sin((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); } else { this.motX = this.motZ = 0.0D; } @@ -236,7 +234,7 @@ public abstract class EntityHuman extends EntityLiving { } public void z() { - this.a(this.inventory.a(this.inventory.c, 1), false); + this.a(this.inventory.a(this.inventory.itemInHandIndex, 1), false); } public void b(ItemStack itemstack) { @@ -247,7 +245,7 @@ public abstract class EntityHuman extends EntityLiving { if (itemstack != null) { EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.q(), this.locZ, itemstack); - entityitem.c = 40; + entityitem.pickupDelay = 40; float f = 0.1F; float f1; @@ -255,14 +253,14 @@ public abstract class EntityHuman extends EntityLiving { f1 = this.random.nextFloat() * 0.5F; float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; - entityitem.motX = (double) (-MathHelper.a(f2) * f1); - entityitem.motZ = (double) (MathHelper.b(f2) * f1); + entityitem.motX = (double) (-MathHelper.sin(f2) * f1); + entityitem.motZ = (double) (MathHelper.cos(f2) * f1); entityitem.motY = 0.20000000298023224D; } else { f = 0.3F; - entityitem.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f); - entityitem.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); + entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); + entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); + entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); f = 0.02F; f1 = this.random.nextFloat() * 3.1415927F * 2.0F; f *= this.random.nextFloat(); @@ -294,7 +292,7 @@ public abstract class EntityHuman extends EntityLiving { } protected void a(EntityItem entityitem) { - this.world.a((Entity) entityitem); + this.world.addEntity(entityitem); } public float a(Block block) { @@ -324,11 +322,11 @@ public abstract class EntityHuman extends EntityLiving { this.sleeping = nbttagcompound.m("Sleeping"); this.sleepTicks = nbttagcompound.d("SleepTimer"); if (this.sleeping) { - this.b = new ChunkCoordinates(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)); + this.b = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); this.a(true, true, false); } - if (nbttagcompound.b("SpawnX") && nbttagcompound.b("SpawnY") && nbttagcompound.b("SpawnZ")) { + if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { this.d = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ")); } } @@ -340,9 +338,9 @@ public abstract class EntityHuman extends EntityLiving { nbttagcompound.a("Sleeping", this.sleeping); nbttagcompound.a("SleepTimer", (short) this.sleepTicks); if (this.d != null) { - nbttagcompound.a("SpawnX", this.d.a); - nbttagcompound.a("SpawnY", this.d.b); - nbttagcompound.a("SpawnZ", this.d.c); + nbttagcompound.a("SpawnX", this.d.x); + nbttagcompound.a("SpawnY", this.d.y); + nbttagcompound.a("SpawnZ", this.d.z); } } @@ -350,7 +348,7 @@ public abstract class EntityHuman extends EntityLiving { public void b(int i, int j, int k) {} - public void b(Entity entity, int i) {} + public void receive(Entity entity, int i) {} public float q() { return 0.12F; @@ -360,25 +358,25 @@ public abstract class EntityHuman extends EntityLiving { this.height = 1.62F; } - public boolean a(Entity entity, int i) { + public boolean damageEntity(Entity entity, int i) { this.at = 0; if (this.health <= 0) { return false; } else { - if (this.F()) { + if (this.isSleeping()) { this.a(true, true, false); } if (entity instanceof EntityMonster || entity instanceof EntityArrow) { - if (this.world.j == 0) { + if (this.world.spawnMonsters == 0) { i = 0; } - if (this.world.j == 1) { + if (this.world.spawnMonsters == 1) { i = i / 3 + 1; } - if (this.world.j == 3) { + if (this.world.spawnMonsters == 3) { i = i * 3 / 2; } } @@ -388,8 +386,8 @@ public abstract class EntityHuman extends EntityLiving { } else { Object object = entity; - if (entity instanceof EntityArrow && ((EntityArrow) entity).b != null) { - object = ((EntityArrow) entity).b; + if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { + object = ((EntityArrow) entity).shooter; } // CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters @@ -413,7 +411,7 @@ public abstract class EntityHuman extends EntityLiving { } this.a(StatisticList.t, i); - return super.a(entity, i); + return super.damageEntity(entity, i); } } } @@ -474,11 +472,11 @@ public abstract class EntityHuman extends EntityLiving { } public ItemStack A() { - return this.inventory.b(); + return this.inventory.getItemInHand(); } public void B() { - this.inventory.a(this.inventory.c, (ItemStack) null); + this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); } public double C() { @@ -512,7 +510,7 @@ public abstract class EntityHuman extends EntityLiving { } // CraftBukkit end - entity.a(this, i); + entity.damageEntity(this, i); ItemStack itemstack = this.A(); if (itemstack != null && entity instanceof EntityLiving) { @@ -535,8 +533,8 @@ public abstract class EntityHuman extends EntityLiving { public void a(ItemStack itemstack) {} - public void D() { - super.D(); + public void die() { + super.die(); this.defaultContainer.a(this); if (this.activeContainer != null) { this.activeContainer.a(this); @@ -548,8 +546,8 @@ public abstract class EntityHuman extends EntityLiving { } public EnumBedError a(int i, int j, int k) { - if (!this.F() && this.N()) { - if (this.world.m.c) { + if (!this.isSleeping() && this.N()) { + if (this.world.worldProvider.c) { return EnumBedError.NOT_POSSIBLE_HERE; } else if (this.world.d()) { return EnumBedError.NOT_POSSIBLE_NOW; @@ -561,16 +559,16 @@ public abstract class EntityHuman extends EntityLiving { org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k); PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); server.getPluginManager().callEvent(event); - + if (event.isCancelled()) { return EnumBedError.OTHER_PROBLEM; } } // CraftBukkit end - + this.b(0.2F, 0.2F); this.height = 0.2F; - if (this.world.f(i, j, k)) { + if (this.world.isLoaded(i, j, k)) { int l = this.world.getData(i, j, k); int i1 = BlockBed.c(l); float f = 0.5F; @@ -594,9 +592,9 @@ public abstract class EntityHuman extends EntityLiving { } this.e(i1); - this.a((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); + this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); } else { - this.a((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); + this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); } this.sleeping = true; @@ -604,7 +602,7 @@ public abstract class EntityHuman extends EntityLiving { this.b = new ChunkCoordinates(i, j, k); this.motX = this.motZ = this.motY = 0.0D; if (!this.world.isStatic) { - this.world.q(); + this.world.everyoneSleeping(); } return EnumBedError.OK; @@ -643,19 +641,19 @@ public abstract class EntityHuman extends EntityLiving { ChunkCoordinates chunkcoordinates = this.b; ChunkCoordinates chunkcoordinates1 = this.b; - if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) == Block.BED.id) { - BlockBed.a(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, false); - chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0); + if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) { + BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false); + chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); if (chunkcoordinates1 == null) { - chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.a, chunkcoordinates.b + 1, chunkcoordinates.c); + chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z); } - this.a((double) ((float) chunkcoordinates1.a + 0.5F), (double) ((float) chunkcoordinates1.b + this.height + 0.1F), (double) ((float) chunkcoordinates1.c + 0.5F)); + this.setPosition((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F)); } this.sleeping = false; if (!this.world.isStatic && flag1) { - this.world.q(); + this.world.everyoneSleeping(); } // CraftBukkit start @@ -664,7 +662,7 @@ public abstract class EntityHuman extends EntityLiving { CraftServer server = ((WorldServer) world).getServer(); org.bukkit.block.Block bed; if (chunkcoordinates != null) { - bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c); + bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); } else { bed = ((WorldServer) world).getWorld().getBlockAt(player.getLocation()); } @@ -685,30 +683,30 @@ public abstract class EntityHuman extends EntityLiving { } private boolean m() { - return this.world.getTypeId(this.b.a, this.b.b, this.b.c) == Block.BED.id; + return this.world.getTypeId(this.b.x, this.b.y, this.b.z) == Block.BED.id; } - public static ChunkCoordinates a(World world, ChunkCoordinates chunkcoordinates) { + public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) { IChunkProvider ichunkprovider = world.n(); - ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c - 3 >> 4); - ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c - 3 >> 4); - ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c + 3 >> 4); - ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c + 3 >> 4); - if (world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) != Block.BED.id) { + ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); + ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); + ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4); + ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4); + if (world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) != Block.BED.id) { return null; } else { - ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0); + ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); return chunkcoordinates1; } } - public boolean F() { + public boolean isSleeping() { return this.sleeping; } - public boolean G() { + public boolean isDeeplySleeping() { return this.sleeping && this.sleepTicks >= 100; } -- cgit v1.2.3