From 7e06c9d13de555f7cfd18442e959e217cdca18c8 Mon Sep 17 00:00:00 2001 From: LexManos Date: Thu, 26 Apr 2012 19:11:16 -0700 Subject: [PATCH] New block hooks for creating custom beds. --- .../net/minecraft/src/Block.java.patch | 79 ++++++++++++++++++- .../net/minecraft/src/EntityPlayer.java.patch | 75 +++++++++++++++++- .../minecraft/src/EntityRenderer.java.patch | 26 +++++- .../net/minecraft/src/RenderBlocks.java.patch | 40 ++++++---- .../minecraft/src/RenderManager.java.patch | 21 +++++ .../net/minecraft/src/Block.java.patch | 79 ++++++++++++++++++- .../net/minecraft/src/EntityPlayer.java.patch | 59 +++++++++++++- 7 files changed, 357 insertions(+), 22 deletions(-) create mode 100644 forge/patches/minecraft/net/minecraft/src/RenderManager.java.patch diff --git a/forge/patches/minecraft/net/minecraft/src/Block.java.patch b/forge/patches/minecraft/net/minecraft/src/Block.java.patch index 9ab2d7f7d..5757a8f11 100644 --- a/forge/patches/minecraft/net/minecraft/src/Block.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/Block.java.patch @@ -80,7 +80,7 @@ { ItemStack var8 = this.createStackedBlock(par6); -@@ -1054,6 +1054,435 @@ +@@ -1054,6 +1054,512 @@ */ public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6) {} @@ -512,6 +512,83 @@ + } + return isBlockSolidOnSide(world, x, y, z, 1); + } ++ ++ /** ++ * Determines if this block is classified as a Bed, Allowing ++ * players to sleep in it, though the block has to specifically ++ * perform the sleeping functionality in it's activated event. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @return True to treat this as a bed ++ */ ++ public boolean isBed(World world, int x, int y, int z, EntityLiving player) ++ { ++ return blockID == Block.bed.blockID; ++ } ++ ++ /** ++ * Returns the position that the player is moved to upon ++ * waking up, or respawning at the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @return The spawn position ++ */ ++ public ChunkCoordinates getBedSpawnPosition(World world, int x, int y, int z, EntityPlayer player) ++ { ++ return BlockBed.getNearestEmptyChunkCoordinates(world, x, y, z, 0); ++ } ++ ++ /** ++ * Called when a user either starts or stops sleeping in the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed ++ */ ++ public void setBedOccupied(World world, int x, int y, int z, EntityPlayer player, boolean occupied) ++ { ++ BlockBed.setBedOccupied(world, x, y, z, occupied); ++ } ++ ++ /** ++ * Returns the direction of the block. Same values that ++ * are returned by BlockDirectional ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @return Bed direction ++ */ ++ public int getBedDirection(IBlockAccess world, int x, int y, int z) ++ { ++ return BlockBed.getDirection(world.getBlockMetadata(x, y, z)); ++ } ++ ++ /** ++ * Determines if the current block is the foot half of the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @return True if the current block is the foot side of a bed. ++ */ ++ public boolean isBedFoot(IBlockAccess world, int x, int y, int z) ++ { ++ return BlockBed.isBlockFootOfBed(world.getBlockMetadata(x, y, z)); ++ } + static { diff --git a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch index 308c876f1..feaeaf09c 100644 --- a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch @@ -123,7 +123,78 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1697,6 +1742,7 @@ +@@ -1254,6 +1299,11 @@ + { + int var9 = this.worldObj.getBlockMetadata(par1, par2, par3); + int var5 = BlockBed.getDirection(var9); ++ Block block = Block.blocksList[worldObj.getBlockId(par1, par2, par3)]; ++ if (block != null) ++ { ++ var5 = block.getBedDirection(worldObj, par1, par2, par3); ++ } + float var10 = 0.5F; + float var7 = 0.5F; + +@@ -1329,11 +1379,12 @@ + this.resetHeight(); + ChunkCoordinates var4 = this.playerLocation; + ChunkCoordinates var5 = this.playerLocation; ++ Block block = (var4 == null ? null : Block.blocksList[worldObj.getBlockId(var4.posX, var4.posY, var4.posZ)]); + +- if (var4 != null && this.worldObj.getBlockId(var4.posX, var4.posY, var4.posZ) == Block.bed.blockID) ++ if (var4 != null && block != null && block.isBed(worldObj, var4.posX, var4.posY, var4.posZ, this)) + { +- BlockBed.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, false); +- var5 = BlockBed.getNearestEmptyChunkCoordinates(this.worldObj, var4.posX, var4.posY, var4.posZ, 0); ++ block.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, this, false); ++ var5 = block.getBedSpawnPosition(worldObj, var4.posX, var4.posY, var4.posZ, this); + + if (var5 == null) + { +@@ -1370,7 +1421,9 @@ + */ + private boolean isInBed() + { +- return this.worldObj.getBlockId(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ) == Block.bed.blockID; ++ ChunkCoordinates c = playerLocation; ++ int blockID = worldObj.getBlockId(c.posX, c.posY, c.posZ); ++ return Block.blocksList[blockID] != null && Block.blocksList[blockID].isBed(worldObj, c.posX, c.posY, c.posZ, this); + } + + /** +@@ -1385,13 +1438,15 @@ + var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + +- if (par0World.getBlockId(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ) != Block.bed.blockID) ++ ChunkCoordinates c = par1ChunkCoordinates; ++ Block block = Block.blocksList[par0World.getBlockId(c.posX, c.posY, c.posZ)]; ++ if (block == null || !block.isBed(par0World, c.posX, c.posY, c.posZ, null)) + { + return null; + } + else + { +- ChunkCoordinates var3 = BlockBed.getNearestEmptyChunkCoordinates(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, 0); ++ ChunkCoordinates var3 = block.getBedSpawnPosition(par0World, c.posX, c.posY, c.posZ, null); + return var3; + } + } +@@ -1403,8 +1458,11 @@ + { + if (this.playerLocation != null) + { +- int var1 = this.worldObj.getBlockMetadata(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ); +- int var2 = BlockBed.getDirection(var1); ++ int x = playerLocation.posX; ++ int y = playerLocation.posY; ++ int z = playerLocation.posZ; ++ Block block = Block.blocksList[worldObj.getBlockId(x, y, z)]; ++ int var2 = (block == null ? 0 : block.getBedDirection(worldObj, x, y, z)); + + switch (var2) + { +@@ -1697,6 +1755,7 @@ return 101; } } @@ -131,7 +202,7 @@ } return var3; -@@ -1869,4 +1915,30 @@ +@@ -1869,4 +1928,30 @@ } public void func_50009_aI() {} diff --git a/forge/patches/minecraft/net/minecraft/src/EntityRenderer.java.patch b/forge/patches/minecraft/net/minecraft/src/EntityRenderer.java.patch index d87b0bbec..85e093ea5 100644 --- a/forge/patches/minecraft/net/minecraft/src/EntityRenderer.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/EntityRenderer.java.patch @@ -36,7 +36,27 @@ float var4 = 70.0F; if (par2) -@@ -1095,8 +1104,11 @@ +@@ -391,12 +400,14 @@ + + if (!this.mc.gameSettings.debugCamEnable) + { +- int var10 = this.mc.theWorld.getBlockId(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posY), MathHelper.floor_double(var2.posZ)); +- +- if (var10 == Block.bed.blockID) ++ int x = MathHelper.floor_double(var2.posX); ++ int y = MathHelper.floor_double(var2.posY); ++ int z = MathHelper.floor_double(var2.posZ); ++ Block block = Block.blocksList[mc.theWorld.getBlockId(x, y, z)]; ++ ++ if (block != null && block.isBed(mc.theWorld, x, y, z, var2)) + { +- int var11 = this.mc.theWorld.getBlockMetadata(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posY), MathHelper.floor_double(var2.posZ)); +- int var12 = var11 & 3; ++ int var12 = block.getBedDirection(mc.theWorld, x, y, z); + GL11.glRotatef((float)(var12 * 90), 0.0F, 1.0F, 0.0F); + } + +@@ -1095,8 +1106,11 @@ var20 = (EntityPlayer)var4; GL11.glDisable(GL11.GL_ALPHA_TEST); Profiler.endStartSection("outline"); @@ -50,7 +70,7 @@ GL11.glEnable(GL11.GL_ALPHA_TEST); } } -@@ -1160,8 +1172,12 @@ +@@ -1160,8 +1174,12 @@ var20 = (EntityPlayer)var4; GL11.glDisable(GL11.GL_ALPHA_TEST); Profiler.endStartSection("outline"); @@ -65,7 +85,7 @@ GL11.glEnable(GL11.GL_ALPHA_TEST); } -@@ -1185,6 +1201,9 @@ +@@ -1185,6 +1203,9 @@ this.setupFog(1, par1); GL11.glPopMatrix(); } diff --git a/forge/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch b/forge/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch index e3a178e95..2fe3c05b4 100644 --- a/forge/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch @@ -1,6 +1,18 @@ --- ../src_base/minecraft/net/minecraft/src/RenderBlocks.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft/net/minecraft/src/RenderBlocks.java 0000-00-00 00:00:00.000000000 -0000 -@@ -1375,7 +1375,7 @@ +@@ -424,9 +424,8 @@ + public boolean renderBlockBed(Block par1Block, int par2, int par3, int par4) + { + Tessellator var5 = Tessellator.instance; +- int var6 = this.blockAccess.getBlockMetadata(par2, par3, par4); +- int var7 = BlockBed.getDirection(var6); +- boolean var8 = BlockBed.isBlockFootOfBed(var6); ++ int var7 = par1Block.getBedDirection(blockAccess, par2, par3, par4); ++ boolean var8 = par1Block.isBedFoot(blockAccess, par2, par3, par4); + float var9 = 0.5F; + float var10 = 1.0F; + float var11 = 0.8F; +@@ -1375,7 +1374,7 @@ double var28; double var30; @@ -9,7 +21,7 @@ { float var36 = 0.2F; float var33 = 0.0625F; -@@ -1395,7 +1395,7 @@ +@@ -1395,7 +1394,7 @@ var9 = var18; } @@ -18,7 +30,7 @@ { var5.addVertexWithUV((double)((float)par2 + var36), (double)((float)par3 + var17 + var33), (double)(par4 + 1), var11, var13); var5.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 0) + var33), (double)(par4 + 1), var11, var15); -@@ -1407,7 +1407,7 @@ +@@ -1407,7 +1406,7 @@ var5.addVertexWithUV((double)((float)par2 + var36), (double)((float)par3 + var17 + var33), (double)(par4 + 1), var11, var13); } @@ -27,7 +39,7 @@ { var5.addVertexWithUV((double)((float)(par2 + 1) - var36), (double)((float)par3 + var17 + var33), (double)(par4 + 0), var9, var13); var5.addVertexWithUV((double)(par2 + 1 - 0), (double)((float)(par3 + 0) + var33), (double)(par4 + 0), var9, var15); -@@ -1419,7 +1419,7 @@ +@@ -1419,7 +1418,7 @@ var5.addVertexWithUV((double)((float)(par2 + 1) - var36), (double)((float)par3 + var17 + var33), (double)(par4 + 0), var9, var13); } @@ -36,7 +48,7 @@ { var5.addVertexWithUV((double)(par2 + 0), (double)((float)par3 + var17 + var33), (double)((float)par4 + var36), var11, var13); var5.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 0) + var33), (double)(par4 + 0), var11, var15); -@@ -1431,7 +1431,7 @@ +@@ -1431,7 +1430,7 @@ var5.addVertexWithUV((double)(par2 + 0), (double)((float)par3 + var17 + var33), (double)((float)par4 + var36), var11, var13); } @@ -45,7 +57,7 @@ { var5.addVertexWithUV((double)(par2 + 1), (double)((float)par3 + var17 + var33), (double)((float)(par4 + 1) - var36), var9, var13); var5.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 0) + var33), (double)(par4 + 1 - 0), var9, var15); -@@ -1443,7 +1443,7 @@ +@@ -1443,7 +1442,7 @@ var5.addVertexWithUV((double)(par2 + 1), (double)((float)par3 + var17 + var33), (double)((float)(par4 + 1) - var36), var9, var13); } @@ -54,7 +66,7 @@ { var18 = (double)par2 + 0.5D + 0.5D; var20 = (double)par2 + 0.5D - 0.5D; -@@ -3601,7 +3601,7 @@ +@@ -3601,7 +3600,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 2); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -63,7 +75,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -3724,7 +3724,7 @@ +@@ -3724,7 +3723,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3)); @@ -72,7 +84,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -3847,7 +3847,7 @@ +@@ -3847,7 +3846,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 4); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -81,7 +93,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -3970,7 +3970,7 @@ +@@ -3970,7 +3969,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 5); this.renderSouthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -90,7 +102,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -4082,7 +4082,7 @@ +@@ -4082,7 +4081,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 2); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -99,7 +111,7 @@ { var8.setColorOpaque_F(var18 * par5, var21 * par6, var24 * par7); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4098,7 +4098,7 @@ +@@ -4098,7 +4097,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -108,7 +120,7 @@ { var8.setColorOpaque_F(var18 * par5, var21 * par6, var24 * par7); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4114,7 +4114,7 @@ +@@ -4114,7 +4113,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 4); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -117,7 +129,7 @@ { var8.setColorOpaque_F(var19 * par5, var22 * par6, var25 * par7); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4130,7 +4130,7 @@ +@@ -4130,7 +4129,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 5); this.renderSouthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); diff --git a/forge/patches/minecraft/net/minecraft/src/RenderManager.java.patch b/forge/patches/minecraft/net/minecraft/src/RenderManager.java.patch new file mode 100644 index 000000000..b3ad76d9c --- /dev/null +++ b/forge/patches/minecraft/net/minecraft/src/RenderManager.java.patch @@ -0,0 +1,21 @@ +--- ../src_base/minecraft/net/minecraft/src/RenderManager.java 0000-00-00 00:00:00.000000000 -0000 ++++ ../src_work/minecraft/net/minecraft/src/RenderManager.java 0000-00-00 00:00:00.000000000 -0000 +@@ -125,12 +125,14 @@ + + if (par4EntityLiving.isPlayerSleeping()) + { +- int var7 = par1World.getBlockId(MathHelper.floor_double(par4EntityLiving.posX), MathHelper.floor_double(par4EntityLiving.posY), MathHelper.floor_double(par4EntityLiving.posZ)); ++ int x = MathHelper.floor_double(par4EntityLiving.posX); ++ int y = MathHelper.floor_double(par4EntityLiving.posY); ++ int z = MathHelper.floor_double(par4EntityLiving.posZ); ++ Block block = Block.blocksList[par1World.getBlockId(x, y, z)]; + +- if (var7 == Block.bed.blockID) ++ if (block != null && block.isBed(par1World, x, y, z, par4EntityLiving)) + { +- int var8 = par1World.getBlockMetadata(MathHelper.floor_double(par4EntityLiving.posX), MathHelper.floor_double(par4EntityLiving.posY), MathHelper.floor_double(par4EntityLiving.posZ)); +- int var9 = var8 & 3; ++ int var9 = block.getBedDirection(par1World, x, y, z); + this.playerViewY = (float)(var9 * 90 + 180); + this.playerViewX = 0.0F; + } diff --git a/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch b/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch index c3656209e..7db4b6e09 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/Block.java.patch @@ -68,7 +68,7 @@ { ItemStack var8 = this.createStackedBlock(par6); -@@ -970,6 +972,435 @@ +@@ -970,6 +972,512 @@ */ public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6) {} @@ -500,6 +500,83 @@ + } + return isBlockSolidOnSide(world, x, y, z, 1); + } ++ ++ /** ++ * Determines if this block is classified as a Bed, Allowing ++ * players to sleep in it, though the block has to specifically ++ * perform the sleeping functionality in it's activated event. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @return True to treat this as a bed ++ */ ++ public boolean isBed(World world, int x, int y, int z, EntityLiving player) ++ { ++ return blockID == Block.bed.blockID; ++ } ++ ++ /** ++ * Returns the position that the player is moved to upon ++ * waking up, or respawning at the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @return The spawn position ++ */ ++ public ChunkCoordinates getBedSpawnPosition(World world, int x, int y, int z, EntityPlayer player) ++ { ++ return BlockBed.getNearestEmptyChunkCoordinates(world, x, y, z, 0); ++ } ++ ++ /** ++ * Called when a user either starts or stops sleeping in the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @param player The player or camera entity, null in some cases. ++ * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed ++ */ ++ public void setBedOccupied(World world, int x, int y, int z, EntityPlayer player, boolean occupied) ++ { ++ BlockBed.setBedOccupied(world, x, y, z, occupied); ++ } ++ ++ /** ++ * Returns the direction of the block. Same values that ++ * are returned by BlockDirectional ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @return Bed direction ++ */ ++ public int getBedDirection(IBlockAccess world, int x, int y, int z) ++ { ++ return BlockBed.getDirection(world.getBlockMetadata(x, y, z)); ++ } ++ ++ /** ++ * Determines if the current block is the foot half of the bed. ++ * ++ * @param world The current world ++ * @param x X Position ++ * @param y Y Position ++ * @param z Z Position ++ * @return True if the current block is the foot side of a bed. ++ */ ++ public boolean isBedFoot(IBlockAccess world, int x, int y, int z) ++ { ++ return BlockBed.isBlockFootOfBed(world.getBlockMetadata(x, y, z)); ++ } + static { diff --git a/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch b/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch index 78cb344c7..2764a4b51 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch @@ -136,7 +136,64 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1725,4 +1781,45 @@ +@@ -1181,6 +1237,11 @@ + { + int var9 = this.worldObj.getBlockMetadata(par1, par2, par3); + int var5 = BlockBed.getDirection(var9); ++ Block block = Block.blocksList[worldObj.getBlockId(par1, par2, par3)]; ++ if (block != null) ++ { ++ var5 = block.getBedDirection(worldObj, par1, par2, par3); ++ } + float var10 = 0.5F; + float var7 = 0.5F; + +@@ -1256,11 +1317,12 @@ + this.resetHeight(); + ChunkCoordinates var4 = this.playerLocation; + ChunkCoordinates var5 = this.playerLocation; ++ Block block = (var4 == null ? null : Block.blocksList[worldObj.getBlockId(var4.posX, var4.posY, var4.posZ)]); + +- if (var4 != null && this.worldObj.getBlockId(var4.posX, var4.posY, var4.posZ) == Block.bed.blockID) ++ if (var4 != null && block != null && block.isBed(worldObj, var4.posX, var4.posY, var4.posZ, this)) + { +- BlockBed.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, false); +- var5 = BlockBed.getNearestEmptyChunkCoordinates(this.worldObj, var4.posX, var4.posY, var4.posZ, 0); ++ block.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, this, false); ++ var5 = block.getBedSpawnPosition(worldObj, var4.posX, var4.posY, var4.posZ, this); + + if (var5 == null) + { +@@ -1297,7 +1359,9 @@ + */ + private boolean isInBed() + { +- return this.worldObj.getBlockId(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ) == Block.bed.blockID; ++ ChunkCoordinates c = playerLocation; ++ int blockID = worldObj.getBlockId(c.posX, c.posY, c.posZ); ++ return Block.blocksList[blockID] != null && Block.blocksList[blockID].isBed(worldObj, c.posX, c.posY, c.posZ, this); + } + + /** +@@ -1312,13 +1376,15 @@ + var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + +- if (par0World.getBlockId(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ) != Block.bed.blockID) ++ ChunkCoordinates c = par1ChunkCoordinates; ++ Block block = Block.blocksList[par0World.getBlockId(c.posX, c.posY, c.posZ)]; ++ if (block == null || !block.isBed(par0World, c.posX, c.posY, c.posZ, null)) + { + return null; + } + else + { +- ChunkCoordinates var3 = BlockBed.getNearestEmptyChunkCoordinates(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, 0); ++ ChunkCoordinates var3 = block.getBedSpawnPosition(par0World, c.posX, c.posY, c.posZ, null); + return var3; + } + } +@@ -1725,4 +1791,45 @@ } public void func_50022_L() {}