 BlockCupboard.java (Client)
 BlockCupboard.java (Client)package net.minecraft.src;
public class BlockCupboard extends BlockChest
{
	protected BlockCupboard(int i,int tex)
	{
		super(i);
		blockIndexInTexture=tex;
	}
	
	@Override
	public int getBlockTextureFromSide(int i)
	{
		if(i == 3)
		{
			return blockIndexInTexture+1;
		} else
		{
			return blockIndexInTexture;
		}
	}
	
	private boolean isThereANeighborChest(World world, int i, int j, int k)
	{
		if(world.getBlockId(i, j, k) != blockID)
		{
			return false;
		}
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			return true;
		}
		return world.getBlockId(i, j-1, k) == blockID;
	}
	
	private void setDefaultDirection(World world, int i, int j, int k)
	{
		if(world.multiplayerWorld)
		{
			return;
		}
		int l = world.getBlockId(i, j, k - 1);
		int i1 = world.getBlockId(i, j, k + 1);
		int j1 = world.getBlockId(i - 1, j, k);
		int k1 = world.getBlockId(i + 1, j, k);
		byte byte0 = 3;
		if(Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])
		{
			byte0 = 3;
		}
		if(Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])
		{
			byte0 = 2;
		}
		if(Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])
		{
			byte0 = 5;
		}
		if(Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])
		{
			byte0 = 4;
		}
		world.setBlockMetadataWithNotify(i, j, k, byte0);
	}
	
	@Override
	public void onBlockAdded(World world, int i, int j, int k)
	{
		super.onBlockAdded(world, i, j, k);
		setDefaultDirection(world, i, j, k);
	}
	
	@Override
	public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
	{
		int blockDown=world.getBlockId(i,j-1,k);
		int blockUp=world.getBlockId(i,j+1,k);
		int metaData;
		if(blockUp==blockID)
			{
				metaData=world.getBlockMetadata(i,j+1,k);
				world.setBlockMetadataWithNotify(i, j, k, metaData);
				return;
			}
		if(blockDown==blockID)
			{
				metaData=world.getBlockMetadata(i,j-1,k);
				world.setBlockMetadataWithNotify(i, j, k, metaData);
				return;
			}
		int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
		if(l == 0)
		{
			world.setBlockMetadataWithNotify(i, j, k, 2);
		}
		if(l == 1)
		{
			world.setBlockMetadataWithNotify(i, j, k, 5);
		}
		if(l == 2)
		{
			world.setBlockMetadataWithNotify(i, j, k, 3);
		}
		if(l == 3)
		{
			world.setBlockMetadataWithNotify(i, j, k, 4);
		}
	}
	
	@Override
	public boolean canPlaceBlockAt(World world, int i, int j, int k)
	{
		int l = 0;
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			l++;
		}
		if(world.getBlockId(i, j-1, k) == blockID)
		{
			l++;
		}
		if(l > 1)
		{
			return false;
		}
		if(isThereANeighborChest(world, i, j+1, k))
		{
			return false;
		}
		return !isThereANeighborChest(world, i, j-1, k);
	}
	
	@Override
	public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l)
	{
		if(l == 1||l==0)
		{
			return blockIndexInTexture;
		}
		int blockUp = iblockaccess.getBlockId(i, j+1, k);
		int blockDown = iblockaccess.getBlockId(i, j-1, k);
		int metaData = iblockaccess.getBlockMetadata(i, j, k);
		if(blockDown == blockID)
		{
			if(metaData==l)
			{
				return blockIndexInTexture+1+16;
			}
			else
			{
				return blockIndexInTexture+16;
			}
		}
		if(blockUp == blockID)
		{
			if(metaData==l)
			{
				return blockIndexInTexture+1+32;
			}
			else
			{
				return blockIndexInTexture+32;
			}
		}
		if(metaData==l)
			{
				return blockIndexInTexture+1;
			}
		else
		{
			return blockIndexInTexture;
		}
	}
public boolean isBlocked(World world, int i, int j, int k)
{
	int l=world.getBlockMetadata(i,j,k);
	if(world.isBlockNormalCube(i, j, k-1) && l==2) return true;
	if(world.isBlockNormalCube(i, j, k+1) && l==3) return true;
	if(world.isBlockNormalCube(i-1, j, k) && l==4) return true;
	if(world.isBlockNormalCube(i+1, j, k) && l==5) return true;
	return false;
}
	@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
	{
		Object obj = (TileEntityChest)world.getBlockTileEntity(i, j, k);
		if(world.getBlockId(i, j, k) == blockID && isBlocked(world,i,j,k))
		{
			return true;
		}
		if(world.getBlockId(i, j+1, k) == blockID && isBlocked(world,i,j+1,k))
		{
			return true;
		}
		if(world.getBlockId(i, j-1, k) == blockID && isBlocked(world,i,j-1,k))
		{
			return true;
		}
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			obj = new InventoryLargeChest("Cupboard", (TileEntityChest)world.getBlockTileEntity(i, j+1, k), ((IInventory) (obj)));
		}
		if(world.getBlockId(i, j-1, k) == blockID)
		{
			obj = new InventoryLargeChest("Cupboard", ((IInventory) (obj)), (TileEntityChest)world.getBlockTileEntity(i, j-1, k));
		}
		if(world.multiplayerWorld)
		{
			return true;
		} else
		{
			entityplayer.displayGUIChest(((IInventory) (obj)));
			return true;
		}
	}	
}
 BlockCupboard.java (Server)
 BlockCupboard.java (Server)package net.minecraft.src;
public class BlockCupboard extends BlockChest
{
	protected BlockCupboard(int i,int tex)
	{
		super(i);
		blockIndexInTexture=tex;
	}
	
	@Override
	public int getBlockTextureFromSide(int i)
	{
		if(i == 3)
		{
			return blockIndexInTexture+1;
		} else
		{
			return blockIndexInTexture;
		}
	}
	
	private boolean isThereANeighborChest(World world, int i, int j, int k)
	{
		if(world.getBlockId(i, j, k) != blockID)
		{
			return false;
		}
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			return true;
		}
		return world.getBlockId(i, j-1, k) == blockID;
	}
	
	private void setDefaultDirection(World world, int i, int j, int k)
	{
		if(world.singleplayerWorld)
		{
			return;
		}
		int l = world.getBlockId(i, j, k - 1);
		int i1 = world.getBlockId(i, j, k + 1);
		int j1 = world.getBlockId(i - 1, j, k);
		int k1 = world.getBlockId(i + 1, j, k);
		byte byte0 = 3;
		if(Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])
		{
			byte0 = 3;
		}
		if(Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])
		{
			byte0 = 2;
		}
		if(Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])
		{
			byte0 = 5;
		}
		if(Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])
		{
			byte0 = 4;
		}
		world.setBlockMetadataWithNotify(i, j, k, byte0);
	}
	
	@Override
	public void onBlockAdded(World world, int i, int j, int k)
	{
		super.onBlockAdded(world, i, j, k);
		setDefaultDirection(world, i, j, k);
	}
	
	@Override
	public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
	{
		int blockDown=world.getBlockId(i,j-1,k);
		int blockUp=world.getBlockId(i,j+1,k);
		int metaData;
		if(blockUp==blockID)
			{
				metaData=world.getBlockMetadata(i,j+1,k);
				world.setBlockMetadataWithNotify(i, j, k, metaData);
				return;
			}
		if(blockDown==blockID)
			{
				metaData=world.getBlockMetadata(i,j-1,k);
				world.setBlockMetadataWithNotify(i, j, k, metaData);
				return;
			}
		int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
		if(l == 0)
		{
			world.setBlockMetadataWithNotify(i, j, k, 2);
		}
		if(l == 1)
		{
			world.setBlockMetadataWithNotify(i, j, k, 5);
		}
		if(l == 2)
		{
			world.setBlockMetadataWithNotify(i, j, k, 3);
		}
		if(l == 3)
		{
			world.setBlockMetadataWithNotify(i, j, k, 4);
		}
	}
	
	@Override
	public boolean canPlaceBlockAt(World world, int i, int j, int k)
	{
		int l = 0;
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			l++;
		}
		if(world.getBlockId(i, j-1, k) == blockID)
		{
			l++;
		}
		if(l > 1)
		{
			return false;
		}
		if(isThereANeighborChest(world, i, j+1, k))
		{
			return false;
		}
		return !isThereANeighborChest(world, i, j-1, k);
	}
	public boolean isBlocked(World world, int i, int j, int k)
	{
		int l=world.getBlockMetadata(i,j,k);
		if(world.isBlockNormalCube(i, j, k-1) && l==2) return true;
		if(world.isBlockNormalCube(i, j, k+1) && l==3) return true;
		if(world.isBlockNormalCube(i-1, j, k) && l==4) return true;
		if(world.isBlockNormalCube(i+1, j, k) && l==5) return true;
		return false;
	}
	@Override
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
	{
		Object obj = (TileEntityChest)world.getBlockTileEntity(i, j, k);
		if(world.getBlockId(i, j, k) == blockID && isBlocked(world,i,j,k))
		{
			return true;
		}
		if(world.getBlockId(i, j+1, k) == blockID && isBlocked(world,i,j+1,k))
		{
			return true;
		}
		if(world.getBlockId(i, j-1, k) == blockID && isBlocked(world,i,j-1,k))
		{
			return true;
		}
		if(world.getBlockId(i, j+1, k) == blockID)
		{
			obj = new InventoryLargeChest("Cupboard", (TileEntityChest)world.getBlockTileEntity(i, j+1, k), ((IInventory) (obj)));
		}
		if(world.getBlockId(i, j-1, k) == blockID)
		{
			obj = new InventoryLargeChest("Cupboard", ((IInventory) (obj)), (TileEntityChest)world.getBlockTileEntity(i, j-1, k));
		}
		if(world.singleplayerWorld)
		{
			return true;
		} else
		{
			entityplayer.displayGUIChest(((IInventory) (obj)));
			return true;
		}
	}	
}
 diff Block.java (Client)
 diff Block.java (Client)cupboard = (new BlockCupboard(221,1)).setHardness(2.5F).setStepSound(soundWoodFootstep).setBlockName("cupboard").disableNeighborNotifyOnMetadataChange();
 diff Block.java (Server)
 diff Block.java (Server)cupboard = (new BlockCupboard(221,1)).setHardness(2.5F).setStepSound(soundWoodFootstep).setBlockName("cupboard").setRequiresSelfNotify();
 diff CraftingManager.java
 diff CraftingManager.java				addRecipe(new ItemStack(Block.cupboard), new Object[] {
			"#", Character.valueOf('#'), Block.chest
		});
 текстура
 текстура скрин
 скрин Достижения
 Достижения Биржа
 Биржа 
 Карты ↓
 Карты ↓








 Поиск
 Поиск Твинки
 Твинки Друзья
 Друзья Администрация
 Администрация